Node.js GM segment() Function
Last Updated :
31 Mar, 2023
The segment() function is an inbuilt function in the GraphicsMagick library which is used to segment an image by analyzing the histograms of the color components and identifying units that are homogeneous with the fuzzy c-means technique. The function returns the true value on success.
Syntax:
threshold( cluster threshold, smoothing threshold )
Parameters: This function accepts two parameters as mentioned above and described below:
- cluster threshold: This parameter is used to specify the value of the cluster threshold.
- smoothing threshold: This parameter is used to specify the value of the smoothing threshold.
Return Value: This function returns the GraphicsMagick object.
Example 1:
Javascript
const gm = require( 'gm' );
gm(600, 300, 'white' )
.stroke( "green" , 3)
.font( "Helvetica.ttf" , 60)
.drawText(100, 280, "GeeksforGeeks!" )
.segment(1, 0.1)
.write( "segment1.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Example 2:
Javascript
const gm = require( 'gm' );
gm( '1.png' )
.segment(2, 0.2)
.write( "segment1.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Reference:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...