countNonZero
import { countNonZero } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Counts non-zero array elements.
The function returns the number of non-zero elements in src :
\sum _{I: \; \texttt{src} (I) \ne0 } 1
The function do not work with multi-channel arrays. If you need to count non-zero array elements across all the channels, use Mat::reshape first to reinterpret the array as single-channel. Or you may extract the particular channel using either extractImageCOI, or mixChannels, or split.
Note: - CV_16F/CV_16BF/CV_Bool/CV_64U/CV_64S/CV_32U are not supported for src.
- If only whether there are non-zero elements is important,
hasNonZerois helpful. - If the location of non-zero array elements is important,
findNonZerois helpful.
See: mean, meanStdDev, norm, minMaxLoc, calcCovarMatrix See: findNonZero, hasNonZero
countNonZero(src: Mat): number;srcsingle-channel array.
The number result.
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.