Table of Contents

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

src InputArray

Source 8-bit single-channel image.

dst OutputArray

Destination image of the same size and the same type as src.

maxValue double

Non-zero value assigned to the pixels for which the condition is satisfied, used with the THRESH_BINARY and THRESH_BINARY_INV thresholding types.

type ThresholdTypes

Thresholding type, see cv::ThresholdTypes.

blockSize int

Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.

k double

The 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.

binarizationMethod LocalBinarizationMethods

Binarization method to use. By default, Niblack's technique is used. Other techniques can be specified, see cv::ximgproc::LocalBinarizationMethods.

r double

The 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.