]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Tue, 28 Feb 2017 01:41:33 +0000 (20:41 -0500)
committerCristy <urban-warrior@imagemagick.org>
Tue, 28 Feb 2017 01:42:14 +0000 (20:42 -0500)
MagickCore/compare.c
MagickCore/magick-type.h

index 5cdbd89e738546edcae574d681bacfdb5784a824..1b7c32e8eacc379a644d27d4e4c6b2346bc5e054 100644 (file)
@@ -1212,13 +1212,10 @@ static MagickBooleanType GetPeakSignalToNoiseRatio(const Image *image,
 
   status=GetMeanSquaredDistortion(image,reconstruct_image,distortion,exception);
   for (i=0; i <= MaxPixelChannels; i++)
-  {
-    double
-      gamma;
-
-    gamma=PerceptibleReciprocal(sqrt(distortion[i]));
-    distortion[i]=20.0*MagickLog10(gamma);
-  }
+    if (fabs(distortion[i]) < MagickEpsilon)
+      distortion[i]=INFINITY;
+    else
+      distortion[i]=20.0*MagickLog10(1.0/sqrt(distortion[i]));
   return(status);
 }
 
index a7b76d297da7acacdddf641f6ab62ad21e801343..05920677571169d1a4898eccdf06c56a1378e74e 100644 (file)
@@ -167,6 +167,9 @@ typedef enum
 #else
 #  define IsNaN(a) (a != a)
 #endif
+#if !defined(INFINITY)
+#  define INFINITY (log(0))
+#endif
 
 typedef struct _BlobInfo BlobInfo;