Page 1 of 1

How to make part of picture same during comparison

Posted: 2018-08-11T22:43:08-07:00
by harrychu
I was trying to compare photo "newScreenshot" with "snapshotImage", with code like this:

Code: Select all

using (var newScreenshot = new MagickImage(newScreenshotPath))
{
    var snapshotImage = TryGetBaselineImage(snapshotFilePath);
    if (snapshotImage == null) return false;
    using (snapshotImage)
    {
        var result = newScreenshot.Equals(snapshotImage);
        if (result) return true;
        using (var diffImage = new MagickImage())
        {
            newScreenshot.Compare(snapshotImage, ErrorMetric.Absolute, diffImage);
            //I also tried fuzz(10) but with no luck
            diffImage.Write(diffImagePath);
        }
        return false;
    }
}
  • newScreenshot file:
Image


  • snapshotImage file:
Image


  • diffImage file:
Image

My problem:
As we can see, at the bottom of diffImage:
Those text wordings get a lot of noise and recognized as different.

But from newScreenshot image and snapshotImage image, we can see that those wordings styles are just the same from a person's viewpoint:
Image

Wondering is there a way to pre-process 2 images or change a way of comparison, that can get a result of SAME?

Thank you very much !!!

Re: How to make part of picture same during comparison

Posted: 2018-08-12T11:39:11-07:00
by snibgo
diffImage tells you the difference is mostly vertical. Looking closely at the two inputs, we see there is a small (less than one pixel) displacement between the images. A small vertical blur eg -morphology Convolve Blur:0x1,90" smooths over that difference.

diffImage tells you where differences are, but doesn't tell you how much the difference is, either overall or the worst differences. The metrics (ie the numbers, eg "-metric RMSE" or "-metric PAE") will do that.

Re: How to make part of picture same during comparison

Posted: 2018-08-13T17:54:05-07:00
by harrychu
Thank you very much for the hint snibgo, I will try it out and update you on how the thing goes!!