Applies an adaptive threshold to an array.
void adaptiveThreshold(InputArray src, OutputArray dst, double maxValue, int adaptiveMethod, int thresholdType, int blockSize, double C)
Parameters:
src – Source 8-bit single-channel image.
dst – Destination image ofthe same size andthe same type as src
maxValue – Non-zero value assigned tothe pixels for which the condition is satisfied. See the details below
adaptiveMethod – Adaptive thresholding algorithm to use, ADAPTIVE_THRESH_MEAN_C or ADAPTIVE_THRESH_GAUSSIAN_C, See the details below.
thresholdType – Thresholding type that must be either THRESH_BINARY or THRESH_BINARY_INV
blockSize – Size of a pixel neighborhood thatis used to calculate a threshold value forthe pixel: 3, 5, 7, and so on
C – Constant subtracted fromthe mean or weighted mean (see the details below). Normally, itis positive but may be zero or negative as well
The function transforms a grayscale image to a binary image according tothe formulae:
where T(x,y)is a threshold calculated individually foreach pixel
For the methodADAPTIVE_THRESH_MEAN_C , thethresholdvalueT(x,y)isameanofthe \texttt{blockSize} \times \texttt{blockSize}neighborhoodof(x, y)minusC .
ADAPTIVE_THRESH_MEAN_C: 计算(x,y)为中心的方块内的均值 - C = (x,y)的值
For the methodADAPTIVE_THRESH_GAUSSIAN_C , thethresholdvalueT(x, y)isaweightedsum(cross-correlation with a Gaussian window)ofthe \texttt{blockSize} \times \texttt{blockSize}neighborhoodof(x, y)minusC . Thedefaultsigma(standard deviation)isusedforthespecifiedblockSize . SeegetGaussianKernel() .
ADAPTIVE_THRESH_GAUSSIAN_C:计算(x,y)为中心的高斯块(方块不同位置权重不一样)内的均值 - C = (x, y)的值