per_element_operations.rst 14.3 KB

Per-element Operations

gpu::add

Computes a matrix-matrix or matrix-scalar sum.

gpu::subtract

Computes a matrix-matrix or matrix-scalar difference.

gpu::multiply

Computes a matrix-matrix or matrix-scalar per-element product.

gpu::divide

Computes a matrix-matrix or matrix-scalar division.

This function, in contrast to :ocv:func:`divide`, uses a round-down rounding mode.

gpu::addWeighted

Computes 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.

gpu::abs

Computes an absolute value of each matrix element.

gpu::sqr

Computes a square value of each matrix element.

gpu::sqrt

Computes a square root of each matrix element.

gpu::exp

Computes an exponent of each matrix element.

gpu::log

Computes a natural logarithm of absolute value of each matrix element.

gpu::pow

Raises every matrix element to a power.

The function pow raises every element of the input matrix to p :

\texttt{dst} (I) =  \fork{\texttt{src}(I)^p}{if \texttt{p} is integer}{|\texttt{src}(I)|^p}{otherwise}

gpu::absdiff

Computes per-element absolute difference of two matrices (or of a matrix and scalar).

gpu::compare

Compares elements of two matrices.

gpu::bitwise_not

Performs a per-element bitwise inversion.

gpu::bitwise_or

Performs a per-element bitwise disjunction of two matrices or of matrix and scalar.

gpu::bitwise_and

Performs a per-element bitwise conjunction of two matrices or of matrix and scalar.

gpu::bitwise_xor

Performs a per-element bitwise exclusive or operation of two matrices of matrix and scalar.

gpu::rshift

Performs pixel by pixel right shift of an image by a constant value.

gpu::lshift

Performs pixel by pixel right left of an image by a constant value.

gpu::min

Computes the per-element minimum of two matrices (or a matrix and a scalar).

gpu::max

Computes the per-element maximum of two matrices (or a matrix and a scalar).