Image comparison in C++

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
apollomok

Image comparison in C++

Post by apollomok »

Hi,

I am using the ImageMagick C++ API.
I try to differentiate the Color/Black & White image as the description in this link:
http://www.imagemagick.org/Usage/compare/#type_general

So, in Code:
Magick::Image source( "color.jpg" );
Magick::Image image = source;
image.type( GrayscaleType );
source.compare( image );
source.meanErrorPerPixel();
source.normalizedMaxError();
source.normalizedMeanError();

However, all meanErrorPerPixel, normalizedMaxError, and normalizedMeanError return zero.

The comparison seems working if replacing the line "image.type( GrayscaleType );" with "image.solarize();"

So, what happened? and how to make it work?

Thanks!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Image comparison in C++

Post by magick »

The problem is that the colorspaces differ (RGB vs. Grayscale), however for this special case it should compute the error. We will add a patch to ImageMagick-6.3.5-7 Beta by tommorrow.
apollomok

Re: Image comparison in C++

Post by apollomok »

Hi,

I downloaded and compiled the latest ImageMagick-6.3.5-7 Beta code.
I am getting the same result. I wonder if the problem hasn't been fixed?

Thanks!
Post Reply