Function File: [level, sep] = graythresh (img)
Function File: [level, sep] = graythresh (img, method, options)
Function File: [level, sep] = graythresh (hist, …)

Compute global image threshold.

Given an image img finds the optimal threshold value level for conversion to a binary image with im2bw. Color images are converted to grayscale before level is computed. An image histogram hist can also be used to allow for preprocessing of the histogram.

The optional argument method is the algorithm to be used (default’s to Otsu). Some methods may have other options and/or return an extra value sep (see each entry for details). The available methods are:

Otsu (default)

Implements Otsu’s method as described in Nobuyuki Otsu (1979). "A threshold selection method from gray-level histograms", IEEE Trans. Sys., Man., Cyber. 9 (1): 62-66. This algorithm chooses the threshold to minimize the intraclass variance of the black and white pixels.

The second output, sep represents the “goodness” (or separability) of the threshold at level. It is a value within the range [0 1], the lower bound (zero) being attainable by, and only by, histograms having a single constant gray level, and the upper bound being attainable by, and only by, two-valued pictures.

concavity

Find a global threshold for a grayscale image by choosing the threshold to be in the shoulder of the histogram A. Rosenfeld, and P. De La Torre (1983). "Histogram concavity analysis as an aid in threshold selection", IEEE Transactions on Systems, Man, and Cybernetics, 13: 231-235.

intermodes

This assumes a bimodal histogram and chooses the threshold to be the mean of the two peaks of the bimodal histogram J. M. S. Prewitt, and M. L. Mendelsohn (1966). "The analysis of cell images", Annals of the New York Academy of Sciences, 128: 1035-1053.

Images with histograms having extremely unequal peaks or a broad and flat valley are unsuitable for this method.

intermeans

Iterative procedure based on the iterative intermeans algorithm of T. Ridler, and S. Calvard (1978). "Picture thresholding using an iterative selection method", IEEE Transactions on Systems, Man, and Cybernetics, 8: 630-632 and H. J. Trussell (1979). "Comments on ’Picture thresholding using an iterative selection method’", IEEE Transactions on Systems, Man, and Cybernetics, 9: 311.

Note that several implementations of this method exist. See the source code for details.

MaxEntropy

Implements Kapur-Sahoo-Wong (Maximum Entropy) thresholding method based on the entropy of the image histogram J. N. Kapur, P. K. Sahoo, and A. C. K. Wong (1985). "A new method for gray-level picture thresholding using the entropy of the histogram", Graphical Models and Image Processing, 29(3): 273-285.

MaxLikelihood

Find a global threshold for a grayscale image using the maximum likelihood via expectation maximization method A. P. Dempster, N. M. Laird, and D. B. Rubin (1977). "Maximum likelihood from incomplete data via the EM algorithm", Journal of the Royal Statistical Society, Series B, 39:1-38.

mean

The mean intensity value. It is mostly used by other methods as a first guess threshold.

MinError

An iterative implementation of Kittler and Illingworth’s Minimum Error thresholding J. Kittler, and J. Illingworth (1986). "Minimum error thresholding", Pattern recognition, 19: 41-47.

This implementation seems to converge more often than the original. Nevertheless, sometimes the algorithm does not converge to a solution. In that case a warning is displayed and defaults to the initial estimate of the mean method.

minimum

This assumes a bimodal histogram and chooses the threshold to be in the valley of the bimodal histogram. This method is also known as the mode method J. M. S. Prewitt, and M. L. Mendelsohn (1966). "The analysis of cell images", Annals of the New York Academy of Sciences, 128: 1035-1053.

Images with histograms having extremely unequal peaks or a broad and flat valley are unsuitable for this method.

moments

Find a global threshold for a grayscale image using moment preserving thresholding method W. Tsai (1985). "Moment-preserving thresholding: a new approach", Computer Vision, Graphics, and Image Processing, 29: 377-393

percentile

Assumes a specific fraction of pixels (set at options) to be background. If no value is given, assumes 0.5 (equal distribution of background and foreground) W Doyle (1962). "Operation useful for similarity-invariant pattern recognition", Journal of the Association for Computing Machinery 9: 259-267

See also: im2bw, otsuthresh.

Package: image