Threshold - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

ImageTools

 Threshold
 perform threshold operation on a grayscale image

 Calling Sequence Threshold( img, thr, opts )

Parameters

 img - Image; input image thr - (optional) realcons; value of the threshold opts - (optional) equation(s) of the form option = value; specify options for the Threshold command

Options

 • low = float
 Specifies the value that all pixels that fall below the threshold are set to.  The default value is 0.0.
 • high = float
 Specifies the value that all pixels that fall above the threshold are set to.  The default value is 1.0.
 • method = above, below, or both
 Specifies how the threshold operation is performed. Specifying method = above causes all the pixels that fall above the threshold to be set to the value specified by the high option, and the pixels that fall below the threshold retain their value. Specifying method = below causes all the pixels that fall below the threshold to be set to the value specified by the low option, and the pixels that fall above the threshold retain their value. Specifying method = both, which is the default value, causes all the pixels that fall below the threshold to be set to the value specified by the low option, and all the pixels that fall above the threshold to be set to the value specified by the high option.

Description

 • The Threshold command performs a threshold operation on a grayscale image.
 • The img parameter is the input image. It must be of type GrayImage.
 • The optional thr parameter specifies the threshold. If not specified, a threshold is computed using Otsu's method.
 • The effect of the threshold operation can be specified by the method option, by specifying whether to threshold pixels above the threshold, below the threshold, or both.
 • The options high and low specify the new intensity values.

Examples

 > $\mathrm{with}\left(\mathrm{ImageTools}\right):$
 > $\mathrm{img}≔\mathrm{Matrix}\left(200,200,\left(y,x\right)→\left(0.4\mathrm{sin}\left(0.05x\right)+0.5\right)\left(0.4\mathrm{sin}\left(0.1y\right)+0.5\right)+\frac{x}{1000},\mathrm{datatype}={\mathrm{float}}_{8}\right)$
 > $\mathrm{Embed}\left(\mathrm{img}\right)$

 > $\mathrm{img2_b}≔\mathrm{Threshold}\left(\mathrm{img},\mathrm{method}=\mathrm{below}\right)$
 > $\mathrm{img2_a}≔\mathrm{Threshold}\left(\mathrm{img},\mathrm{method}=\mathrm{above}\right)$
 > $\mathrm{img2}≔\mathrm{Threshold}\left(\mathrm{img},\mathrm{method}=\mathrm{both}\right)$
 > $\mathrm{Embed}\left(\left[\mathrm{img2_b},\mathrm{img2_a},\mathrm{img2}\right]\right)$

References

 Otsu, N. "A threshold selection method from gray level histograms." IEEE Trans. Systems, Man and Cybernetics, Vol. 9. (1979).