Skip to content

convertScaleAbs

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

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

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

Scales, calculates absolute values, and converts the result to 8-bit.

On each element of the input array, the function convertScaleAbs performs three operations sequentially: scaling, taking an absolute value, conversion to an unsigned 8-bit type:

\texttt{dst} (I)= \texttt{saturate\_cast<uchar>} (| \texttt{src} (I)* \texttt{alpha} +  \texttt{beta} |)

In case of multi-channel arrays, the function processes each channel independently. When the output is not 8-bit, the operation can be emulated by calling the Mat::convertTo method (or by using matrix expressions) and then by calculating an absolute value of the result. For example:

    Mat_<float> A(30,30);
    randu(A, Scalar(-100), Scalar(100));
    Mat_<float> B = A*5 + 3;
    B = abs(B);
    // Mat_<float> B = abs(A*5+3) will also do the job,
    // but it will allocate a temporary matrix

See: Mat::convertTo, cv::abs(const Mat&)

convertScaleAbs(src: Mat, dst: Mat, alpha: number, beta: number): void;
3 available overloads
convertScaleAbs(src: Mat, dst: Mat): void;
convertScaleAbs(src: Mat, dst: Mat, alpha: number): void;
convertScaleAbs(src: Mat, dst: Mat, alpha: number, beta: number): void;
src

input array.

dst

Output destination, filled by the native operation. output array.

alpha

optional scale factor.

beta

optional delta added to the scaled values.

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.