MagickCore::CompareImages() question

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
trevor123
Posts: 4
Joined: 2016-04-07T13:51:30-07:00
Authentication code: 1151

MagickCore::CompareImages() question

Post by trevor123 »

Hello

I've observed a difference in using MagickCore::CompareImages when the image hasn't originated from a decoded png. The code, essentially, looks like:

Code: Select all

Image a(pixel buffer);
Image b("b.png");
a.write("saved_a.png");
MagickCore::CompareImages(b.image(), a.image(), MagickCore::FuzzErrorMetric, &distortion, exception);
The resultant distortion is 0.00422927

If, however, I reload the "saved_a.png" file back into an Image type, and compare, I get a lower difference value, say 0.00345319:

Code: Select all

Image a(pixel buffer);
Image b("b.png");
a.write("saved_a.png");
Image c("saved_a.png"); // decode the image we've just saved
// note compare b and c
MagickCore::CompareImages(b.image(), c.image(), MagickCore::FuzzErrorMetric, &distortion, exception);
And indeed, this is true using the command line:

Code: Select all

$ compare -metric FUZZ a.png b.png null
0.00345319
How can I ensure I get the same values back without decoding the file that I've just written out (ie I don't want to do that as it's expensive). Is there something that I can invoke on Image?

Thanks a lot
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: MagickCore::CompareImages() question

Post by snibgo »

Please, always tell us what version of IM you are running on. The platform probably isn't important here, but the Q-number and HDRI is.

Is your pixel buffer identical to the saved file a.png? Perhaps the buffer is 32-bit or something.
snibgo's IM pages: im.snibgo.com
trevor123
Posts: 4
Joined: 2016-04-07T13:51:30-07:00
Authentication code: 1151

Re: MagickCore::CompareImages() question

Post by trevor123 »

Sorry, it's Magick++ v6.0.0-7. Presumably, you're referring to MAGICKCORE_QUANTUM_DEPTH (which is 16 - I've also tried 8 ) and MAGICKCORE_HDRI_ENABLE (which is 0). The pixel buffer is a Magick::CharPixel, and is a GL framebuffer.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: MagickCore::CompareImages() question

Post by snibgo »

v6.0.0-7 is a museum piece. I suggest you upgrade.

I don't know exactly what your first code example does, so I don't know if the difference between the compares is expected behaviour.
snibgo's IM pages: im.snibgo.com
Post Reply