Skip to content

gapi_threshold

gapifunctionOpenCV 5.0.0
import { gapi_threshold } from '@banou/opencv-wasm'

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

ARGUMENTSsrc, thresh, maxval, type_
FUNCTIONgapi_threshold
RETURN TYPEGMat
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Applies a fixed-level threshold to each matrix element.

The function applies fixed-level thresholding to a single- or multiple-channel matrix. The function is typically used to get a bi-level (binary) image out of a grayscale image ( cmp functions could be also used for this purpose) or for removing a noise, that is, filtering out pixels with too small or too large values. There are several types of thresholding supported by the function. They are determined by type parameter.

Also, the special values cv::THRESH_OTSU or cv::THRESH_TRIANGLE may be combined with one of the above values. In these cases, the function determines the optimal threshold value using the Otsu's or Triangle algorithm and uses it instead of the specified thresh . The function returns the computed threshold value in addititon to thresholded matrix. The Otsu's and Triangle methods are implemented only for 8-bit matrices.

Input image should be single channel only in case of cv::THRESH_OTSU or cv::THRESH_TRIANGLE flags. Output matrix must be of the same size and depth as src.

Note: Function textual ID is "org.opencv.core.matrixop.threshold"

See: min, max, cmpGT, cmpLE, cmpGE, cmpLT

gapi_threshold(src: GMat, thresh: GScalar, maxval: GScalar, type_: number): GMat;
src

input matrix (CV_8UC1, CV_8UC3, or CV_32FC1).

thresh

threshold value.

maxval

maximum value to use with the cv::THRESH_BINARY and cv::THRESH_BINARY_INV thresholding types.

type_

thresholding type (see the cv::ThresholdTypes).

Returns

The GMat result. Release returned native handles with using or delete(), including handles nested in results.

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.