I'm trying to compare two screenshots from a webpage using Magick.NET, a C# library from ImageMagick. My code looks like this:
//Adapt image a bit otherwise he'll throw an error over the whole image
newScreenshot.ColorFuzz = new Percentage(15);
//Get the difference, 1 = perfectly the same, less then 1 not.
double diff = newScreenshot.Compare(benchmarkScreenshot, new ErrorMetric(), imgDiff);
//Output the result image for comparaison
imgDiff.Write(compareResultPath);
if (diff < 0.998)
{
//Do something
}
In this case I would get values lower then 1, where I imagined 1 would be "Identical" and everything less then 1 wouldn't be. I was wrong... So the only way I could think of to check if they are as identical as possible is to lower the tolerence by lowering the value in the if-statement.
So if I have a screenshot from a website, and I adapt it I get the following values for the "diff" variable:
Identical image: 0.99842343024053205
Removing a sentence: 0.99776453647987487
Removing one letter from any word on the page: 0.99698398328761506
I'm very afraid of the fact that removing an entire sentence has a higher value then just a single letter.
I also tried with ErrorMetric.Absolute rather then new ErrorMetric(), the values that I got for the "diff" variable were:
Identical image: 1949
Removing a sentence: 766
Removing one letter from any word on the page: 75
Is there a better, more accurate way then what I'm trying to do to check if there's an actual change or not?