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++)
typedef enum
{
- UndefinedMetric,
+ UndefinedErrorMetric,
AbsoluteErrorMetric,
+ FuzzErrorMetric,
MeanAbsoluteErrorMetric,
MeanErrorPerPixelMetric,
MeanSquaredErrorMetric,
+ NormalizedCrossCorrelationErrorMetric,
PeakAbsoluteErrorMetric,
PeakSignalToNoiseRatioMetric,
- RootMeanSquaredErrorMetric,
- NormalizedCrossCorrelationErrorMetric,
- FuzzErrorMetric
+ RootMeanSquaredErrorMetric
} MetricType;
extern MagickExport double
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() \
format=(char *) NULL;
j=1;
k=0;
- metric=UndefinedMetric;
+ metric=UndefinedErrorMetric;
NewImageStack();
option=(char *) NULL;
pend=MagickFalse;
difference_image->page.x,(double) difference_image->page.y);
break;
}
- case UndefinedMetric:
+ case UndefinedErrorMetric:
break;
}
}
image->error.normalized_maximum_error);
break;
}
- case UndefinedMetric:
+ case UndefinedErrorMetric:
break;
}
channel_distortion=(double *) RelinquishMagickMemory(
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);
}