PHP 5.6.18 is available


(PECL imagick 2.0.0)



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

非線形 S 字コントラストアルゴリズムを用いて画像のコントラストを調整します。 S 字変換関数を使用し、ハイライトや影を飽和させることなく画像のコントラストを強調します。 contrast は、どの程度コントラストを向上させるかを表します (0 は何もしない、3 は一般的な程度、20 は押し出す) mid-point は、結果の画像での中間色の扱いを表します (0 は白、50 はグレー、100 は黒)。sharpen を TRUE にするとコントラストを強め、それ以外にするとコントラストを弱めます。

» ImageMagick v6 Examples - Image Transformations — Sigmoidal Non-linearity Contrast も参照ください。



If true increase the contrast, if false decrease the contrast.


The amount of contrast to apply. 1 is very little, 5 is a significant amount, 20 is extreme.


Where the midpoint of the gradient will be. This value should be in the range 0 to 1 - mutliplied by the quantum value for ImageMagick.


Which color channels the contrast will be applied to.


成功した場合に TRUE を返します。

例1 Imagick::sigmoidalContrastImage() によるグラデーションの作成 (ふたつの画像を、$contrast と $midpoint の定義でブレンドする)


function generateBlendImage($width$height$contrast 10$midpoint 0.5) {
$imagick = new Imagick();
$quanta $imagick->getQuantumRange();
$imagick->sigmoidalContrastImage(true$contrast$midpoint $quanta["quantumRangeLong"]);



エラー / 例外

エラー時に ImagickException をスローします。

add a note add a note

User Contributed Notes 2 notes

acameron at theatomgroup dot com
2 years 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)
2 months ago
The formula for sigmoidal contrast given by Thyssen is missing a term. It should be:

( 1/(1+exp(β*(α-u))) - 1/(1+exp(β*α)) ) / ( 1/(1+exp(β*(α-1))) - 1/(1+exp(β*α)) )

where there was an α missing from the second term.

Note that a sigmoidal contrast with α = 6 and β = 0.46 is approximately equivalent to combining a "screen" overlay of the image on itself, followed by a "multiply" overlay.
To Top