Not work MagickCompareImages, need help

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
deomonstore2

Not work MagickCompareImages, need help

Post by deomonstore2 »

In console:

Code: Select all

C:\Program Files\ImageMagick-6.3.6-Q8>compare.exe -metric PSNR C:\1.bmp C:\2.bmp C:\Result.bmp
9.86553
In my application:

Code: Select all

D:\Test>Test.exe
Status = 1
Status = 1
Distortion =  0.00000000000000E+0000
Distortion =  6.70699291666667E+0003
Source code:

Code: Select all

program Test;

{$APPTYPE CONSOLE}

uses
SysUtils,
ImageMagick in 'PascalMagick\magick\ImageMagick.pas',
magick_wand in 'PascalMagick\wand\magick_wand.pas';

var
Img1, Img2, ImgResult: PMagickWand;
Status: MagickBooleanType;
Distortion: Double;

begin
MagickWandGenesis;

Img2 := NewMagickWand;
Img1 := NewMagickWand;

Status := MagickReadImage(Img1, PChar('C:\1.bmp'));
Writeln('Status = ', Status);

Status := MagickReadImage(Img2, PChar('C:\2.bmp'));
Writeln('Status = ', Status);

Writeln('Distortion = ', Distortion);
ImgResult := MagickCompareImages(Img1, Img2, PeakSignalToNoiseRatioMetric, @Distortion);
Writeln('Distortion = ', Distortion);

Img1 := DestroyMagickWand(Img1);
Img2 := DestroyMagickWand(Img2);
DestroyMagickWand(ImgResult);

MagickWandTerminus;
end.
Why 6.70699291666667E+0003 (but not 9.86553)? I don't understand, where is my trouble?
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Not work MagickCompareImages, need help

Post by el_supremo »

FYI: I tried this sort of thing in C using the rose: image.
First, I did this from the command line:

Code: Select all

convert rose: rose.jpg
convert rose.jpg -sharpen 0x1 reconstruct.jpg
compare -metric PSNR rose.jpg reconstruct.jpg difference.png
Which printed the result 27.0375

I then wrote and compiled a C program to compare rose.jpg and reconstruct.jpg using MagickWand's MagickCompareImages function and it prints exactly the same result.

Pete
deomonstore2

Re: Not work MagickCompareImages, need help

Post by deomonstore2 »

el_supremo
can i see source code of your C programm?
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Not work MagickCompareImages, need help

Post by el_supremo »

Code: Select all

#include <windows.h>
#include <wand/magick_wand.h>

void test_wand(void)
{
	MagickWand *img1 = NULL,*img2 = NULL,*m_wand = NULL;
	double distortion = 0.0;
	char info[128];

	MagickWandGenesis();
	img1 = NewMagickWand();
	img2 = NewMagickWand();
	MagickReadImage(img1, "rose.jpg");
	MagickReadImage(img2,"reconstruct.jpg");
	m_wand = MagickCompareImages(img1,img2,PeakSignalToNoiseRatioMetric,&distortion);

	sprintf(info,"%12.4f",distortion);
	MessageBox(NULL,info,"",MB_OK);

	/* Tidy up */
	m_wand = DestroyMagickWand(m_wand);
	img1 = DestroyMagickWand(img1);
	img2 = DestroyMagickWand(img2);
	MagickWandTerminus();
}
Pete
Post Reply