Skip to content

addWeighted

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

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

ARGUMENTSsrc1, alpha, src2, beta
FUNCTIONaddWeighted
RETURN TYPEvoid
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Calculates the weighted sum of two arrays.

The function addWeighted calculates the weighted sum of two arrays as follows:

\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} +  \texttt{src2} (I)* \texttt{beta} +  \texttt{gamma} )

where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each channel is processed independently. The function can be replaced with a matrix expression:

    dst = src1*alpha + src2*beta + gamma;

Note: Saturation is not applied when the output array has the depth CV_32S. You may even get result of an incorrect sign in the case of overflow.

See: add, subtract, scaleAdd, Mat::convertTo

addWeighted(src1: Mat, alpha: number, src2: Mat, beta: number, gamma: number, dst: Mat, dtype: number): void;
2 available overloads
addWeighted(src1: Mat, alpha: number, src2: Mat, beta: number, gamma: number, dst: Mat): void;
addWeighted(src1: Mat, alpha: number, src2: Mat, beta: number, gamma: number, dst: Mat, dtype: number): void;
src1

first input array.

alpha

weight of the first array elements.

src2

second input array of the same size and channel number as src1.

beta

weight of the second array elements.

gamma

scalar added to each sum.

dst

Output destination, filled by the native operation. output array that has the same size and number of channels as the input arrays.

dtype

optional depth of the output array; when both input arrays have the same depth, dtype can be set to -1, which will be equivalent to src1.depth().

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.