cv.niBlackThreshold - MATLAB File Help |
Performs thresholding on input images using Niblack's technique or some of the popular variations it inspired
dst = cv.niBlackThreshold(src, k)
dst = cv.niBlackThreshold(src, k, 'OptionName',optionValue, ...)
mean + k * std
).src
.Binary
and BinaryInv
thresholding types.
default 255dst(x,y) = (src(x,y) > thresh) ? maxValue : 0
dst(x,y) = (src(x,y) > thresh) ? 0 : maxValue
dst(x,y) = (src(x,y) > thresh) ? thresh : src(x,y)
dst(x,y) = (src(x,y) > thresh) ? src(x,y) : 0
dst(x,y) = (src(x,y) > thresh) ? 0 : src(x,y)
The function transforms a grayscale image to a binary image according to the formulae:
Binary
| maxValue, if src(x,y) > T(x,y)
dst(x,y) = |
| 0, otherwise
BinaryInv
| 0, if src(x,y) > T(x,y)
dst(x,y) = |
| maxValue, otherwise
Trunc
| T(x,y), if src(x,y) > T(x,y)
dst(x,y) = |
| src(x,y), otherwise
ToZero
| src(x,y), if src(x,y) > T(x,y)
dst(x,y) = |
| 0, otherwise
ToZeroInv
| 0, if src(x,y) > T(x,y)
dst(x,y) = |
| src(x,y), otherwise
where T(x,y)
is a local threshold calculated individually for each pixel.
The threshold value T(x,y)
is determined based on the binarization method
chosen. For classic Niblack, it is the mean minus k
times standard
deviation of BlockSize x BlockSize
neighborhood of (x,y)
.
[Niblack1985]:
Wayne Niblack. "An introduction to digital image processing". Strandberg Publishing Company, 1985.
[Sauvola1997]:
Jaakko Sauvola, Tapio Seppanen, Sami Haapakoski, and Matti Pietikainen. "Adaptive document binarization". In Document Analysis and Recognition, Proceedings of the Fourth International Conference on, volume 1, pages 147-152. IEEE, 1997.
[Wolf2004]:
Christian Wolf and J-M Jolion. "Extraction and recognition of artificial text in multimedia documents". Pattern Analysis & Applications, 6(4):309-326, 2004.
[Khurshid2009]:
Khurram Khurshid, Imran Siddiqi, Claudie Faure, and Nicole Vincent. "Comparison of niblack inspired binarization methods for ancient documents". In IS&T/SPIE Electronic Imaging, pages 72470U-72470U. International Society for Optics and Photonics, 2009.