From 39b3e3f0d4b6237302f4af4223d6ebec45ada820 Mon Sep 17 00:00:00 2001 From: nicolas Date: Wed, 8 Aug 2012 16:21:15 +0000 Subject: [PATCH] IM7 enhance.c: functional macro names the way Cristy apparently likes them --- MagickCore/enhance.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/MagickCore/enhance.c b/MagickCore/enhance.c index a6b3cbd0f..fc5600035 100644 --- a/MagickCore/enhance.c +++ b/MagickCore/enhance.c @@ -3328,20 +3328,20 @@ MagickExport MagickBooleanType SigmoidalContrastImage(Image *image, (void) ResetMagickMemory(sigmoidal_map,0,(MaxMap+1)*sizeof(*sigmoidal_map)); /* Sigmoidal with inflexion point moved to b and "slope constant" set to a. */ -#define SIGMOIDAL(a,b,x) ( 1.0/(1.0+exp((a)*((b)-(x)))) ) +#define Sigmoidal(a,b,x) ( 1.0/(1.0+exp((a)*((b)-(x)))) ) /* Scaled sigmoidal formula: (1/(1+exp(a*(b-x))) - 1/(1+exp(a*b))) * / * (1/(1+exp(a*(b-1))) - 1/(1+exp(a*b))). * See http://osdir.com/ml/video.image-magick.devel/2005-04/msg00006.html and * http://www.cs.dartmouth.edu/farid/downloads/tutorials/fip.pdf. */ -#define SCALED_SIGMOIDAL(a,b,x) ( \ - (SIGMOIDAL((a),(b),(x))-SIGMOIDAL((a),(b),0.0)) / \ - (SIGMOIDAL((a),(b),1.0)-SIGMOIDAL((a),(b),0.0)) ) -#define INVERSE_SCALED_SIGMOIDAL(a,b,x) ( \ - (b) - log( -1.0+1.0/((SIGMOIDAL((a),(b),1.0)-SIGMOIDAL((a),(b),0.0))*(x)+ \ - SIGMOIDAL((a),(b),0.0)) ) / (a) ) - /* The limit of SCALED_SIGMOIDAL as a->0 is the identity, but a=0 gives a +#define ScaledSigmoidal(a,b,x) ( \ + (Sigmoidal((a),(b),(x))-Sigmoidal((a),(b),0.0)) / \ + (Sigmoidal((a),(b),1.0)-Sigmoidal((a),(b),0.0)) ) +#define InverseScaledSigmoidal(a,b,x) ( \ + (b) - log( -1.0+1.0/((Sigmoidal((a),(b),1.0)-Sigmoidal((a),(b),0.0))*(x)+ \ + Sigmoidal((a),(b),0.0)) ) / (a) ) + /* The limit of ScaledSigmoidal as a->0 is the identity, but a=0 gives a * division by zero. This is fixed below by hardwiring the identity when a is * small. This would appear to be safe because the series expansion of the * sigmoidal function around x=b is 1/2-a*(b-x)/4+... so that s(1)-s(0) is @@ -3353,11 +3353,11 @@ MagickExport MagickBooleanType SigmoidalContrastImage(Image *image, else if (sharpen != MagickFalse) for (i=0; i <= (ssize_t) MaxMap; i++) sigmoidal_map[i]=ScaleMapToQuantum( (double) (MaxMap* - SCALED_SIGMOIDAL(contrast,QuantumScale*midpoint,(double) i/MaxMap))); + ScaledSigmoidal(contrast,QuantumScale*midpoint,(double) i/MaxMap))); else for (i=0; i <= (ssize_t) MaxMap; i++) sigmoidal_map[i]=ScaleMapToQuantum((double) (MaxMap* - INVERSE_SCALED_SIGMOIDAL(contrast,QuantumScale*midpoint, + InverseScaledSigmoidal(contrast,QuantumScale*midpoint, (double) i/MaxMap))); if (image->storage_class == PseudoClass) for (i=0; i < (ssize_t) image->colors; i++) -- 2.49.0