From a89535413da12effb627349cc74b6a90e8408d27 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 10 Sep 2016 12:23:58 -0400 Subject: [PATCH] ... --- MagickCore/identify.c | 2 ++ MagickCore/statistic.c | 10 ++++++++++ coders/ipl.c | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/MagickCore/identify.c b/MagickCore/identify.c index 038dd0100..6cd4528b9 100644 --- a/MagickCore/identify.c +++ b/MagickCore/identify.c @@ -407,6 +407,8 @@ static ssize_t PrintChannelPerceptualHash(Image *image,FILE *file, j; PixelChannel channel=GetPixelChannelChannel(image,i); + if (channel == IndexPixelChannel) + continue; PixelTrait traits=GetPixelChannelTraits(image,channel); if (traits == UndefinedPixelTrait) continue; diff --git a/MagickCore/statistic.c b/MagickCore/statistic.c index d74f9c4f7..d412119a4 100644 --- a/MagickCore/statistic.c +++ b/MagickCore/statistic.c @@ -1792,6 +1792,7 @@ MagickExport ChannelPerceptualHash *GetImagePerceptualHash(const Image *image, *artifact; MagickBooleanType + normalize, status; register char @@ -1804,6 +1805,9 @@ MagickExport ChannelPerceptualHash *GetImagePerceptualHash(const Image *image, MaxPixelChannels+1UL,sizeof(*perceptual_hash)); if (perceptual_hash == (ChannelPerceptualHash *) NULL) return((ChannelPerceptualHash *) NULL); + artifact=GetImageArtifact(image,"phash:normalize"); + normalize=(artifact == (const char *) NULL) || + (IsStringTrue(artifact) == MagickFalse) ? MagickFalse : MagickTrue; artifact=GetImageArtifact(image,"phash:colorspaces"); if (artifact != NULL) colorspaces=AcquireString(artifact); @@ -1846,8 +1850,14 @@ MagickExport ChannelPerceptualHash *GetImagePerceptualHash(const Image *image, break; for (channel=0; channel <= MaxPixelChannels; channel++) for (j=0; j < MaximumNumberOfImageMoments; j++) + { perceptual_hash[channel].phash[i][j]= (-MagickLog10(moments[channel].invariant[j])); + if ((normalize != MagickFalse) && + (fabs(perceptual_hash[channel].phash[i][j]) > MagickEpsilon)) + perceptual_hash[channel].phash[i][j]= + sqrt(perceptual_hash[channel].phash[i][j]/3.0); + } moments=(ChannelMoments *) RelinquishMagickMemory(moments); } perceptual_hash[0].number_colorspaces=(size_t) i; diff --git a/coders/ipl.c b/coders/ipl.c index e425098d1..ec41ff70b 100644 --- a/coders/ipl.c +++ b/coders/ipl.c @@ -669,8 +669,8 @@ static MagickBooleanType WriteIPLImage(const ImageInfo *image_info,Image *image, } } quantum_info=DestroyQuantumInfo(quantum_info); - if (GetNextImageInList(image) == (Image *) NULL) - break; + if (GetNextImageInList(image) == (Image *) NULL) + break; image=SyncNextImageInList(image); status=SetImageProgress(image,SaveImagesTag,scene++, GetImageListLength(image)); -- 2.49.0