Functions > Image Processing > Image Manipulation > Binarization
  
Binarization
binarize(M, [lowThresh, [highThresh, inValue, outValue]])—Returns a binarized version of matrix M with pixels below, or equal to, lowThresh are set to 0 and those above threshold lowThresh set to 1.
Binarization produces an image with only two levels of grey, and can be used for enhancing features of an image by choosing the appropriate threshold. Binarization can also be a first step in image analysis.
Arguments
M is an image matrix.
lowThresh, highThresh, inValue, outValue (optional) are real numbers.
Additional Information
If none of the optional arguments is supplied, then a threshold is automatically set, assuming a bimodal distribution of "foreground" and "background" pixels. The algorithm uses a criterion due to Kittler and Illingworth that minimizes the fit between the actual pixel histogram and the assumed bimodal distribution (see R. M. Harlick and L. G. Shapiro, Computer and Robot Vision, Vol. 1, Addison-Wesley, 1992).
If only lowThresh is supplied, then it is used as a threshold for setting the elements of the output matrix to 0 or 1.
Supplying highThresh requires the supply of inValue and outValue.
If all four optional arguments are supplied, then all levels between lowThresh and highThresh are set to inValue, and all others are set to outValue. The values for the input parameters are arbitrary and do not have to be between 0 and 255. inValue and outValue may be the same, in which case the entire image is set to one level only.