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

[QUESTION] Difference Percentage Calculations Don't Match #233

Open
PeerHalvorsen opened this issue May 27, 2022 · 1 comment
Open

[QUESTION] Difference Percentage Calculations Don't Match #233

PeerHalvorsen opened this issue May 27, 2022 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@PeerHalvorsen
Copy link

I'm trying to understand why getDifferencePercent(BufferedImage img1, BufferedImage img2) on line 138 of the ImageComparisonUtil class is returning a different result than the percent calculated in line 313 of the ImageComparison class.

The algorithm used to acquire the count of different pixels in populateTheMatrixOfTheDifferences() on line 234 seems to be similar to what's being done in getDifferencePercent(BufferedImage img1, BufferedImage img2) but the end result isn't the same.

It seems like if I'm trying to set an allowed percentage difference using setAllowingPercentOfDifferentPixels() I can't use the output of getDifferencePercent as a gauge since that value doesn't match what's calculated during the image comparison inside isAllowedPercentOfDifferentPixels(long countOfDifferentPixels)

@PeerHalvorsen PeerHalvorsen added the question Further information is requested label May 27, 2022
nikmazur pushed a commit to nikmazur/image-comparison that referenced this issue Nov 2, 2022
@nikmazur
Copy link

nikmazur commented Nov 2, 2022

I ran into the same issue when writing my own project: getDifferencePercent was returning an incorrect percentage. It seems that it was calculating the total number of different pixels incorrectly - instead of increasing an overall counter for each different pixel it was summing a long of differences from getRGB method.

Created a new pull request to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants