(PECL imagick 2, PECL imagick 3)
Imagick::adaptiveThresholdImage — 根據強度範圍為每個像素選擇閾值
根據像素局部鄰域的強度值範圍,為每個像素選擇個別的閾值。這允許對全局強度直方圖不包含明顯峰值的影像進行閾值處理。
width(寬度)
局部鄰域的寬度。
height(高度)
局部鄰域的高度。
offset(偏移量)
平均偏移量
成功時回傳 true
。
範例 #1 Imagick::adaptiveThresholdImage()
<?php
function adaptiveThresholdImage($imagePath, $width, $height, $adaptiveOffset) {
$imagick = new \Imagick(realpath($imagePath));
$adaptiveOffsetQuantum = intval($adaptiveOffset * \Imagick::getQuantum());
$imagick->adaptiveThresholdImage($width, $height, $adaptiveOffsetQuantum);
header("Content-Type: image/jpg");
echo $imagick->getImageBlob();
}
?>