Binarizes a gray image using adaptive thresholding
y = adapthresh(x)
y = adapthresh(x,fsize)
y = adapthresh(x,fsize,t)
y = adapthresh(x,fsize,t,ftype)
y = adapthresh(x,fsize,t,ftype,tmode)
A matrix representing a gray image.
A scalar value representing the size of square sized filter used to smooth the given gray image.
A scalar value representing the threshold value for binarization.
A character constant which indicates the type of smoothing filters to use.
A character constant which indicates the modes of the thresholding to be used for binarization.
A binary matrix representing the binarized image.
It binarizes a gray level image using adaptive thresholding method. If only the gray level is used as input, the filter size is taken as 1/20 of the width of the image, threshold is taken as 15, filter type as 'g' for gaussian and thresholding mode as 'r' for reflective. The other options for filter type ftype are 'm' for median and 'c' for convolution filter. Also, the thresholding mode tmode can take 'f' for fix thresholding.
// reading an image and converting it to gray x=imread('lena.png'); x=rgb2gray(x); x=double(x); // Binarizing the gray image using adapthresh // with default parameters bx=adapthresh(x); // Displaying the binary image imshow(bx) // Binarizing the gray image using adapthresh // with convolution filter at threshold 10 bx1=adapthresh(x,0,10,'c'); // Displaying the binary image imshow(bx1) | ![]() | ![]() |
Reference: Pierre Wellner, "Adaptive Thresholding for the DigitalDesk" Rank Xerox Technical Report EPC-1993-110 1993