2011-06-18 22:19:03 +02:00
Per-element Operations
2011-03-05 22:26:13 +01:00
=======================
.. highlight :: cpp
2011-03-23 11:56:20 +01:00
2011-03-05 22:26:13 +01:00
gpu::add
------------
2011-08-30 10:27:23 +02:00
Computes a matrix-matrix or matrix-scalar sum.
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::add( const GpuMat& a, const GpuMat& b, GpuMat& c, const GpuMat& mask=GpuMat(), int dtype=-1, Stream& stream=Stream::Null() )
2011-08-30 10:27:23 +02:00
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::add( const GpuMat& a, const Scalar& sc, GpuMat& c, const GpuMat& mask=GpuMat(), int dtype=-1, Stream& stream=Stream::Null() )
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
:param a: First source matrix.
:param b: Second source matrix to be added to ``a`` . Matrix should have the same size and type as ``a`` .
2011-03-23 11:56:20 +01:00
2012-05-30 13:13:07 +02:00
:param sc: A scalar to be added to ``a`` .
:param c: Destination matrix that has the same size and number of channels as the input array(s). The depth is defined by ``dtype`` or ``a`` depth.
2011-03-05 22:26:13 +01:00
2011-12-27 09:25:47 +01:00
:param mask: Optional operation mask, 8-bit single channel array, that specifies elements of the destination array to be changed.
2012-05-30 13:13:07 +02:00
2011-12-27 09:25:47 +01:00
:param dtype: Optional depth of the output array.
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
:param stream: Stream for the asynchronous version.
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `add`
2011-03-05 22:26:13 +01:00
gpu::subtract
-----------------
2011-08-30 10:27:23 +02:00
Computes a matrix-matrix or matrix-scalar difference.
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::subtract( const GpuMat& a, const GpuMat& b, GpuMat& c, const GpuMat& mask=GpuMat(), int dtype=-1, Stream& stream=Stream::Null() )
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::subtract( const GpuMat& a, const Scalar& sc, GpuMat& c, const GpuMat& mask=GpuMat(), int dtype=-1, Stream& stream=Stream::Null() )
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
:param a: First source matrix.
:param b: Second source matrix to be added to ``a`` . Matrix should have the same size and type as ``a`` .
:param sc: A scalar to be added to ``a`` .
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
:param c: Destination matrix that has the same size and number of channels as the input array(s). The depth is defined by ``dtype`` or ``a`` depth.
2011-03-05 22:26:13 +01:00
2011-12-27 09:25:47 +01:00
:param mask: Optional operation mask, 8-bit single channel array, that specifies elements of the destination array to be changed.
2012-05-30 13:13:07 +02:00
2011-12-27 09:25:47 +01:00
:param dtype: Optional depth of the output array.
2011-03-23 11:56:20 +01:00
2011-08-30 10:27:23 +02:00
:param stream: Stream for the asynchronous version.
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `subtract`
2011-03-05 22:26:13 +01:00
gpu::multiply
-----------------
2011-08-30 10:27:23 +02:00
Computes a matrix-matrix or matrix-scalar per-element product.
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::multiply( const GpuMat& a, const GpuMat& b, GpuMat& c, double scale=1, int dtype=-1, Stream& stream=Stream::Null() )
2011-03-23 11:56:20 +01:00
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::multiply( const GpuMat& a, const Scalar& sc, GpuMat& c, double scale=1, int dtype=-1, Stream& stream=Stream::Null() )
2011-03-23 11:56:20 +01:00
2012-05-30 13:13:07 +02:00
:param a: First source matrix.
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
:param b: Second source matrix to be multiplied by ``a`` elements.
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
:param sc: A scalar to be multiplied by ``a`` elements.
:param c: Destination matrix that has the same size and number of channels as the input array(s). The depth is defined by ``dtype`` or ``a`` depth.
2011-12-27 09:25:47 +01:00
:param scale: Optional scale factor.
2012-05-30 13:13:07 +02:00
2011-12-27 09:25:47 +01:00
:param dtype: Optional depth of the output array.
2011-08-30 10:27:23 +02:00
:param stream: Stream for the asynchronous version.
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `multiply`
2011-03-05 22:26:13 +01:00
gpu::divide
2012-03-29 10:07:57 +02:00
-----------
2011-12-27 09:25:47 +01:00
Computes a matrix-matrix or matrix-scalar division.
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::divide( const GpuMat& a, const GpuMat& b, GpuMat& c, double scale=1, int dtype=-1, Stream& stream=Stream::Null() )
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::divide(const GpuMat& a, const Scalar& sc, GpuMat& c, double scale = 1, int dtype = -1, Stream& stream = Stream::Null())
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::divide( double scale, const GpuMat& b, GpuMat& c, int dtype=-1, Stream& stream=Stream::Null() )
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
:param a: First source matrix or a scalar.
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
:param b: Second source matrix. The ``a`` elements are divided by it.
:param sc: A scalar to be divided by the elements of ``a`` matrix.
:param c: Destination matrix that has the same size and number of channels as the input array(s). The depth is defined by ``dtype`` or ``a`` depth.
2011-12-27 09:25:47 +01:00
:param scale: Optional scale factor.
2012-05-30 13:13:07 +02:00
2011-12-27 09:25:47 +01:00
:param dtype: Optional depth of the output array.
2011-03-23 11:56:20 +01:00
2011-08-30 10:27:23 +02:00
:param stream: Stream for the asynchronous version.
2011-03-23 11:56:20 +01:00
2011-08-30 10:27:23 +02:00
This function, in contrast to :ocv:func: `divide` , uses a round-down rounding mode.
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `divide`
2011-03-05 22:26:13 +01:00
2012-03-29 10:07:57 +02:00
gpu::addWeighted
----------------
2011-12-27 09:25:47 +01:00
Computes the weighted sum of two arrays.
2012-03-02 21:59:13 +01:00
.. ocv:function :: void gpu::addWeighted(const GpuMat& src1, double alpha, const GpuMat& src2, double beta, double gamma, GpuMat& dst, int dtype = -1, Stream& stream = Stream::Null())
2011-12-27 09:25:47 +01:00
:param src1: First source array.
:param alpha: Weight for the first array elements.
:param src2: Second source array of the same size and channel number as ``src1`` .
2012-05-30 13:13:07 +02:00
2011-12-27 09:25:47 +01:00
:param beta: Weight for the second array elements.
:param dst: Destination array that has the same size and number of channels as the input arrays.
2012-05-30 13:13:07 +02:00
2011-12-27 09:25:47 +01:00
:param gamma: Scalar added to each sum.
2012-05-30 13:13:07 +02:00
2011-12-27 09:25:47 +01:00
:param dtype: Optional 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()``.
:param stream: Stream for the asynchronous version.
The function `` addWeighted `` calculates the weighted sum of two arrays as follows:
.. math ::
\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.
.. seealso :: :ocv:func: `addWeighted`
2012-02-22 11:00:53 +01:00
gpu::abs
2011-03-05 22:26:13 +01:00
------------
2012-02-22 11:00:53 +01:00
Computes an absolute value of each matrix element.
2011-03-05 22:26:13 +01:00
2012-02-22 11:00:53 +01:00
.. ocv:function :: void gpu::abs(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null())
2011-03-05 22:26:13 +01:00
2012-02-22 11:00:53 +01:00
:param src: Source matrix. Supports ``CV_16S`` and ``CV_32F`` depth.
2011-03-23 11:56:20 +01:00
2011-08-30 10:27:23 +02:00
:param dst: Destination matrix with the same size and type as ``src`` .
:param stream: Stream for the asynchronous version.
2012-02-22 11:00:53 +01:00
.. seealso :: :ocv:func: `abs`
2011-08-30 10:27:23 +02:00
2012-02-22 11:00:53 +01:00
gpu::sqr
2011-08-30 10:27:23 +02:00
------------
2012-02-22 11:00:53 +01:00
Computes a square value of each matrix element.
2011-08-30 10:27:23 +02:00
2012-02-22 11:00:53 +01:00
.. ocv:function :: void gpu::sqr(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null())
:param src: Source matrix. Supports ``CV_8U`` , ``CV_16U`` , ``CV_16S`` and ``CV_32F`` depth.
:param dst: Destination matrix with the same size and type as ``src`` .
:param stream: Stream for the asynchronous version.
2011-08-30 10:27:23 +02:00
2012-02-22 11:00:53 +01:00
gpu::sqrt
------------
Computes a square root of each matrix element.
.. ocv:function :: void gpu::sqrt(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null())
:param src: Source matrix. Supports ``CV_8U`` , ``CV_16U`` , ``CV_16S`` and ``CV_32F`` depth.
2011-08-30 10:27:23 +02:00
:param dst: Destination matrix with the same size and type as ``src`` .
:param stream: Stream for the asynchronous version.
2012-02-22 11:00:53 +01:00
.. seealso :: :ocv:func: `sqrt`
2011-03-23 11:56:20 +01:00
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
2012-02-22 11:00:53 +01:00
gpu::exp
------------
Computes an exponent of each matrix element.
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::exp( const GpuMat& a, GpuMat& b, Stream& stream=Stream::Null() )
2012-02-22 11:00:53 +01:00
2012-05-30 13:13:07 +02:00
:param a: Source matrix. Supports ``CV_8U`` , ``CV_16U`` , ``CV_16S`` and ``CV_32F`` depth.
2012-02-22 11:00:53 +01:00
2012-05-30 13:13:07 +02:00
:param b: Destination matrix with the same size and type as ``a`` .
2012-02-22 11:00:53 +01:00
:param stream: Stream for the asynchronous version.
.. seealso :: :ocv:func: `exp`
2011-03-05 22:26:13 +01:00
gpu::log
------------
2011-08-30 10:27:23 +02:00
Computes a natural logarithm of absolute value of each matrix element.
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::log( const GpuMat& a, GpuMat& b, Stream& stream=Stream::Null() )
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
:param a: Source matrix. Supports ``CV_8U`` , ``CV_16U`` , ``CV_16S`` and ``CV_32F`` depth.
2011-03-23 11:56:20 +01:00
2012-05-30 13:13:07 +02:00
:param b: Destination matrix with the same size and type as ``a`` .
2011-03-23 11:56:20 +01:00
2011-08-30 10:27:23 +02:00
:param stream: Stream for the asynchronous version.
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `log`
2011-03-05 22:26:13 +01:00
2012-02-22 11:00:53 +01:00
gpu::pow
------------
Raises every matrix element to a power.
.. ocv:function :: void gpu::pow(const GpuMat& src, double power, GpuMat& dst, Stream& stream = Stream::Null())
:param src: Source matrix. Supports all type, except ``CV_64F`` depth.
:param power: Exponent of power.
:param dst: Destination matrix with the same size and type as ``src`` .
:param stream: Stream for the asynchronous version.
The function `` pow `` raises every element of the input matrix to `` p `` :
.. math ::
\texttt{dst} (I) = \fork{\texttt{src}(I)^p}{if \texttt{p} is integer}{|\texttt{src}(I)|^p}{otherwise}
.. seealso :: :ocv:func: `pow`
2011-03-05 22:26:13 +01:00
gpu::absdiff
----------------
2011-08-30 10:27:23 +02:00
Computes per-element absolute difference of two matrices (or of a matrix and scalar).
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::absdiff( const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream=Stream::Null() )
2011-08-30 10:27:23 +02:00
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::absdiff( const GpuMat& a, const Scalar& s, GpuMat& c, Stream& stream=Stream::Null() )
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
:param a: First source matrix.
2011-03-23 11:56:20 +01:00
2012-05-30 13:13:07 +02:00
:param b: Second source matrix to be added to ``a`` .
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
:param s: A scalar to be added to ``a`` .
:param c: Destination matrix with the same size and type as ``a`` .
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
:param stream: Stream for the asynchronous version.
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `absdiff`
2011-03-23 11:56:20 +01:00
2011-03-05 22:26:13 +01:00
gpu::compare
----------------
2011-08-30 10:27:23 +02:00
Compares elements of two matrices.
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::compare( const GpuMat& a, const GpuMat& b, GpuMat& c, int cmpop, Stream& stream=Stream::Null() )
2011-03-05 22:26:13 +01:00
2012-05-30 13:13:07 +02:00
:param a: First source matrix.
:param b: Second source matrix with the same size and type as ``a`` .
:param c: Destination matrix with the same size as ``a`` and the ``CV_8UC1`` type.
2011-03-05 22:26:13 +01:00
:param cmpop: Flag specifying the relation between the elements to be checked:
2011-08-30 10:27:23 +02:00
2012-05-30 13:13:07 +02:00
* **CMP_EQ:** `` a(.) == b(.) ``
* **CMP_GT:** `` a(.) < b(.) ``
* **CMP_GE:** `` a(.) <= b(.) ``
* **CMP_LT:** `` a(.) < b(.) ``
* **CMP_LE:** `` a(.) <= b(.) ``
* **CMP_NE:** `` a(.) != b(.) ``
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
:param stream: Stream for the asynchronous version.
.. seealso :: :ocv:func: `compare`
2011-03-23 11:56:20 +01:00
2011-03-05 22:26:13 +01:00
gpu::bitwise_not
--------------------
2011-08-30 10:27:23 +02:00
Performs a per-element bitwise inversion.
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: void gpu::bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null())
2011-03-05 22:26:13 +01:00
:param src: Source matrix.
2011-08-30 10:27:23 +02:00
:param dst: Destination matrix with the same size and type as ``src`` .
2011-03-05 22:26:13 +01:00
:param mask: Optional operation mask. 8-bit single channel image.
:param stream: Stream for the asynchronous version.
2011-03-23 11:56:20 +01:00
2011-03-05 22:26:13 +01:00
gpu::bitwise_or
-------------------
2012-02-22 11:00:53 +01:00
Performs a per-element bitwise disjunction of two matrices or of matrix and scalar.
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: void gpu::bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null())
2012-02-22 11:00:53 +01:00
.. ocv:function :: void gpu::bitwise_or(const GpuMat& src1, const Scalar& sc, GpuMat& dst, Stream& stream = Stream::Null())
2011-03-05 22:26:13 +01:00
:param src1: First source matrix.
2011-08-30 10:27:23 +02:00
:param src2: Second source matrix with the same size and type as ``src1`` .
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
:param dst: Destination matrix with the same size and type as ``src1`` .
2011-03-05 22:26:13 +01:00
:param mask: Optional operation mask. 8-bit single channel image.
:param stream: Stream for the asynchronous version.
2011-03-23 11:56:20 +01:00
2011-03-05 22:26:13 +01:00
gpu::bitwise_and
--------------------
2012-02-22 11:00:53 +01:00
Performs a per-element bitwise conjunction of two matrices or of matrix and scalar.
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: void gpu::bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null())
2012-02-22 11:00:53 +01:00
.. ocv:function :: void gpu::bitwise_and(const GpuMat& src1, const Scalar& sc, GpuMat& dst, Stream& stream = Stream::Null())
2011-03-05 22:26:13 +01:00
:param src1: First source matrix.
2011-08-30 10:27:23 +02:00
:param src2: Second source matrix with the same size and type as ``src1`` .
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
:param dst: Destination matrix with the same size and type as ``src1`` .
2011-03-05 22:26:13 +01:00
:param mask: Optional operation mask. 8-bit single channel image.
:param stream: Stream for the asynchronous version.
2011-03-23 11:56:20 +01:00
2011-03-05 22:26:13 +01:00
gpu::bitwise_xor
--------------------
2012-02-22 11:00:53 +01:00
Performs a per-element bitwise `` exclusive or `` operation of two matrices of matrix and scalar.
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: void gpu::bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null())
2012-02-22 11:00:53 +01:00
.. ocv:function :: void gpu::bitwise_xor(const GpuMat& src1, const Scalar& sc, GpuMat& dst, Stream& stream = Stream::Null())
2011-03-05 22:26:13 +01:00
:param src1: First source matrix.
2011-08-30 10:27:23 +02:00
:param src2: Second source matrix with the same size and type as ``src1`` .
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
:param dst: Destination matrix with the same size and type as ``src1`` .
2011-03-05 22:26:13 +01:00
:param mask: Optional operation mask. 8-bit single channel image.
:param stream: Stream for the asynchronous version.
2011-03-23 11:56:20 +01:00
2012-02-22 11:00:53 +01:00
gpu::rshift
--------------------
Performs pixel by pixel right shift of an image by a constant value.
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::rshift( const GpuMat& src, Scalar_<int> sc, GpuMat& dst, Stream& stream=Stream::Null() )
2012-02-22 11:00:53 +01:00
:param src: Source matrix. Supports 1, 3 and 4 channels images with integers elements.
:param sc: Constant values, one per channel.
:param dst: Destination matrix with the same size and type as ``src`` .
:param stream: Stream for the asynchronous version.
gpu::lshift
--------------------
Performs pixel by pixel right left of an image by a constant value.
2012-05-30 13:13:07 +02:00
.. ocv:function :: void gpu::lshift( const GpuMat& src, Scalar_<int> sc, GpuMat& dst, Stream& stream=Stream::Null() )
2012-02-22 11:00:53 +01:00
:param src: Source matrix. Supports 1, 3 and 4 channels images with ``CV_8U`` , ``CV_16U`` or ``CV_32S`` depth.
:param sc: Constant values, one per channel.
:param dst: Destination matrix with the same size and type as ``src`` .
:param stream: Stream for the asynchronous version.
2011-03-05 22:26:13 +01:00
gpu::min
------------
2011-08-30 10:27:23 +02:00
Computes the per-element minimum of two matrices (or a matrix and a scalar).
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: void gpu::min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null())
2011-03-23 11:56:20 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: void gpu::min(const GpuMat& src1, double src2, GpuMat& dst, Stream& stream = Stream::Null())
2011-03-05 22:26:13 +01:00
:param src1: First source matrix.
2011-03-29 23:48:36 +02:00
:param src2: Second source matrix or a scalar to compare ``src1`` elements with.
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
:param dst: Destination matrix with the same size and type as ``src1`` .
2011-03-05 22:26:13 +01:00
2011-03-23 11:56:20 +01:00
:param stream: Stream for the asynchronous version.
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `min`
2011-03-05 22:26:13 +01:00
gpu::max
------------
2011-08-30 10:27:23 +02:00
Computes the per-element maximum of two matrices (or a matrix and a scalar).
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: void gpu::max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null())
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: void gpu::max(const GpuMat& src1, double src2, GpuMat& dst, Stream& stream = Stream::Null())
2011-03-05 22:26:13 +01:00
:param src1: First source matrix.
2011-03-29 01:05:42 +02:00
:param src2: Second source matrix or a scalar to compare ``src1`` elements with.
2011-03-05 22:26:13 +01:00
2011-08-30 10:27:23 +02:00
:param dst: Destination matrix with the same size and type as ``src1`` .
2011-03-05 22:26:13 +01:00
:param stream: Stream for the asynchronous version.
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `max`