]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Wed, 10 Jul 2013 22:20:51 +0000 (22:20 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Wed, 10 Jul 2013 22:20:51 +0000 (22:20 +0000)
MagickCore/compare.c
MagickCore/compare.h
MagickWand/compare.c

index fc5702022de7a102b4c20795760a2c086998d75c..3263a9daa3aae19a4a1833c2d4655013f07ae047 100644 (file)
@@ -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++)
index 8528f6047b9e1f534f01f12c15c1cc8fd2c4d128..5197e03df75893e16c70353954063f30859a4dcb 100644 (file)
@@ -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
index ff004167b4a59d5f0dbfd70225446f8bcecdc1f0..c80a23323c11668e608fb54239e2cce73abbb788 100644 (file)
@@ -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);
 }