Analyses the image and identifies units that are similar. Available since 6.4.5

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.


Image
Cluster threshold
Smooth threshold
Color space
Analyses the image and identifies units that are similar. Available since 6.4.5

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.

Parameters
COLORSPACEintOne of the COLORSPACE constants.
cluster_thresholdfloatA percentage describing minimum number of pixels contained in hexedra before it is considered valid.
smooth_thresholdfloatEliminates noise from the histogram.
verboseboolWhether to output detailed information about recognised classes.
function segmentImage($imagePath, $colorSpace, $clusterThreshold, $smoothThreshold)
{
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->segmentImage($colorSpace, $clusterThreshold, $smoothThreshold);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}