]> granicus.if.org Git - imagemagick/blobdiff - wand/compare.c
(no commit message)
[imagemagick] / wand / compare.c
index b0a3a8ee8bb2e79c03873d39c984a9e11de06841..3034d0a1db7ab0f87875ecea5f8f1aa180bd42f4 100644 (file)
@@ -17,7 +17,7 @@
 %                               December 2003                                 %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -110,7 +110,7 @@ static MagickBooleanType CompareUsage(void)
       "-density geometry    horizontal and vertical density of the image",
       "-depth value         image depth",
       "-dissimilarity-threshold value",
-      "                     maximum RMSE for (sub)image match",
+      "                     maximum distortion for (sub)image match",
       "-encipher filename   convert plain pixels to cipher pixels",
       "-extract geometry    extract area from image",
       "-format \"string\"     output formatted image characteristics",
@@ -849,10 +849,14 @@ WandExport MagickBooleanType CompareImageCommand(ImageInfo *image_info,
             subimage_search=MagickTrue;
             break;
           }
+        if (LocaleCompare("synchronize",option+1) == 0)
+          break;
         ThrowCompareException(OptionError,"UnrecognizedOption",option)
       }
       case 't':
       {
+        if (LocaleCompare("taint",option+1) == 0)
+          break;
         if (LocaleCompare("transparent-color",option+1) == 0)
           {
             if (*option == '+')
@@ -933,52 +937,52 @@ WandExport MagickBooleanType CompareImageCommand(ImageInfo *image_info,
     ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]);
   image=GetImageFromList(image,0);
   reconstruct_image=GetImageFromList(image,1);
-  similarity_image=SimilarityImage(image,reconstruct_image,&offset,
-    &similarity_metric,exception);
-  if (similarity_metric > dissimilarity_threshold)
-    ThrowCompareException(ImageError,"ImagesTooDissimilar",image->filename);
+  if (subimage_search != MagickFalse)
+    {
+      similarity_image=SimilarityImage(image,reconstruct_image,&offset,
+        &similarity_metric,exception);
+      if (similarity_metric > dissimilarity_threshold)
+        ThrowCompareException(ImageError,"ImagesTooDissimilar",image->filename);
+    }
   if ((reconstruct_image->columns == image->columns) &&
       (reconstruct_image->rows == image->rows))
     difference_image=CompareImageChannels(image,reconstruct_image,channels,
       metric,&distortion,exception);
   else
-    if (subimage_search == MagickFalse)
-      difference_image=CompareImageChannels(image,reconstruct_image,channels,
-        metric,&distortion,exception);
+    if (similarity_image == (Image *) NULL)
+      ThrowCompareException(OptionError,"ImageWidthsOrHeightsDiffer",
+        image->filename)
     else
-      if (similarity_image != (Image *) NULL)
-        {
-          Image
-            *composite_image;
+      {
+        Image
+          *composite_image;
 
-          /*
-            Determine if reconstructed image is a subimage of the image.
-          */
-          composite_image=CloneImage(image,0,0,MagickTrue,exception);
-          if (composite_image == (Image *) NULL)
-            difference_image=CompareImageChannels(image,reconstruct_image,
+        /*
+          Determine if reconstructed image is a subimage of the image.
+        */
+        composite_image=CloneImage(image,0,0,MagickTrue,exception);
+        if (composite_image == (Image *) NULL)
+          difference_image=CompareImageChannels(image,reconstruct_image,
+            channels,metric,&distortion,exception);
+        else
+          {
+            (void) CompositeImage(composite_image,CopyCompositeOp,
+              reconstruct_image,offset.x,offset.y);
+            difference_image=CompareImageChannels(image,composite_image,
               channels,metric,&distortion,exception);
-          else
-            {
-              (void) CompositeImage(composite_image,CopyCompositeOp,
-                reconstruct_image,offset.x,offset.y);
-              difference_image=CompareImageChannels(image,composite_image,
-                channels,metric,&distortion,exception);
-              if (difference_image != (Image *) NULL)
-                {
-                  difference_image->page.x=offset.x;
-                  difference_image->page.y=offset.y;
-                }
-              composite_image=DestroyImage(composite_image);
-            }
-          if (difference_image == (Image *) NULL)
-            similarity_image=DestroyImage(similarity_image);
-          else
-            {
-              AppendImageToList(&difference_image,similarity_image);
-              similarity_image=(Image *) NULL;
-            }
-        }
+            if (difference_image != (Image *) NULL)
+              {
+                difference_image->page.x=offset.x;
+                difference_image->page.y=offset.y;
+              }
+            composite_image=DestroyImage(composite_image);
+          }
+        if (difference_image != (Image *) NULL)
+          {
+            AppendImageToList(&difference_image,similarity_image);
+            similarity_image=(Image *) NULL;
+          }
+      }
   if (difference_image == (Image *) NULL)
     status=0;
   else
@@ -1007,6 +1011,7 @@ WandExport MagickBooleanType CompareImageCommand(ImageInfo *image_info,
               break;
             }
             case AbsoluteErrorMetric:
+            case NormalizedCrossCorrelationErrorMetric:
             case PeakSignalToNoiseRatioMetric:
             {
               (void) fprintf(stderr,"%g",distortion);
@@ -1112,6 +1117,7 @@ WandExport MagickBooleanType CompareImageCommand(ImageInfo *image_info,
               break;
             }
             case AbsoluteErrorMetric:
+            case NormalizedCrossCorrelationErrorMetric:
             case PeakSignalToNoiseRatioMetric:
             {
               switch (image->colorspace)