HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelDevelopmentTutorial Source codeReport an issue
Category
Example

Imagick::segmentImage

← scaleImage   selectiveBlurImage →
Analyses the image and identifies units that are similar. This method is available if Imagick has been compiled against ImageMagick version 6.4.5 or newer.

This function is quite slow and prone to time out. Large values for the cluster and smooth threshold appear to be faster, and so safer.


Example

function segmentImage($image_path, $colorSpace, $clusterThreshold, $smoothThreshold)
{
    $imagick = new \Imagick(realpath($image_path));
    $imagick->segmentImage($colorSpace, $clusterThreshold, $smoothThreshold);
    header("Content-Type: image/jpeg");
    echo $imagick->getImageBlob();
}