Skip to content

inRange

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

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

Checks if array elements lie between the elements of two other arrays.

The function checks the range as follows:

  • For every element of a single-channel input array:
\texttt{dst} (I)= \texttt{lowerb} (I)_0  \leq \texttt{src} (I)_0 \leq  \texttt{upperb} (I)_0
  • For two-channel arrays:
\texttt{dst} (I)= \texttt{lowerb} (I)_0  \leq \texttt{src} (I)_0 \leq  \texttt{upperb} (I)_0  \land \texttt{lowerb} (I)_1  \leq \texttt{src} (I)_1 \leq  \texttt{upperb} (I)_1
  • and so forth.

That is, dst (I) is set to 255 (all 1 -bits) if src (I) is within the specified 1D, 2D, 3D, ... box and 0 otherwise.

When the lower and/or upper boundary parameters are scalars, the indexes (I) at lowerb and upperb in the above formulas should be omitted.

inRange(src: Mat, lowerb: Mat, upperb: Mat, dst: Mat): void;
src

first input array.

lowerb

inclusive lower boundary array or a scalar.

upperb

inclusive upper boundary array or a scalar.

dst

Output destination, filled by the native operation. output array of the same size as src and CV_8U type.

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.