0
votes

I want to compare two JPG images. I know the parameter "fuzz" because of JPG compensation. Now I want to compare these two images with a mask - I dont want to compare the whole rectangle, only a part of it. As a result I want the pixel difference to calculate the percentage difference and in step two I want an image, which shows the difference in red/black.

I found this article: New compare feature

My old way (compare the whole rectangle):

/usr/bin/compare -metric ae /mnt/usbstorage/tmp/15.jpg /mnt/usbstorage/tmp/14.jpg -compose src /dev/null 2>&1
=> 8432 Pixels different

My old way (compare the whole rectangle and paint it to an image):

/usr/bin/compare -metric ae /mnt/usbstorage/tmp/15.jpg /mnt/usbstorage/tmp/14.jpg -compose src /dev/null -highlight-color Red -lowlight-color Black /mnt/usbstorage/tmp/diff.gif

My new try (compare the images with a masking image):

/usr/bin/compare -read-mask /mnt/usbstorage/tmp/mask.png -metric ae /mnt/usbstorage/tmp/15.jpg /mnt/usbstorage/tmp/14.jpg -compose src /dev/null 2>&1
=> 8432 Pixels different

The different pixels won't change! 8432 <=> 8432...so my mask doesn't change anything!

When I do that command to save the difference in a new image there are gray places for the mask, black places for non-changed-pixels and red areas for different pixels -> perfect. The image is perfect, the pixel comparison stays the same. Why?

I don't get it - do you have an explanation / example? Am I doing anything wrong?

Here are the files:

14.jpg

15.jpg

mask.png

1

1 Answers

0
votes

Masked compare only works in IM 7.0.3.9 or higher. In IM 7, you must add magick before compare:

magick compare -metric rmse -read-mask mask.png 14.jpg 15.jpg 14_15_diff.png


enter image description here

The red areas are where they differ under the mask. The white areas are where they are the same under the mask. The gray areas are outside the mask.