From: cristy Date: Fri, 10 Jan 2014 14:21:07 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~2910 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2661ac1f59ccc02584f9500423304746a3a6effa;p=imagemagick --- diff --git a/MagickCore/compare.c b/MagickCore/compare.c index 225e7c565..6378e4ead 100644 --- a/MagickCore/compare.c +++ b/MagickCore/compare.c @@ -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);