]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Fri, 10 Jan 2014 14:21:07 +0000 (14:21 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Fri, 10 Jan 2014 14:21:07 +0000 (14:21 +0000)
MagickCore/compare.c

index 225e7c5658606d52fdda99decadbdea41491b133..6378e4ead5e4987ccfd388228184d41b130c749e 100644 (file)
@@ -1109,8 +1109,8 @@ static MagickBooleanType GetPerceptualHashDistortion(const Image *image,
     *reconstruct_moments;
 
   Image
-    *hclp_image,
-    *hclp_reconstruct;
+    *blur_image,
+    *blur_reconstruct;
 
   register ssize_t
     i;
@@ -1118,13 +1118,28 @@ static MagickBooleanType GetPerceptualHashDistortion(const Image *image,
   /*
     Compute perceptual hash in the native image colorspace.
   */
-  image_moments=GetImageMoments(image,exception);
-  if (image_moments == (ChannelMoments *) NULL)
+  blur_image=BlurImage(image,0,1,exception);
+  if (blur_image == (Image *) NULL)
     return(MagickFalse);
-  reconstruct_moments=GetImageMoments(reconstruct_image,exception);
+  image_moments=GetImageMoments(blur_image,exception);
+  if (image_moments == (ChannelMoments *) NULL)
+    {
+      blur_image=DestroyImage(blur_image);
+      return(MagickFalse);
+    }
+  blur_reconstruct=BlurImage(reconstruct_image,0,1,exception);
+  if (blur_reconstruct == (Image *) NULL)
+    {
+      image_moments=(ChannelMoments *) RelinquishMagickMemory(image_moments);
+      blur_image=DestroyImage(blur_image);
+      return(MagickFalse);
+    }
+  reconstruct_moments=GetImageMoments(blur_reconstruct,exception);
   if (reconstruct_moments == (ChannelMoments *) NULL)
     {
       image_moments=(ChannelMoments *) RelinquishMagickMemory(image_moments);
+      blur_image=DestroyImage(blur_image);
+      blur_reconstruct=DestroyImage(blur_reconstruct);
       return(MagickFalse);
     }
   for (i=0; i < 8; i++)
@@ -1151,38 +1166,28 @@ static MagickBooleanType GetPerceptualHashDistortion(const Image *image,
       distortion[CompositePixelChannel]+=difference*difference;
     }
   }
+  image_moments=(ChannelMoments *) RelinquishMagickMemory(image_moments);
   reconstruct_moments=(ChannelMoments *) RelinquishMagickMemory(
     reconstruct_moments);
-  image_moments=(ChannelMoments *) RelinquishMagickMemory(image_moments);
   /*
     Compute perceptual hash in the HCLP colorspace.
   */
-  hclp_image=CloneImage(image,0,0,MagickTrue,exception);
-  if (hclp_image == (Image *) NULL)
-    return(MagickFalse);
-  if (SetImageColorspace(hclp_image,HCLpColorspace,exception) == MagickFalse)
+  if ((SetImageColorspace(blur_image,HCLpColorspace,exception) == MagickFalse) ||
+      (SetImageColorspace(blur_reconstruct,HCLpColorspace,exception) == MagickFalse))
     {
-      hclp_image=DestroyImage(hclp_image);
+      blur_reconstruct=DestroyImage(blur_reconstruct);
+      blur_image=DestroyImage(blur_image);
       return(MagickFalse);
     }
-  image_moments=GetImageMoments(hclp_image,exception);
-  hclp_image=DestroyImage(hclp_image);
+  image_moments=GetImageMoments(blur_image,exception);
+  blur_image=DestroyImage(blur_image);
   if (image_moments == (ChannelMoments *) NULL)
-    return(MagickFalse);
-  hclp_reconstruct=CloneImage(reconstruct_image,0,0,MagickTrue,exception);
-  if (hclp_reconstruct == (Image *) NULL)
     {
-      image_moments=(ChannelMoments *) RelinquishMagickMemory(image_moments);
-      return(MagickFalse);
-    }
-  if (SetImageColorspace(hclp_reconstruct,HCLpColorspace,exception) == MagickFalse)
-    {
-      hclp_reconstruct=DestroyImage(hclp_reconstruct);
-      image_moments=(ChannelMoments *) RelinquishMagickMemory(image_moments);
+      blur_reconstruct=DestroyImage(blur_reconstruct);
       return(MagickFalse);
     }
-  reconstruct_moments=GetImageMoments(hclp_reconstruct,exception);
-  hclp_reconstruct=DestroyImage(hclp_reconstruct);
+  reconstruct_moments=GetImageMoments(blur_reconstruct,exception);
+  blur_reconstruct=DestroyImage(blur_reconstruct);
   if (reconstruct_moments == (ChannelMoments *) NULL)
     {
       image_moments=(ChannelMoments *) RelinquishMagickMemory(image_moments);