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