Include methods for Image objects, or extend imageCompare, to give more detailed feedback on how exactly are the images not equal. E.g., it could return an optional string (passing by reference?) that specifies if the images are not equal but proportional, not equal in only few % of pixels, not equal but with a tolerance of a certain % of the image mean, etc. (some of these are maybe bad ideas). This would displace code to the library, enabling one stable implementation and well tested sentences that are clear and concise.
Example to check for normalization:
// function that checks if there is a normalization error between img1 and img2
function is_normalization_error(img1, img2){
var c = null
// Iterate through image
for( var x = 0; x < img.nx; x++){
for( var y = 0; y < img.ny; y++){
// Initialize proportionality constant
if (c == null && img1.getPixel(x,y) != 0 && img2.getPixel(x,y) != 0){
c = img1.getPixel(x,y) / img2.getPixel(x,y);
}
// If only one is 0, not proportional
if ((img1.getPixel(x,y) == 0) ^ (img2.getPixel(x,y) == 0)){
return false;
}
// Check proportionality constant, if both are not 0
if (img2.getPixel(x,y) != 0){
if (img1.getPixel(x,y)/img2.getPixel(x,y) != c){
return false;
}
}
}
}
return true;
}
Include methods for Image objects, or extend imageCompare, to give more detailed feedback on how exactly are the images not equal. E.g., it could return an optional string (passing by reference?) that specifies if the images are not equal but proportional, not equal in only few % of pixels, not equal but with a tolerance of a certain % of the image mean, etc. (some of these are maybe bad ideas). This would displace code to the library, enabling one stable implementation and well tested sentences that are clear and concise.
Example to check for normalization: