Selects an individual threshold for each pixel based on the range of intensity values in its local neighborhood. This allows for thresholding of an image whose global intensity histogram doesn't contain distinctive peaks.
Touch/mouse over to see original View modified in new window.
Width
Height
Image
Offset
Selects an individual threshold for each pixel based on the range of intensity values in its local neighborhood. This allows for thresholding of an image whose global intensity histogram doesn't contain distinctive peaks.
Parameters
widthintWidth of the local neighborhood.
heightintHeight of the local neighborhood.
offsetintThe mean offset
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();
}