Page 1 of 1

Compare Function Questions

Posted: 2012-05-04T23:22:05-07:00
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?

Re: Compare Function Questions

Posted: 2012-05-05T10:18:33-07:00
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.

Re: Compare Function Questions

Posted: 2012-05-05T10:24:49-07:00
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.

Re: Compare Function Questions

Posted: 2012-05-05T12:36:38-07:00
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...

Re: Compare Function Questions

Posted: 2012-05-05T14:32:43-07:00
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.

Re: Compare Function Questions

Posted: 2012-05-05T16:31:51-07:00
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?

Re: Compare Function Questions

Posted: 2012-05-06T02:10:58-07:00
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.