image = | adaptiveThreshold2dImg (inImg,inKnlXY) |
image = | adaptiveThresholdGaussian2dImg (inImg,halfKnlSize) |
Binarize an input image according an adaptive threshold based on the pixel's neighbourhood.
For each pixel, the algorithm computes a threshold according to a neighbourhood described by the input kernel size as follows :
Where is the pixel's neighbourhood.
For example, the threshold can be the mean intensity in the neighbourhood with each kernel coefficients set to , with
being the number of pixels in the neighbourhood.
It is also possible to call the adaptiveThresholdGaussian2dImg wrapper, which needs the half kernel size instead of the kernel as input data. In this case, a predifined Gaussian kernel is used, whose coefficients are computed with the folowing standard deviation (see http://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html#Mat%20getGaussianKernel%28int%20ksize,%20double%20sigma,%20int%20ktype%29) :
Where is the kernel size :
.
Here is an example of an adaptive image thresholding applied to a 8-bits grey level image, with a Gaussian kernel with a size of 5 :