OpenCV  4.1.0
Open Source Computer Vision
Functions
Per-element Operations

Functions

void cv::cuda::abs (InputArray src, OutputArray dst, Stream &stream=Stream::Null())
 Computes an absolute value of each matrix element.
 
void cv::cuda::absdiff (InputArray src1, InputArray src2, OutputArray dst, Stream &stream=Stream::Null())
 Computes per-element absolute difference of two matrices (or of a matrix and scalar).
 
void cv::cuda::add (InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1, Stream &stream=Stream::Null())
 Computes a matrix-matrix or matrix-scalar sum.
 
void cv::cuda::addWeighted (InputArray src1, double alpha, InputArray src2, double beta, double gamma, OutputArray dst, int dtype=-1, Stream &stream=Stream::Null())
 Computes the weighted sum of two arrays.
 
void cv::cuda::bitwise_and (InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray(), Stream &stream=Stream::Null())
 Performs a per-element bitwise conjunction of two matrices (or of matrix and scalar).
 
void cv::cuda::bitwise_not (InputArray src, OutputArray dst, InputArray mask=noArray(), Stream &stream=Stream::Null())
 Performs a per-element bitwise inversion.
 
void cv::cuda::bitwise_or (InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray(), Stream &stream=Stream::Null())
 Performs a per-element bitwise disjunction of two matrices (or of matrix and scalar).
 
void cv::cuda::bitwise_xor (InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray(), Stream &stream=Stream::Null())
 Performs a per-element bitwise exclusive or operation of two matrices (or of matrix and scalar).
 
void cv::cuda::cartToPolar (InputArray x, InputArray y, OutputArray magnitude, OutputArray angle, bool angleInDegrees=false, Stream &stream=Stream::Null())
 Converts Cartesian coordinates into polar.
 
void cv::cuda::compare (InputArray src1, InputArray src2, OutputArray dst, int cmpop, Stream &stream=Stream::Null())
 Compares elements of two matrices (or of a matrix and scalar).
 
void cv::cuda::divide (InputArray src1, InputArray src2, OutputArray dst, double scale=1, int dtype=-1, Stream &stream=Stream::Null())
 Computes a matrix-matrix or matrix-scalar division.
 
void cv::cuda::exp (InputArray src, OutputArray dst, Stream &stream=Stream::Null())
 Computes an exponent of each matrix element.
 
void cv::cuda::log (InputArray src, OutputArray dst, Stream &stream=Stream::Null())
 Computes a natural logarithm of absolute value of each matrix element.
 
void cv::cuda::lshift (InputArray src, Scalar_< int > val, OutputArray dst, Stream &stream=Stream::Null())
 Performs pixel by pixel right left of an image by a constant value.
 
void cv::cuda::magnitude (InputArray xy, OutputArray magnitude, Stream &stream=Stream::Null())
 Computes magnitudes of complex matrix elements.
 
void cv::cuda::magnitude (InputArray x, InputArray y, OutputArray magnitude, Stream &stream=Stream::Null())
 
void cv::cuda::magnitudeSqr (InputArray xy, OutputArray magnitude, Stream &stream=Stream::Null())
 Computes squared magnitudes of complex matrix elements.
 
void cv::cuda::magnitudeSqr (InputArray x, InputArray y, OutputArray magnitude, Stream &stream=Stream::Null())
 
void cv::cuda::max (InputArray src1, InputArray src2, OutputArray dst, Stream &stream=Stream::Null())
 Computes the per-element maximum of two matrices (or a matrix and a scalar).
 
void cv::cuda::min (InputArray src1, InputArray src2, OutputArray dst, Stream &stream=Stream::Null())
 Computes the per-element minimum of two matrices (or a matrix and a scalar).
 
void cv::cuda::multiply (InputArray src1, InputArray src2, OutputArray dst, double scale=1, int dtype=-1, Stream &stream=Stream::Null())
 Computes a matrix-matrix or matrix-scalar per-element product.
 
void cv::cuda::phase (InputArray x, InputArray y, OutputArray angle, bool angleInDegrees=false, Stream &stream=Stream::Null())
 Computes polar angles of complex matrix elements.
 
void cv::cuda::polarToCart (InputArray magnitude, InputArray angle, OutputArray x, OutputArray y, bool angleInDegrees=false, Stream &stream=Stream::Null())
 Converts polar coordinates into Cartesian.
 
void cv::cuda::pow (InputArray src, double power, OutputArray dst, Stream &stream=Stream::Null())
 Raises every matrix element to a power.
 
void cv::cuda::rshift (InputArray src, Scalar_< int > val, OutputArray dst, Stream &stream=Stream::Null())
 Performs pixel by pixel right shift of an image by a constant value.
 
static void cv::cuda::scaleAdd (InputArray src1, double alpha, InputArray src2, OutputArray dst, Stream &stream=Stream::Null())
 adds scaled array to another one (dst = alpha*src1 + src2)
 
void cv::cuda::sqr (InputArray src, OutputArray dst, Stream &stream=Stream::Null())
 Computes a square value of each matrix element.
 
void cv::cuda::sqrt (InputArray src, OutputArray dst, Stream &stream=Stream::Null())
 Computes a square root of each matrix element.
 
void cv::cuda::subtract (InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1, Stream &stream=Stream::Null())
 Computes a matrix-matrix or matrix-scalar difference.
 
double cv::cuda::threshold (InputArray src, OutputArray dst, double thresh, double maxval, int type, Stream &stream=Stream::Null())
 Applies a fixed-level threshold to each array element.
 

Detailed Description

Function Documentation

void cv::cuda::abs ( InputArray  src,
OutputArray  dst,
Stream &  stream = Stream::Null() 
)

Computes an absolute value of each matrix element.

Parameters
srcSource matrix.
dstDestination matrix with the same size and type as src .
streamStream for the asynchronous version.
See Also
abs
void cv::cuda::absdiff ( InputArray  src1,
InputArray  src2,
OutputArray  dst,
Stream &  stream = Stream::Null() 
)

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

Parameters
src1First source matrix or scalar.
src2Second source matrix or scalar.
dstDestination matrix that has the same size and type as the input array(s).
streamStream for the asynchronous version.
See Also
absdiff
void cv::cuda::add ( InputArray  src1,
InputArray  src2,
OutputArray  dst,
InputArray  mask = noArray(),
int  dtype = -1,
Stream &  stream = Stream::Null() 
)

Computes a matrix-matrix or matrix-scalar sum.

Parameters
src1First source matrix or scalar.
src2Second source matrix or scalar. Matrix should have the same size and type as src1 .
dstDestination matrix that has the same size and number of channels as the input array(s). The depth is defined by dtype or src1 depth.
maskOptional operation mask, 8-bit single channel array, that specifies elements of the destination array to be changed. The mask can be used only with single channel images.
dtypeOptional depth of the output array.
streamStream for the asynchronous version.
See Also
add
void cv::cuda::addWeighted ( InputArray  src1,
double  alpha,
InputArray  src2,
double  beta,
double  gamma,
OutputArray  dst,
int  dtype = -1,
Stream &  stream = Stream::Null() 
)

Computes the weighted sum of two arrays.

Parameters
src1First source array.
alphaWeight for the first array elements.
src2Second source array of the same size and channel number as src1 .
betaWeight for the second array elements.
dstDestination array that has the same size and number of channels as the input arrays.
gammaScalar added to each sum.
dtypeOptional depth of the destination array. When both input arrays have the same depth, dtype can be set to -1, which will be equivalent to src1.depth().
streamStream for the asynchronous version.

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.

See Also
addWeighted
void cv::cuda::bitwise_and ( InputArray  src1,
InputArray  src2,
OutputArray  dst,
InputArray  mask = noArray(),
Stream &  stream = Stream::Null() 
)

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

Parameters
src1First source matrix or scalar.
src2Second source matrix or scalar.
dstDestination matrix that has the same size and type as the input array(s).
maskOptional operation mask, 8-bit single channel array, that specifies elements of the destination array to be changed. The mask can be used only with single channel images.
streamStream for the asynchronous version.
void cv::cuda::bitwise_not ( InputArray  src,
OutputArray  dst,
InputArray  mask = noArray(),
Stream &  stream = Stream::Null() 
)

Performs a per-element bitwise inversion.

Parameters
srcSource matrix.
dstDestination matrix with the same size and type as src .
maskOptional operation mask, 8-bit single channel array, that specifies elements of the destination array to be changed. The mask can be used only with single channel images.
streamStream for the asynchronous version.
void cv::cuda::bitwise_or ( InputArray  src1,
InputArray  src2,
OutputArray  dst,
InputArray  mask = noArray(),
Stream &  stream = Stream::Null() 
)

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

Parameters
src1First source matrix or scalar.
src2Second source matrix or scalar.
dstDestination matrix that has the same size and type as the input array(s).
maskOptional operation mask, 8-bit single channel array, that specifies elements of the destination array to be changed. The mask can be used only with single channel images.
streamStream for the asynchronous version.
void cv::cuda::bitwise_xor ( InputArray  src1,
InputArray  src2,
OutputArray  dst,
InputArray  mask = noArray(),
Stream &  stream = Stream::Null() 
)

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

Parameters
src1First source matrix or scalar.
src2Second source matrix or scalar.
dstDestination matrix that has the same size and type as the input array(s).
maskOptional operation mask, 8-bit single channel array, that specifies elements of the destination array to be changed. The mask can be used only with single channel images.
streamStream for the asynchronous version.
void cv::cuda::cartToPolar ( InputArray  x,
InputArray  y,
OutputArray  magnitude,
OutputArray  angle,
bool  angleInDegrees = false,
Stream &  stream = Stream::Null() 
)

Converts Cartesian coordinates into polar.

Parameters
xSource matrix containing real components ( CV_32FC1 ).
ySource matrix containing imaginary components ( CV_32FC1 ).
magnitudeDestination matrix of float magnitudes ( CV_32FC1 ).
angleDestination matrix of angles ( CV_32FC1 ).
angleInDegreesFlag for angles that must be evaluated in degrees.
streamStream for the asynchronous version.
See Also
cartToPolar
void cv::cuda::compare ( InputArray  src1,
InputArray  src2,
OutputArray  dst,
int  cmpop,
Stream &  stream = Stream::Null() 
)

Compares elements of two matrices (or of a matrix and scalar).

Parameters
src1First source matrix or scalar.
src2Second source matrix or scalar.
dstDestination matrix that has the same size as the input array(s) and type CV_8U.
cmpopFlag specifying the relation between the elements to be checked:
  • CMP_EQ: a(.) == b(.)
  • CMP_GT: a(.) > b(.)
  • CMP_GE: a(.) >= b(.)
  • CMP_LT: a(.) < b(.)
  • CMP_LE: a(.) <= b(.)
  • CMP_NE: a(.) != b(.)
streamStream for the asynchronous version.
See Also
compare
void cv::cuda::divide ( InputArray  src1,
InputArray  src2,
OutputArray  dst,
double  scale = 1,
int  dtype = -1,
Stream &  stream = Stream::Null() 
)

Computes a matrix-matrix or matrix-scalar division.

Parameters
src1First source matrix or a scalar.
src2Second source matrix or scalar.
dstDestination matrix that has the same size and number of channels as the input array(s). The depth is defined by dtype or src1 depth.
scaleOptional scale factor.
dtypeOptional depth of the output array.
streamStream for the asynchronous version.

This function, in contrast to divide, uses a round-down rounding mode.

See Also
divide
void cv::cuda::exp ( InputArray  src,
OutputArray  dst,
Stream &  stream = Stream::Null() 
)

