Skip to content

ximgproc_niBlackThreshold

Extended image processingfunctionOpenCV 5.0.0
import { ximgproc_niBlackThreshold } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTS_src, _dst, maxValue, type_
FUNCTIONximgproc_niBlackThreshold
RETURN TYPEvoid
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Performs thresholding on input images using Niblack's technique or some of the popular variations it inspired.

The function transforms a grayscale image to a binary image according to the formulae:

  • THRESH_BINARY
dst(x,y) =  \fork{\texttt{maxValue}}{if \(src(x,y) > T(x,y)\)}{0}{otherwise}
  • THRESH_BINARY_INV
dst(x,y) =  \fork{0}{if \(src(x,y) > T(x,y)\)}{\texttt{maxValue}}{otherwise}

where T(x,y) is a 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 \texttt{blockSize} \times\texttt{blockSize} neighborhood of (x, y).

The function can't process the image in-place.

See: threshold, adaptiveThreshold

ximgproc_niBlackThreshold(_src: Mat, _dst: Mat, maxValue: number, type_: number, blockSize: number, k: number, binarizationMethod: number, r: number): void;
3 available overloads
ximgproc_niBlackThreshold(_src: Mat, _dst: Mat, maxValue: number, type_: number, blockSize: number, k: number): void;
ximgproc_niBlackThreshold(_src: Mat, _dst: Mat, maxValue: number, type_: number, blockSize: number, k: number, binarizationMethod: number): void;
ximgproc_niBlackThreshold(_src: Mat, _dst: Mat, maxValue: number, type_: number, blockSize: number, k: number, binarizationMethod: number, r: number): void;
_src

Source 8-bit single-channel image.

_dst

Output destination, filled by the native operation. Destination image of the same size and the same type as src.

maxValue

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_

Thresholding type, see cv::ThresholdTypes.

blockSize

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

k

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

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

r

The user-adjustable parameter used by Sauvola's technique. This is the dynamic range of standard deviation.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.