Change language

PHP ImagickgmentImage () Function

Syntax:
bool Imagick::segmentImage (int $COLORSPACE, float  $cluster_threshold, float $smooth_threshold, bool $verbose = FALSE)
Parameters:This function takes four parameters, as above and described below:
  • $COLORSPACE:specifies an integer value that matches one of the COLORSPACEconstants. You can also pass in direct constants such as imagick::COLORSPACE_RGB.
  • $cluster_threshold:specifies a percentage that describes the minimum number of pixels contained in hexedra before it is considered valid.
  • $smooth_threshold:specifies whether to remove noise from the histogram.
  • $verbose (Optional):specifies whether to display detailed information about the recognized classes. The default is false
A list of all COLORSPACE constants is given below:
  • imagick::COLORSPACE_UNDEFINED (0)
  • imagick::COLORSPACE_RGB (1)
  • imagick::COLORSPACE_GRAY (2)
  • imagick::COLORSPACE_TRANSPARENT (3)
  • imagick::COLORSPACE_OHTA (4)
  • imagick::COLORSPACE_LAB (5)
  • imagick::COLORSPACE_XYZ (6)
  • imagick::COLORSPACE_YCBCR (7)
  • imagick::COLORSPACE_YCC ( 8)
  • imagick::COLORSPACE_YIQ (9)
  • imagick::COLORSPACE_YPBPR (10)
  • imagick::COLORSPACE_YUV (11)
  • imagick::COLORSPACE_CMYK (12)
  • imagick::COLORSPACE_SRGB (13)
  • imagick::COLORSPACE_HSB (14)
  • imagick::COLORSPACE_HSL (15)
  • imagick::COLORSPACE_HWB (16)
  • imagick::COLORSPACE_REC601LUMA (17)
  • imagick::COLORSPACE_REC709LUMA (19)
  • imagick::COLORSPACE_LOG (21)
  • imagick::COLORSPACE_CMY (22)
Return th value:This function returns TRUE on success.Exceptions:This function throws an ImagickException on error.The following programs illustrate the Imagick::gmentImage() functionin PHP:Program 1:  
// Create a new imagick object $imagick = new Imagick ( https://media.engineerforengineer.org/wp-content/uploads/engineerforengineer-13.png );  
// Segment the image with color space as imagick::COLORSPACE_RGB $imagick -> segmentImage (1, 0, 12);  
// Show image header ( "Content-Type: image / png" ); echo $imagick -> getImageBlob(); ?>
Output: Program 2:  
// Create new imagick object $imagick = new Imagick ( https://media.engineerforengineer.org/wp-content/uploads/engineerforengineer-13.png );  
// Segment the image with color space as imagick::COLORSPACE_GRAY $imagick -> segmentImage (2, 5, 30);  
// Show image header ( "Content-Type: image / png" ); echo $imagick -> getImageBlob(); ?>
Output: Link: https://www.php.net/manual/en/imagick.segmentimage.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method