Method NiblackThreshold
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
NiblackThreshold(InputArray, OutputArray, double, ThresholdTypes, int, double, LocalBinarizationMethods, double)
Applies Niblack thresholding to input image.
public static void NiblackThreshold(InputArray src, OutputArray dst, double maxValue, ThresholdTypes type, int blockSize, double k, LocalBinarizationMethods binarizationMethod = LocalBinarizationMethods.Niblack, double r = 128)
Parameters
srcInputArraySource 8-bit single-channel image.
dstOutputArrayDestination image of the same size and the same type as src.
maxValuedoubleNon-zero value assigned to the pixels for which the condition is satisfied, used with the THRESH_BINARY and THRESH_BINARY_INV thresholding types.
typeThresholdTypesThresholding type, see cv::ThresholdTypes.
blockSizeintSize of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.
kdoubleThe user-adjustable parameter used by Niblack and inspired techniques.For Niblack, this is normally a value between 0 and 1 that is multiplied with the standard deviation and subtracted from the mean.
binarizationMethodLocalBinarizationMethodsBinarization method to use. By default, Niblack's technique is used. Other techniques can be specified, see cv::ximgproc::LocalBinarizationMethods.
rdoubleThe user-adjustable parameter used by Sauvola's technique. This is the dynamic range of standard deviation.
Remarks
The function transforms a grayscale image to a binary image according to the formulae:
- THRESH_BINARY \f[dst(x, y) = \fork{\texttt{maxValue } }{if (src(x, y) > T(x, y))}{0}{otherwise}\f]
- ** THRESH_BINARY_INV** \f[dst(x, y) = \fork{0}{if (src(x, y) > T(x, y))}{\texttt{maxValue}}{otherwise}\f] where \f$T(x, y)\f$ is a threshold calculated individually for each pixel. The threshold value \f$T(x, y)\f$ is the mean minus \f$ delta \f$ times standard deviation of \f$\texttt{blockSize} \times\texttt{blockSize}\f$ neighborhood of \f$(x, y)\f$. The function can't process the image in-place.