FUNCTION REFERENCE
graythresh
Global image threshold by Otsu's method.
Global image threshold by Otsu's method.
Syntax
level = graythresh(I)Syntax
[level, em] = graythresh(I)Computes the 256-bin histogram of I (as imhist does, over the range of its class, all elements of an array of any size) and returns the threshold of Otsu's method (Otsu, 1979) as a fraction of the class range in [0, 1]: the bin boundary that maximises the between-class variance, (k - 1)/255 for the last bin k of the lower class; when several boundaries reach the maximum, their mean is used. em is the effectiveness metric, the maximal between-class variance divided by the total variance of the histogram (1 for an image with exactly two values). An image with a single value gives level = 0 and em = 0. Compare with imbinarize, which applies the level.
Example
level = graythresh(uint8([10 10 10 200 200 200])) % 104.5/255Example
[level, em] = graythresh([0.2 0.2 0.8 0.8]) % em = 1Differences from MATLAB: none known.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.