Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Informative comparison functions #3

Open
poldap opened this issue Mar 1, 2021 · 1 comment
Open

Informative comparison functions #3

poldap opened this issue Mar 1, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@poldap
Copy link
Collaborator

poldap commented Mar 1, 2021

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;
}
@poldap poldap added the enhancement New feature or request label Mar 1, 2021
@poldap
Copy link
Collaborator Author

poldap commented Apr 11, 2021

I recently discovered console.table() and I think it could help us with either displaying matrices (substitute for the current visualize) or comparing results to correct ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants