Skip to content

mean

Core and matricesfunctionOpenCV 5.0.0
import { mean } from '@banou/opencv-wasm'

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

ARGUMENTSsrc, mask
FUNCTIONmean
RETURN TYPEScalar
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Calculates an average (mean) of array elements.

The function cv::mean calculates the mean value M of array elements, independently for each channel, and return it:

\begin{array}{l} N =  \sum _{I: \; \texttt{mask} (I) \ne 0} 1 \\ M_c =  \left ( \sum _{I: \; \texttt{mask} (I) \ne 0}{ \texttt{mtx} (I)_c} \right )/N \end{array}

When all the mask elements are 0's, the function returns Scalar::all(0)

See: countNonZero, meanStdDev, norm, minMaxLoc

mean(src: Mat, mask: Mat): Scalar;
2 available overloads
mean(src: Mat): Scalar;
mean(src: Mat, mask: Mat): Scalar;
src

input array that should have from 1 to 4 channels so that the result can be stored in Scalar_ .

mask

optional operation mask ot type CV_8U, CV_8S or CV_Bool.

Returns

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