Imagick::segmentImage
PHP function
Edit on GitHub ✎
(PECL imagick 2 >= 2.3.0, PECL imagick 3)
Segments an image
Description
Imagick::segmentImage(int $COLORSPACE, float $cluster_threshold, float $smooth_threshold, bool $verbose = false): bool
Analyses the image and identifies units that are similar. 0x645
Parameters
COLORSPACEOne of the COLORSPACE constants.
cluster_thresholdA percentage describing minimum number of pixels contained in hexedra before it is considered valid.
smooth_thresholdEliminates noise from the histogram.
verboseWhether to output detailed information about recognised classes.
Return Values
Examples
php
<?php
function segmentImage($imagePath, $colorSpace, $clusterThreshold, $smoothThreshold) {
$imagick = new \Imagick(realpath($imagePath));
$imagick->segmentImage($colorSpace, $clusterThreshold, $smoothThreshold);
header("Content-Type: image/jpg");
echo $imagick->getImageBlob();
}
segmentImage($imagePath, \Imagick::COLORSPACE_RGB, 5, 5);
?>