]> granicus.if.org Git - imagemagick/commitdiff
sigmoid formula matches code
authornicolas <nicolas@git.imagemagick.org>
Wed, 1 Aug 2012 18:09:01 +0000 (18:09 +0000)
committernicolas <nicolas@git.imagemagick.org>
Wed, 1 Aug 2012 18:09:01 +0000 (18:09 +0000)
MagickCore/enhance.c

index 9fa0db5d732953c9e7a61cf6ca9c466a795a3433..982c8923babcf9f3b870a2a97ebfbc6a438f2a23 100644 (file)
@@ -3392,9 +3392,14 @@ MagickExport MagickBooleanType SigmoidalContrastImage(Image *image,
                (sigmoidal(contrast,QuantumScale*midpoint,(double)i/MaxMap)
                   -(u0+u1)/2.0)/(u1-u0+MagickEpsilon)+0.5)   ));
 #else
-        /* Scaled sigmoidal formula...
-             (1/(1+exp(a*(b-u))) - 1/(1+exp(a))) /
-                     (1/(1+exp(a*(b-1)))/(1+exp(a)))) */
+        /* Scaled sigmoidal formula:
+         *   (1/(1+exp(a*(b-u))) - 1/(1+exp(a*b)))
+         * / (1/(1+exp(a*(b-1))) - 1/(1+exp(a*b)))
+         * + 0.5
+        * 
+        * Nicolas strongly suspects that the +0.5 in the code is at the
+        * wrong paren nesting (does not match the previous one).
+         */
         sigmoidal_map[i]=(MagickRealType) ScaleMapToQuantum((MagickRealType)
           (MaxMap*((1.0/(1.0+exp(contrast*(midpoint/(double) QuantumRange-
           (double) i/MaxMap))))-(1.0/(1.0+exp(contrast*(midpoint/