I\'m using compare to diff two similar color PNG files. They get a PSNR value of ~27.
The images contain a lot of white areas that will always match bet
Updated
Ok, how about we make a mask of the areas you want to be compared first? So, if you want to ignore areas where both images are white, you can do this:
convert a.png b.png \
-colorspace gray \
-compose multiply -composite \
-threshold 65534 \
-negate PNG8:mask.png
Then, when you do your comparison, mask the images beforehand:
convert \( a.png mask.png -compose copy-opacity -composite \) \
\( b.png mask.png -compose copy-opacity -composite \) \
-metric PSNR -compare diff.png
or with compare
like this in bash:
compare -metric PSNR \
<(convert a.png mask.png -compose copy-opacity -composite PNG:-) \
<(convert b.png mask.png -compose copy-opacity -composite PNG:-) \
diff.png
I still don't see what you are trying to do, and I would still like to see your images and what result you expect... however, I have taken your advice and made two similar images from this page with the two s
letters from the word missing
blanked out.
a.png
b.png
So, if I now compare them, I get this:
convert a.png b.png -metric PSNR -compare -format "%[distortion]" info:
33.4539
and this image:
or if I do as I said, I get this:
convert -fill black \( a.png +opaque white \) \( b.png +opaque white \) -metric PSNR -compare -format "%[distortion]" info:
7.25418
and this image:
But I am still none the wiser about what you want because I have done all the work and you have not answered me.
Original Answer
It would be better if you could post your images so we can see what you mean, but try using convert
like this to do the comparison:
convert a.png b.png -metric PSNR -compare diff.png
then you can add in pre-processing like this to make all white areas black before comparing. You can also add -fuzz 10%
to catch near-white colours.
convert -fill black
\( a.png +opaque white \) \
\( b.png +opaque white \) \
-metric PSNR -compare diff.png