]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Sat, 10 Sep 2016 16:23:58 +0000 (12:23 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sat, 10 Sep 2016 16:23:58 +0000 (12:23 -0400)
MagickCore/identify.c
MagickCore/statistic.c
coders/ipl.c

index 038dd0100e8df397619482e9abe5ee5658a1c66f..6cd4528b950fd0747d0075f8ddfb53c55459ff63 100644 (file)
@@ -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;
index d74f9c4f70a516670f2d24bd33493931ad5554f5..d412119a4767d235aa8a3b4d09d45fb710fafcf4 100644 (file)
@@ -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;
index e425098d111dc100730eae70b11126919f7b3e29..ec41ff70b87aaeeccf6b78ff9991ccd51099f6d4 100644 (file)
@@ -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));