]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sat, 22 Feb 2014 23:13:34 +0000 (23:13 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sat, 22 Feb 2014 23:13:34 +0000 (23:13 +0000)
MagickCore/compare.c
MagickCore/identify.c
MagickCore/statistic.c
MagickCore/statistic.h

index 7e3b60971459e763e98e5a6091ed905d0079d51f..8f9c8d82dd3f36113c84be20d545a862a71af5f1 100644 (file)
@@ -1125,10 +1125,10 @@ static MagickBooleanType GetPerceptualHashDistortion(const Image *image,
   /*
     Compute perceptual hash in the sRGB colorspace.
   */
-  image_phash=GetImageChannelPerceptualHash(image,exception);
+  image_phash=GetImagePerceptualHash(image,exception);
   if (image_phash == (ChannelPerceptualHash *) NULL)
     return(MagickFalse);
-  reconstruct_phash=GetImageChannelPerceptualHash(reconstruct_image,exception);
+  reconstruct_phash=GetImagePerceptualHash(reconstruct_image,exception);
   if (image_phash == (ChannelPerceptualHash *) NULL)
     {
       image_phash=(ChannelPerceptualHash *) RelinquishMagickMemory(image_phash);
index b144e17b8e3c2a65c1736ec8bb1af6904764aa61..08c5a5e3ab72b83bc2c7966ffa001c39e9964552 100644 (file)
@@ -382,6 +382,23 @@ static ssize_t PrintChannelMoments(FILE *file,const PixelChannel channel,
   return(n);
 }
 
+static ssize_t PrintChannelPerceptualHash(FILE *file,const ChannelType channel,
+  const char *name,const ChannelPerceptualHash *channel_phash)
+{
+  register ssize_t
+    i;
+
+  ssize_t
+    n;
+
+  n=FormatLocaleFile(file,"    %s:\n",name);
+  for (i=0; i < 7; i++)
+    n+=FormatLocaleFile(file,"      %.20g: %.*g, %.*g\n",(double) i,
+      GetMagickPrecision(),channel_phash[channel].P[i],
+      GetMagickPrecision(),channel_phash[channel].Q[i]);
+  return(n);
+}
+
 static ssize_t PrintChannelStatistics(FILE *file,const PixelChannel channel,
   const char *name,const double scale,
   const ChannelStatistics *channel_statistics)
@@ -420,6 +437,9 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
   ChannelMoments
     *channel_moments;
 
+  ChannelPerceptualHash
+    *channel_phash;
+
   ChannelStatistics
     *channel_statistics;
 
@@ -668,6 +688,7 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
     MagickColorspaceOptions,(ssize_t) image->colorspace));
   channel_statistics=(ChannelStatistics *) NULL;
   channel_moments=(ChannelMoments *) NULL;
+  channel_phash=(ChannelPerceptualHash *) NULL;
   channel_features=(ChannelFeatures *) NULL;
   colorspace=image->colorspace;
   scale=1.0;
@@ -681,7 +702,10 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
         return(MagickFalse);
       artifact=GetImageArtifact(image,"identify:moments");
       if (artifact != (const char *) NULL)
-         channel_moments=GetImageMoments(image,exception);
+        {
+          channel_moments=GetImageMoments(image,exception);
+          channel_phash=GetImagePerceptualHash(image,exception);
+        }
       artifact=GetImageArtifact(image,"identify:features");
       if (artifact != (const char *) NULL)
         {
@@ -835,6 +859,21 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
       channel_moments=(ChannelMoments *) RelinquishMagickMemory(
         channel_moments);
     }
+  if (channel_phash != (ChannelPerceptualHash *) NULL)
+    {
+      (void) FormatLocaleFile(file,"  Channel perceptual hash:\n");
+      (void) PrintChannelPerceptualHash(file,RedChannel,"Red, Hue",
+        channel_phash);
+      (void) PrintChannelPerceptualHash(file,GreenChannel,"Green, Chroma",
+        channel_phash);
+      (void) PrintChannelPerceptualHash(file,BlueChannel,"Blue, Luma",
+        channel_phash);
+      if (image->alpha_trait == BlendPixelTrait)
+        (void) PrintChannelPerceptualHash(file,AlphaChannel,"Alpha, Alpha",
+          channel_phash);
+      channel_phash=(ChannelPerceptualHash *) RelinquishMagickMemory(
+        channel_phash);
+    }
   if (channel_features != (ChannelFeatures *) NULL)
     {
       (void) FormatLocaleFile(file,"  Channel features (horizontal, vertical, "
index 84183350481a258d11f3bf456133388ba433bd32..f3d30fff7f1a017d699a07c1aef420c98b03a89f 100644 (file)
@@ -1646,12 +1646,12 @@ MagickExport ChannelMoments *GetImageMoments(const Image *image,
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  GetImageChannelPerceptualHash() returns the perceptual hash of one or more
+%  GetImagePerceptualHash() returns the perceptual hash of one or more
 %  image channels.
 %
-%  The format of the GetImageChannelPerceptualHash method is:
+%  The format of the GetImagePerceptualHash method is:
 %
-%      ChannelPerceptualHash *GetImageChannelPerceptualHash(const Image *image,
+%      ChannelPerceptualHash *GetImagePerceptualHash(const Image *image,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -1671,7 +1671,7 @@ static inline double MagickLog10(const double x)
  return(log10(fabs(x)));
 }
 
-MagickExport ChannelPerceptualHash *GetImageChannelPerceptualHash(
+MagickExport ChannelPerceptualHash *GetImagePerceptualHash(
   const Image *image,ExceptionInfo *exception)
 {
   ChannelMoments
index b6bc8056159c173c08c202e818ea5b5c1a5760b3..78dd8584a544718ee272879a70cee9e605f0fde9 100644 (file)
@@ -129,7 +129,7 @@ extern MagickExport ChannelMoments
   *GetImageMoments(const Image *,ExceptionInfo *);
 
 extern MagickExport ChannelPerceptualHash
-  *GetImageChannelPerceptualHash(const Image *,ExceptionInfo *);
+  *GetImagePerceptualHash(const Image *,ExceptionInfo *);
 
 extern MagickExport Image
   *EvaluateImages(const Image *,const MagickEvaluateOperator,ExceptionInfo *),