Computes an exponent of each matrix element.

Parameters
srcSource matrix.
dstDestination matrix with the same size and type as src .
streamStream for the asynchronous version.
See Also
exp
void cv::cuda::log ( InputArray  src,
OutputArray  dst,
Stream &  stream = Stream::Null() 
)

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

Parameters
srcSource matrix.
dstDestination matrix with the same size and type as src .
streamStream for the asynchronous version.
See Also
log
void cv::cuda::lshift ( InputArray  src,
Scalar_< int >  val,
OutputArray  dst,
Stream &  stream = Stream::Null() 
)

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

Parameters
srcSource matrix. Supports 1, 3 and 4 channels images with CV_8U , CV_16U or CV_32S depth.
valConstant values, one per channel.
dstDestination matrix with the same size and type as src .
streamStream for the asynchronous version.
void cv::cuda::magnitude ( InputArray  xy,
OutputArray  magnitude,
Stream &  stream = Stream::Null() 
)

Computes magnitudes of complex matrix elements.

Parameters
xySource complex matrix in the interleaved format ( CV_32FC2 ).
magnitudeDestination matrix of float magnitudes ( CV_32FC1 ).
streamStream for the asynchronous version.
See Also
magnitude
void cv::cuda::magnitude ( InputArray  x,
InputArray  y,
OutputArray  magnitude,
Stream &  stream = Stream::Null() 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. computes magnitude of each (x(i), y(i)) vector supports only floating-point source

Parameters
xSource matrix containing real components ( CV_32FC1 ).
ySource matrix containing imaginary components ( CV_32FC1 ).
magnitudeDestination matrix of float magnitudes ( CV_32FC1 ).
streamStream for the asynchronous version.
void cv::cuda::magnitudeSqr ( InputArray  xy,
OutputArray  magnitude,
Stream &  stream = Stream::Null() 
)

Computes squared magnitudes of complex matrix elements.

Parameters
xySource complex matrix in the interleaved format ( CV_32FC2 ).
magnitudeDestination matrix of float magnitude squares ( CV_32FC1 ).
streamStream for the asynchronous version.
void cv::cuda::magnitudeSqr ( InputArray  x,
InputArray  y,
OutputArray  magnitude,
Stream &  stream = Stream::Null() 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. computes squared magnitude of each (x(i), y(i)) vector supports only floating-point source

Parameters
xSource matrix containing real components ( CV_32FC1 ).
ySource matrix containing imaginary components ( CV_32FC1 ).
magnitudeDestination matrix of float magnitude squares ( CV_32FC1 ).
streamStream for the asynchronous version.
void cv::cuda::max ( InputArray  src1,
InputArray  src2,
OutputArray  dst,
Stream &  stream = Stream::Null() 
)

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

Parameters
src1First source matrix or scalar.
src2Second source matrix or scalar.
dstDestination matrix that has the same size and type as the input array(s).
streamStream for the asynchronous version.
See Also
max
void cv::cuda::min ( InputArray  src1,
InputArray  src2,
OutputArray  dst,
Stream &  stream = Stream::Null() 
)

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

Parameters
src1First source matrix or scalar.
src2Second source matrix or scalar.
dstDestination matrix that has the same size and type as the input array(s).
streamStream for the asynchronous version.
See Also
min
void cv::cuda::multiply ( InputArray  src1,
InputArray  src2,
OutputArray  dst,
double  scale = 1,
int  dtype = -1,
Stream &  stream = Stream::Null() 
)

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

Parameters
src1First source matrix or scalar.
src2Second source matrix or scalar.
dstDestination matrix that has the same size and number of channels as the input array(s). The depth is defined by dtype or src1 depth.
scaleOptional scale factor.
dtypeOptional depth of the output array.
streamStream for the asynchronous version.
See Also
multiply
void cv::cuda::phase ( InputArray  x,
InputArray  y,
OutputArray  angle,
bool  angleInDegrees = false,
Stream &  stream = Stream::Null() 
)

Computes polar angles of complex matrix elements.

Parameters
xSource matrix containing real components ( CV_32FC1 ).
ySource matrix containing imaginary components ( CV_32FC1 ).
angleDestination matrix of angles ( CV_32FC1 ).
angleInDegreesFlag for angles that must be evaluated in degrees.
streamStream for the asynchronous version.
See Also
phase
void cv::cuda::polarToCart ( InputArray  magnitude,
InputArray  angle,
OutputArray  x,
OutputArray  y,
bool  angleInDegrees = false,
Stream &  stream = Stream::Null() 
)

Converts polar coordinates into Cartesian.

Parameters
magnitudeSource matrix containing magnitudes ( CV_32FC1 or CV_64FC1 ).
angleSource matrix containing angles ( same type as magnitude ).
xDestination matrix of real components ( same type as magnitude ).
yDestination matrix of imaginary components ( same type as magnitude ).
angleInDegreesFlag that indicates angles in degrees.
streamStream for the asynchronous version.
void cv::cuda::pow ( InputArray  src,
double  power,
OutputArray  dst,
Stream &  stream = Stream::Null() 
)

Raises every matrix element to a power.

Parameters
srcSource matrix.
powerExponent of power.
dstDestination matrix with the same size and type as src .
streamStream for the asynchronous version.

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

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

See Also
pow
void cv::cuda::rshift ( InputArray  src,
Scalar_< int >  val,
OutputArray  dst,
Stream &  stream = Stream::Null() 
)

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

Parameters
srcSource matrix. Supports 1, 3 and 4 channels images with integers elements.
valConstant values, one per channel.
dstDestination matrix with the same size and type as src .
streamStream for the asynchronous version.
static void cv::cuda::scaleAdd ( InputArray  src1,
double  alpha,
InputArray  src2,
OutputArray  dst,
Stream &  stream = Stream::Null() 
)
inlinestatic

adds scaled array to another one (dst = alpha*src1 + src2)

void cv::cuda::sqr ( InputArray  src,
OutputArray  dst,
Stream &  stream = Stream::Null() 
)

Computes a square value of each matrix element.

Parameters
srcSource matrix.
dstDestination matrix with the same size and type as src .
streamStream for the asynchronous version.
void cv::cuda::sqrt ( InputArray  src,
OutputArray  dst,
Stream &  stream = Stream::Null() 
)

Computes a square root of each matrix element.

Parameters
srcSource matrix.
dstDestination matrix with the same size and type as src .
streamStream for the asynchronous version.
See Also
sqrt
void cv::cuda::subtract ( InputArray  src1,
InputArray  src2,
OutputArray  dst,
InputArray  mask = noArray(),
int  dtype = -1,
Stream &  stream = Stream::Null() 
)

Computes a matrix-matrix or matrix-scalar difference.

Parameters
src1First source matrix or scalar.
src2Second source matrix or scalar. Matrix should have the same size and type as src1 .
dstDestination matrix that has the same size and number of channels as the input array(s). The depth is defined by dtype or src1 depth.
maskOptional operation mask, 8-bit single channel array, that specifies elements of the destination array to be changed. The mask can be used only with single channel images.
dtypeOptional depth of the output array.
streamStream for the asynchronous version.
See Also
subtract
double cv::cuda::threshold ( InputArray  src,
OutputArray  dst,
double  thresh,
double  maxval,
int  type,
Stream &  stream = Stream::Null() 
)

Applies a fixed-level threshold to each array element.

Parameters
srcSource array (single-channel).
dstDestination array with the same size and type as src .
threshThreshold value.
maxvalMaximum value to use with THRESH_BINARY and THRESH_BINARY_INV threshold types.
typeThreshold type. For details, see threshold . The THRESH_OTSU and THRESH_TRIANGLE threshold types are not supported.
streamStream for the asynchronous version.
See Also
threshold