Changes the value of individual pixels based on the intensity of each pixel compared to threshold. The result is a high-contrast, two color image.
Convert an image into a black and white image with all pixels above the threshold converted to white, those below to black.
Touch/mouse over to see original View modified in new window.
Image
Threshold
Channel
Changes the value of individual pixels based on the intensity of each pixel compared to threshold. The result is a high-contrast, two color image.
Parameters
thresholdfloat
channelint
function thresholdimage($imagePath, $threshold, $channel)
{
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->thresholdimage($threshold * \Imagick::getQuantum(), $channel);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}