adaptiveThreshold
import { adaptiveThreshold } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Applies an adaptive threshold to an array.
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 (see adaptiveMethod parameter).
The function can process the image in-place.
See: threshold, blur, GaussianBlur
adaptiveThreshold(src: Mat, dst: Mat, maxValue: number, adaptiveMethod: number, thresholdType: number, blockSize: number, C: number): void;srcSource 8-bit single-channel image.
dstOutput destination, filled by the native operation. Destination image of the same size and the same type as src.
maxValueNon-zero value assigned to the pixels for which the condition is satisfied
adaptiveMethodAdaptive thresholding algorithm to use, see #AdaptiveThresholdTypes. The #BORDER_REPLICATE | #BORDER_ISOLATED is used to process boundaries.
thresholdTypeThresholding type that must be either #THRESH_BINARY or #THRESH_BINARY_INV, see #ThresholdTypes.
blockSizeSize of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.
CConstant subtracted from the mean or weighted mean (see the details below). Normally, it is positive but may be zero or negative as well.
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.