Imagick::contrastStretchImage

(PECL imagick 2.0.0)

Imagick::contrastStretchImageEnhances the contrast of a color image

Описание

bool Imagick::contrastStretchImage ( float $black_point , float $white_point [, int $channel = Imagick::CHANNEL_ALL ] )

Enhances the contrast of a color image by adjusting the pixels color to span the entire range of colors available. Этот метод доступен, если Imagick был скомпилирован с версией ImageMagick 6.2.9 или старше.

Список параметров

black_point

The black point.

white_point

The white point.

channel

Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Imagick::CHANNEL_ALL. Refer to this list of channel constants.

Возвращаемые значения

В случае успешной работы возвращает TRUE.

Коментарии

Автор:
Trying to figure out what values the black and white points can have and what their effects are nearly drove me around the bend. However, this works:

<?php
$width 
480;
$height 360;
$mask = new Imagick ();
$mask->newImage ($width$height"black");
$draw = new ImagickDraw ();
$draw->setFillColor ("white");
$draw->ellipse ($width 2$height 2$width 12$height 120360);
$mask->drawImage ($draw);
$mask->blurImage (050);
$mask->contrastStretchImage (10125000);
$mask->writeImage ("mask.png");
?>

The result will be a vignette mask with the pixels in the corner being pure black, and the ones in the middle pure white (which is not the case if the line is commented out). Reducing the white value to, say, 100, turns most of the grey pixels white.
2014-02-21 20:47:17
http://php5.kiev.ua/manual/ru/imagick.contraststretchimage.html
Автор:
The black and white points refer to the absolute number of pixels. In the following example a coloured image is first desaturated (turned into a grey scale image) and then the darkest 90% of pixels are turned black, the brightest 5% are made white, and those between 90% and 95% are grey-scaled:

<?php
$im 
= new Imagick ("some_image.jpg");
list (
$width$height) = array_values ($im->getImageGeometry ());
$im->modulateImage (1000100);
$im->contrastStretchImage ($width $height 0.90$width $height 0.95);
$im->writeImage ("temp.jpg");
echo 
"<img src=\"temp.jpg\">";
?>
2014-06-11 13:22:00
http://php5.kiev.ua/manual/ru/imagick.contraststretchimage.html

    Поддержать сайт на родительском проекте КГБ