Imagick::thresholdImage

(PECL imagick 2, PECL imagick 3)

Imagick::thresholdImage閾値にもとづいて個々のピクセルの値を変更する

説明

public Imagick::thresholdImage(float $threshold, int $channel = Imagick::CHANNEL_DEFAULT): bool

個々のピクセルの輝度を閾値と比較し、その色を変更します。 変換結果は、コントラストの高い 2 色の画像となります。

パラメータ

threshold

channel

戻り値

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

例1 Imagick::thresholdImage()

<?php
function thresholdimage($imagePath, $threshold, $channel) {
$imagick = new \Imagick(realpath($imagePath));
$imagick->thresholdimage($threshold * \Imagick::getQuantum(), $channel);
header("Content-Type: image/jpg");
echo
$imagick->getImageBlob();
}

?>

add a note

User Contributed Notes 1 note

up
1
php t traction dot de
11 years ago
getQuantumRange() can be handy here:

<?php
$i
= new Imagick($imageFile);
$max = $i->getQuantumRange();
$max = $max["quantumRangeLong"];
$i->thresholdImage(0.77 * $max);
?>
To Top