Skip to content

compare

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

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

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

Performs the per-element comparison of two arrays or an array and scalar value.

The function compares: Elements of two arrays when src1 and src2 have the same size:

\texttt{dst} (I) =  \texttt{src1} (I)  \,\texttt{cmpop}\, \texttt{src2} (I)

Elements of src1 with a scalar src2 when src2 is constructed from Scalar or has a single element:

\texttt{dst} (I) =  \texttt{src1}(I) \,\texttt{cmpop}\,  \texttt{src2}

src1 with elements of src2 when src1 is constructed from Scalar or has a single element:

\texttt{dst} (I) =  \texttt{src1}  \,\texttt{cmpop}\, \texttt{src2} (I)

When the comparison result is true, the corresponding element of output array is set to 255. The comparison operations can be replaced with the equivalent matrix expressions:

    Mat dst1 = src1 >= src2;
    Mat dst2 = src1 < 8;
    ...

See: checkRange, min, max, threshold

compare(src1: Mat, src2: Mat, dst: Mat, cmpop: number): void;
src1

first input array or a scalar; when it is an array, it must have a single channel.

src2

second input array or a scalar; when it is an array, it must have a single channel.

dst

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

cmpop

a flag, that specifies correspondence between the arrays (cv::CmpTypes)

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.