From: cristy Date: Wed, 10 Jul 2013 22:20:51 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~3513 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2cb55d5f3c1b2424760d36868e152751c2473b2e;p=imagemagick --- diff --git a/MagickCore/compare.c b/MagickCore/compare.c index fc5702022..3263a9daa 100644 --- a/MagickCore/compare.c +++ b/MagickCore/compare.c @@ -881,7 +881,7 @@ static MagickBooleanType GetNormalizedCrossCorrelationDistortion( progress=0; for (i=0; i <= MaxPixelChannels; i++) distortion[i]=0.0; - area=1.0/((double) image->columns*image->rows-1); + area=1.0/((double) image->columns*image->rows); image_view=AcquireVirtualCacheView(image,exception); reconstruct_view=AcquireVirtualCacheView(reconstruct_image,exception); for (y=0; y < (ssize_t) image->rows; y++) diff --git a/MagickCore/compare.h b/MagickCore/compare.h index 8528f6047..5197e03df 100644 --- a/MagickCore/compare.h +++ b/MagickCore/compare.h @@ -26,16 +26,16 @@ extern "C" { typedef enum { - UndefinedMetric, + UndefinedErrorMetric, AbsoluteErrorMetric, + FuzzErrorMetric, MeanAbsoluteErrorMetric, MeanErrorPerPixelMetric, MeanSquaredErrorMetric, + NormalizedCrossCorrelationErrorMetric, PeakAbsoluteErrorMetric, PeakSignalToNoiseRatioMetric, - RootMeanSquaredErrorMetric, - NormalizedCrossCorrelationErrorMetric, - FuzzErrorMetric + RootMeanSquaredErrorMetric } MetricType; extern MagickExport double diff --git a/MagickWand/compare.c b/MagickWand/compare.c index ff004167b..c80a23323 100644 --- a/MagickWand/compare.c +++ b/MagickWand/compare.c @@ -174,6 +174,7 @@ static MagickBooleanType CompareUsage(void) WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info, int argc,char **argv,char **metadata,ExceptionInfo *exception) { +#define CompareEpsilon (1.0e-06) #define DefaultDissimilarityThreshold 0.31830988618379067154 #define DefaultSimilarityThreshold (-1.0) #define DestroyCompare() \ @@ -275,7 +276,7 @@ WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info, format=(char *) NULL; j=1; k=0; - metric=UndefinedMetric; + metric=UndefinedErrorMetric; NewImageStack(); option=(char *) NULL; pend=MagickFalse; @@ -1055,7 +1056,7 @@ WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info, difference_image->page.x,(double) difference_image->page.y); break; } - case UndefinedMetric: + case UndefinedErrorMetric: break; } } @@ -1195,7 +1196,7 @@ WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info, image->error.normalized_maximum_error); break; } - case UndefinedMetric: + case UndefinedErrorMetric: break; } channel_distortion=(double *) RelinquishMagickMemory( @@ -1218,5 +1219,14 @@ WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info, difference_image=DestroyImageList(difference_image); } DestroyCompare(); - return((status != 0) || (distortion != 0.0) ? MagickTrue : MagickFalse); + if ((metric == NormalizedCrossCorrelationErrorMetric) || + (metric == UndefinedErrorMetric)) + { + if (fabs(distortion-1.0) > CompareEpsilon) + return(MagickTrue); + } + else + if (fabs(distortion) > CompareEpsilon) + return(MagickTrue); + return(status != 0 ? MagickTrue : MagickFalse); }