How to make part of picture same during comparison
Posted: 2018-08-11T22:43:08-07:00
I was trying to compare photo "newScreenshot" with "snapshotImage", with code like this:



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:

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

- snapshotImage file:

- diffImage file:

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:

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