(PECL imagick 2.0.0)

Imagick::sigmoidalContrastImageAjusta el contraste de una imagen


bool Imagick::sigmoidalContrastImage ( bool $sharpen , float $alpha , float $beta [, int $channel = Imagick::CHANNEL_ALL ] )

Ajusta el contraste de una imagen con un algoritmo de contraste sigmoidal no linear. Aumenta el contraste de la imagen usando una función de transferencia saturando los reflejos o las sombras. El contraste indica cuánto se incrementa el contraste (0 es nada; 3 es normal; 20 es enérgico); el punto medio indica dónde caen los medios-tonos en la imagen resultante (0 es blanco; 50 es medio-gris; 100 es negro). Establezca el parámtero sharpen a TRUE para incrementar el contraste de la imagen, si no, el contraste se reduce.






Valores devueltos

Devuelve TRUE en caso de éxito.


Lanza ImagickException en caso de error.

add a note add a note

User Contributed Notes 1 note

acameron at theatomgroup dot com
4 months ago
The documentation for this function really isn't useful or helpful at all. "Sharpen", "Contrast" and "Midpoint" aren't the names of the params, which are referred to as "alpha" and "beta".

The Imagemagick manual entry:

For those interested, the corrected formula for the 'sigmoidal non-linearity contrast control' is...
( 1/(1+exp(β*(α-u))) - 1/(1+exp(β)) ) / ( 1/(1+exp(β*(α-1))) - 1/(1+exp(β*α)) )
Where α is the threshold level, and β the contrast factor to be applied.
The formula is actually very simple exponential curve, with the bulk of the above formula is designed to ensure that 0 remains zero and 1 remains one. That is, the graph always goes though the points 0,0 and 1,1. And the highest gradient of change is at the given threshold.


In the Imagick extension source, the function call is:

 status = MagickSigmoidalContrastImageChannel(intern->magick_wand, channel, sharpen, alpha, beta);


Referring back to the binary API call gives:

foreign import ccall "MagickSigmoidalContrastImageChannel" magickSigmoidalContrastImageChannel
  :: Ptr MagickWand
  -> ChannelType       -- ^ identify which channel to level: `redChannel`, `greenChannel`
  -> MagickBooleanType -- ^ increase or decrease image contrast
  -> CDouble           -- ^ strength of the contrast, the larger the number the more 'threshold-like' it becomes
  -> CDouble           -- ^ midpoint of the function as a color value 0 to `quantumRange`
  -> IO MagickBooleanType


So the parameters should apparently be interpreted:

Sharpen:     0/1 (increase/decrease contrast)
Alpha:       Strength of the contrast (typically 3-20)
Beta:        Midpoint of the contrast (typically 50)
To Top