The whiteThreshold() function is an inbuilt function in the GraphicsMagick library which is used to force all pixels above the threshold into white while leaving all pixels below the threshold unchanged. The function returns the true value on success.
Syntax:
whiteThreshold( intensity )
whiteThreshold( red, green, blue, opacity )
Parameters: This function accepts parameters in two fashion which are mentioned above and described below:
- intensity/red: If only single parameter is mentioned, then this parameter is taken as intensity by the function otherwise it is taken as red intensity.
- green: This parameter is used to specify the green intensity.
- blue: This parameter is used to specify the blue intensity.
- opacity: This parameter is used to specify the opacity intensity.
Return Value: This function returns the GraphicsMagick object.
Original Image
Example 1: Passing only single parameter which is taken as intensity value.
// Include gm library var gm = require( 'gm' ); // Import the image // Invoke whiteThreshold function with 0.2 value .whiteThreshold(.2) // Process and Write the image .write( "whiteThreshold1.png" , function (err) { if (!err) console.log( 'done' ); }); |
Output:
Example 2: Mentioning red, blue, green intensity.
// Include gm library var gm = require( 'gm' ); // Import the image // Invoke whiteThreshold function // with .0001, 0.00001, 12, 0.11 .whiteThreshold(.0001, 0.00001, 12, 0.11) // Process and Write the image .write( "whiteThreshold2.png" , function (err) { if (!err) console.log( 'done' ); }); |
Output:
Reference: