Compare Function Questions

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
boogerlad
Posts: 2
Joined: 2012-05-04T23:15:27-07:00
Authentication code: 13

Compare Function Questions

Post by boogerlad »

Image
Image
1.png is the original, and 2.png is after running through a png optimizer. With ae metric and my eye, both say that there is no difference between them. Why is it then all the other metrics report there is a significant difference between them? Am I just misinterpreting the results?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Compare Function Questions

Post by fmw42 »

I can confirm your results on IM 6.7.6.9beta Q16 Mac OSX Snow Leopard.

It is clear that the two images are different as I compared the textual data from the verbose info.

I would report this on the bugs forum.

It is possible that -metric AE is using a reduced depth compare and the others are not. But I really don't know for sure. The IM developers would have to comment.
Last edited by fmw42 on 2012-05-05T10:44:07-07:00, edited 1 time in total.
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: Compare Function Questions

Post by whugemann »

Interesting question. If the ae metric results in a zero value (as is the case for your images), the image content is the same and all other metrics should rather return 0 or INF.

However, the two PNGs are not exactly identical, which you find out when you call
Identify -verbose 1.png >1.txt
Identify -verbose 2.png >2.txt
an then run
diff 1.txt 2.txt
The more compressed version has one color less (383 instead of 384), and the histograms differ slightly in a few colors.
Wolfgang Hugemann
boogerlad
Posts: 2
Joined: 2012-05-04T23:15:27-07:00
Authentication code: 13

Re: Compare Function Questions

Post by boogerlad »

well, according to the compressor I'm using, it
"It removes "garbage" from PNG files, cleans huffman symbols and does others tricks to optimize the Deflate structure. A quick cleaner which can be efficient after a PNG optimizer, and a PNG compressor. It does RGB space cleaning, palette optimization, ColorType best choice, BitDepth reduction, etc."
I'm not too sure why there would be one colour less though...
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Compare Function Questions

Post by magick »

Pixel differences between these two images are isolated to fully transparent pixels. The AbsoluteError metric notes any differences in pixel colors, however, fully transparent pixels are considered equivalent. In this case, fully transparent white is equivalent to fully transparent black. The AbsoluteError metric is sensitive to the -fuzz option. We could patch the algorithm to consider fully transparent black as different from fully transparent white, but we'll need Anthony's opinion before we can implement the change.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Compare Function Questions

Post by fmw42 »

magick wrote:Pixel differences between these two images are isolated to fully transparent pixels. The AbsoluteError metric notes any differences in pixel colors, however, fully transparent pixels are considered equivalent. In this case, fully transparent white is equivalent to fully transparent black. The AbsoluteError metric is sensitive to the -fuzz option. We could patch the algorithm to consider fully transparent black as different from fully transparent white, but we'll need Anthony's opinion before we can implement the change.

The histogram shows about 4 bins that have different values, but only in partially transparent alpha value. One bin of fully transparent black has different counts.

Are you saying that the comparison is restricted to fully opaque values. Thus fully transparent and partially transparent values are both ignored?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Compare Function Questions

Post by anthony »

magick wrote:Pixel differences between these two images are isolated to fully transparent pixels. The AbsoluteError metric notes any differences in pixel colors, however, fully transparent pixels are considered equivalent. In this case, fully transparent white is equivalent to fully transparent black. The AbsoluteError metric is sensitive to the -fuzz option. We could patch the algorithm to consider fully transparent black as different from fully transparent white, but we'll need Anthony's opinion before we can implement the change.
NO. The point of AE is that the images are the same! Full-transparent pixels have undefined colors, and AE reflects this when other metrics do not.


More that likely AE comes out a 'idenitical' is that for the partial transparent pixel is that it is so close to transparent the rounding effects make them equivelent. I saw similar almost fully transparent pixel in another image. and in a 8 bit depth they probably are fully transparent. But as they were not quite fully-transparent, and they did not have the 'right' color, thouse pixel causes lots of problems.

Simple way to find them is use -background white -alpha background -alpha off This sets all fully-transparent pixels to white, then turns alpha off. The result is that any badly colored 'black' pixels are now highlighted, as they will still be black, when all other pixels are now very bright.

For other methods, see IM Examples, Compare
http://www.imagemagick.org/Usage/compare/

If you know what program generated these bad (almost transparent) pixels. Please let us know.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply