Thresholding is a non-linear operation that converts a gray-scale image into a binary image where the two levels are assigned to pixels that are below or above the specified threshold value. You can apply a threshold to data directly from the command line, e.g.,
myBinaryImage = myGrayImage > thresholdValue ? 255 : 0
It is however far more efficient to use the ImageThreshold operation which also provides several methods for finding the "optimal" threshold value for a given image. ImageThreshold provides the following methods for determining the threshold value:
- Automatically calculate a threshold value using an iterative method.
- Approximate the histogram of the image as a bimodal distribution and choose a mid point value as the threshold level.
- Adaptive thresholding. Evaluate the threshold based on the last 8 pixels in each row, using alternating rows. Note that this method is not supported when used as part of the operation ImageEdgeDetection.
- Fuzzy thresholding using entropy as the measure for "fuzziness".
- Fuzzy thresholding using a method that minimizes a "fuzziness" measure involving the mean gray level in the object and background.
- Determines an ideal threshold by histograming the data and representing the image as a set of clusters that is iteratively reduced until there are two clusters left. The threshold value is then set to the highest level of the lower cluster. This method is based on a paper by A.Z. Arifin and A. Asano but modified for handling images with relatively flat histograms.
- Determines the ideal threshold value by maximizing the total variance between the "object" and "background".
- Default method where you must use the /T flag to specify a threshold value.