*reconstruct_moments;
Image
- *hclp_image,
- *hclp_reconstruct;
+ *blur_image,
+ *blur_reconstruct;
register ssize_t
i;
/*
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++)
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);