Skip to content

absdiff

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

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

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

Calculates the per-element absolute difference between two arrays or between an array and a scalar.

The function cv::absdiff calculates: Absolute difference between two arrays when they have the same size and type:

\texttt{dst}(I) =  \texttt{saturate} (| \texttt{src1}(I) -  \texttt{src2}(I)|)

Absolute difference between an array and a scalar when the second array is constructed from Scalar or has as many elements as the number of channels in src1:

\texttt{dst}(I) =  \texttt{saturate} (| \texttt{src1}(I) -  \texttt{src2} |)

Absolute difference between a scalar and an array when the first array is constructed from Scalar or has as many elements as the number of channels in src2:

\texttt{dst}(I) =  \texttt{saturate} (| \texttt{src1} -  \texttt{src2}(I) |)
where I is a multi-dimensional index of array elements. In case of
multi-channel arrays, each channel is processed independently.

Note: Saturation is not applied when the arrays have the depth CV_32S. You may even get a negative value in the case of overflow.

Note: (Python) Be careful to difference behaviour between src1/src2 are single number and they are tuple/array. absdiff(src,X) means absdiff(src,(X,X,X,X)). absdiff(src,(X,)) means absdiff(src,(X,0,0,0)).

See: cv::abs(const Mat&)

absdiff(src1: Mat, src2: Mat, dst: Mat): void;
src1

first input array or a scalar.

src2

second input array or a scalar.

dst

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

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.