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 (100, 0, 100);
$im->contrastStretchImage ($width * $height * 0.90, $width * $height * 0.95);
$im->writeImage ("temp.jpg");
echo "<img src=\"temp.jpg\">";
?>Imagick::contrastStretchImage
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
Imagick::contrastStretchImage
Референца за `imagick.contraststretchimage.php` со подобрена типографија и навигација.
Imagick::contrastStretchImage
(PECL imagick 2, PECL imagick 3)
Imagick::contrastStretchImage — Го подобрува контрастот на обоена слика
= NULL
$black_point, float $white_point, int $channel од Imagick 3.4.4. Силно се обесхрабрува потпирањето на оваа функција.): boolEnhances the contrast of a color image by adjusting the pixels color to span the entire range of colors available. This method is available if Imagick has been compiled against ImageMagick version 6.2.9 or newer.
Параметри
black_point-
Црната точка.
white_point-
Го подобрува контрастот на обоена слика со прилагодување на бојата на пикселите за да го покрие целиот опсег на достапни бои. Овој метод е достапен ако Imagick е компајлиран со верзија 6.2.9 или понова на ImageMagick.
channel-
Белата точка.
Imagick::CHANNEL_ALLсо бинарни оператори. Стандардно е Обезбедете каква било константа на каналот што е валидна за вашиот режим на канал. За да се примени на повеќе од еден канал, комбинирајте ги константите на типот на каналот користејќи бинарни оператори. Погледнете ја оваа листа на.
Вратени вредности
Патеката до PHP скриптата што треба да се провери. true на успешен исход.
Белешки од корисници 2 забелешки
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 * 5 / 12, $height * 5 / 12, 0, 360);
$mask->drawImage ($draw);
$mask->blurImage (0, 50);
$mask->contrastStretchImage (10, 125000);
$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.