How to make part of picture same during comparison

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
harrychu
Posts: 2
Joined: 2018-08-11T22:15:12-07:00
Authentication code: 1152

How to make part of picture same during comparison

Post by harrychu » 2018-08-11T22:43:08-07:00

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 !!!

snibgo
Posts: 10513
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to make part of picture same during comparison

Post by snibgo » 2018-08-12T11:39:11-07:00

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.
snibgo's IM pages: im.snibgo.com

harrychu
Posts: 2
Joined: 2018-08-11T22:15:12-07:00
Authentication code: 1152

Re: How to make part of picture same during comparison

Post by harrychu » 2018-08-13T17:54:05-07:00

Thank you very much for the hint snibgo, I will try it out and update you on how the thing goes!!

Post Reply