0

I am new to the image comparison area.

I am using C# and Magick.NET (Magick.NET-Q16-AnyCPU version: 7.14.5) to compare screenshots.

Using .ColorFuzz I want to implement some kind of pixel tolerance, to ignore screenshots differences.

Here is my code:

double fuzzLevel = 0;

MagickImage baseHeaderView = new MagickImage(@"C:\githubActual.png");
MagickImage actualHeaderView = new MagickImage(@"C:\githubBase.png");
MagickImage diffView = new MagickImage();

baseHeaderView.ColorFuzz = (Percentage)fuzzLevel;
baseHeaderView.Compare(actualHeaderView, ErrorMetric.Absolute, diffView);

baseHeaderView.Composite(diffView, CompositeOperator.Over);
Console.WriteLine(baseHeaderView.GetAttribute("distortion"));
baseHeaderView.Write(@"C:\diffView.png");

Here is my base and actual screenshots.

This is the diff image when fuzzLevel variable = 0. baseHeaderView.GetAttribute("distortion") will return 614 different pixels in this case.

When I am changing fuzzLevel to 75, baseHeaderView.GetAttribute("distortion") returns 0 different pixels, but diff image still contains highlighted differences

So, my question is why when distortion is equal to 0 there are still highlighted differences in the diff image. Am I doing something wrong, or this is expected behavior?

It is possible to change the code above, so when distortion is 0, then diff image will not contain any highlighted differences?

feared
  • 3
  • 4
  • Why are you not using the return value of the `Compare` method? – dlemstra Dec 06 '19 at 22:12
  • Hi @dlemstra! Thanks for your comment. In this case, I had used GetAttribute("distortion") just for example. Could you please clarify why even when distortion is 0, I am still getting marked differences on my diff image? Probably, I am doing smth wrong in the example above? – feared Dec 06 '19 at 22:44

1 Answers1

0

It looks like you found a bug in the ImageMagick library. Your issues will be resolved with the next release of Magick.NET. Next time feel free to open an issue here instead: https://github.com/dlemstra/Magick.NET/issues

dlemstra
  • 7,813
  • 2
  • 27
  • 43