2011-02-23 04:43:26 +08:00
Operations on Matrices
======================
.. highlight :: cpp
2011-08-30 16:27:23 +08:00
2011-02-23 04:43:26 +08:00
2011-12-27 16:25:47 +08:00
gpu::gemm
------------------
Performs generalized matrix multiplication.
2012-05-30 19:13:07 +08:00
.. ocv:function :: void gpu::gemm(const GpuMat& src1, const GpuMat& src2, double alpha, const GpuMat& src3, double beta, GpuMat& dst, int flags = 0, Stream& stream = Stream::Null())
2011-12-27 16:25:47 +08:00
:param src1: First multiplied input matrix that should have ``CV_32FC1`` , ``CV_64FC1`` , ``CV_32FC2`` , or ``CV_64FC2`` type.
:param src2: Second multiplied input matrix of the same type as ``src1`` .
2012-04-03 14:45:32 +08:00
2011-12-27 16:25:47 +08:00
:param alpha: Weight of the matrix product.
:param src3: Third optional delta matrix added to the matrix product. It should have the same type as ``src1`` and ``src2`` .
2012-04-03 14:45:32 +08:00
2011-12-27 16:25:47 +08:00
:param beta: Weight of ``src3`` .
2012-04-03 14:45:32 +08:00
2011-12-27 16:25:47 +08:00
:param dst: Destination matrix. It has the proper size and the same type as input matrices.
:param flags: Operation flags:
* **GEMM_1_T** transpose `` src1 ``
* **GEMM_2_T** transpose `` src2 ``
* **GEMM_3_T** transpose `` src3 ``
:param stream: Stream for the asynchronous version.
2012-04-03 14:45:32 +08:00
2011-12-27 16:25:47 +08:00
The function performs generalized matrix multiplication similar to the `` gemm `` functions in BLAS level 3. For example, `` gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T) `` corresponds to
.. math ::
\texttt{dst} = \texttt{alpha} \cdot \texttt{src1} ^T \cdot \texttt{src2} + \texttt{beta} \cdot \texttt{src3} ^T
2012-04-03 14:45:32 +08:00
.. note :: Transposition operation doesn't support `` CV_64FC2 `` input type.
2011-12-27 16:25:47 +08:00
.. seealso :: :ocv:func: `gemm`
2011-03-03 15:29:55 +08:00
gpu::transpose
2011-02-23 04:43:26 +08:00
------------------
2011-08-30 16:27:23 +08:00
Transposes a matrix.
2011-02-23 04:43:26 +08:00
2012-05-30 19:13:07 +08:00
.. ocv:function :: void gpu::transpose( const GpuMat& src1, GpuMat& dst, Stream& stream=Stream::Null() )
2011-02-23 04:43:26 +08:00
2012-05-30 19:13:07 +08:00
:param src1: Source matrix. 1-, 4-, 8-byte element sizes are supported for now (CV_8UC1, CV_8UC4, CV_16UC2, CV_32FC1, etc).
2011-02-23 04:43:26 +08:00
2011-02-26 19:05:10 +08:00
:param dst: Destination matrix.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param stream: Stream for the asynchronous version.
.. seealso :: :ocv:func: `transpose`
2011-02-23 04:43:26 +08:00
2011-03-03 15:29:55 +08:00
gpu::flip
2011-02-23 04:43:26 +08:00
-------------
2011-08-30 16:27:23 +08:00
Flips a 2D matrix around vertical, horizontal, or both axes.
2011-02-23 04:43:26 +08:00
2012-05-30 19:13:07 +08:00
.. ocv:function :: void gpu::flip( const GpuMat& a, GpuMat& b, int flipCode, Stream& stream=Stream::Null() )
2011-02-23 04:43:26 +08:00
2012-05-30 19:13:07 +08:00
:param a: Source matrix. Supports 1, 3 and 4 channels images with ``CV_8U``, ``CV_16U``, ``CV_32S`` or ``CV_32F`` depth.
2011-02-23 04:43:26 +08:00
2012-05-30 19:13:07 +08:00
:param b: Destination matrix.
2011-02-23 04:43:26 +08:00
2011-03-29 07:05:42 +08:00
:param flipCode: Flip mode for the source:
2011-03-23 18:56:20 +08:00
2011-08-30 16:27:23 +08:00
* `` 0 `` Flips around x-axis.
* `` >0 `` Flips around y-axis.
* `` <0 `` Flips around both axes.
:param stream: Stream for the asynchronous version.
.. seealso :: :ocv:func: `flip`
2011-02-23 04:43:26 +08:00
2011-03-03 15:29:55 +08:00
gpu::LUT
2011-02-23 04:43:26 +08:00
------------
2011-08-30 16:27:23 +08:00
Transforms the source matrix into the destination matrix using the given look-up table: `` dst(I) = lut(src(I)) ``
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. ocv:function :: void gpu::LUT(const GpuMat& src, const Mat& lut, GpuMat& dst, Stream& stream = Stream::Null())
2011-02-23 04:43:26 +08:00
2011-03-29 07:05:42 +08:00
:param src: Source matrix. ``CV_8UC1`` and ``CV_8UC3`` matrices are supported for now.
2011-02-23 04:43:26 +08:00
2011-04-01 06:07:17 +08:00
:param lut: Look-up table of 256 elements. It is a continuous ``CV_8U`` matrix.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param dst: Destination matrix with the same depth as ``lut`` and the same number of channels as ``src`` .
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param stream: Stream for the asynchronous version.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. seealso :: :ocv:func: `LUT`
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
gpu::merge
--------------
Makes a multi-channel matrix out of several single-channel matrices.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. ocv:function :: void gpu::merge(const GpuMat* src, size_t n, GpuMat& dst, Stream& stream = Stream::Null())
2011-03-23 18:56:20 +08:00
2011-08-30 16:27:23 +08:00
.. ocv:function :: void gpu::merge(const vector<GpuMat>& src, GpuMat& dst, Stream& stream = Stream::Null())
2011-03-23 18:56:20 +08:00
2011-03-29 07:05:42 +08:00
:param src: Array/vector of source matrices.
2011-02-23 04:43:26 +08:00
2011-03-29 07:05:42 +08:00
:param n: Number of source matrices.
2011-02-23 04:43:26 +08:00
2011-03-29 07:05:42 +08:00
:param dst: Destination matrix.
2011-02-23 04:43:26 +08:00
2011-03-29 07:05:42 +08:00
:param stream: Stream for the asynchronous version.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. seealso :: :ocv:func: `merge`
2011-02-23 04:43:26 +08:00
2011-03-03 15:29:55 +08:00
gpu::split
2011-02-23 04:43:26 +08:00
--------------
2011-08-30 16:27:23 +08:00
Copies each plane of a multi-channel matrix into an array.
2011-03-23 18:56:20 +08:00
2011-08-30 16:27:23 +08:00
.. ocv:function :: void gpu::split(const GpuMat& src, GpuMat* dst, Stream& stream = Stream::Null())
2011-03-23 18:56:20 +08:00
2011-08-30 16:27:23 +08:00
.. ocv:function :: void gpu::split(const GpuMat& src, vector<GpuMat>& dst, Stream& stream = Stream::Null())
2011-03-29 07:05:42 +08:00
2011-03-23 18:56:20 +08:00
:param src: Source matrix.
2011-02-23 04:43:26 +08:00
2011-06-19 04:19:03 +08:00
:param dst: Destination array/vector of single-channel matrices.
2011-02-23 04:43:26 +08:00
2011-03-23 18:56:20 +08:00
:param stream: Stream for the asynchronous version.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. seealso :: :ocv:func: `split`
2011-02-23 04:43:26 +08:00
2011-03-03 15:29:55 +08:00
gpu::magnitude
2011-02-23 04:43:26 +08:00
------------------
2011-08-30 16:27:23 +08:00
Computes magnitudes of complex matrix elements.
2011-02-23 04:43:26 +08:00
2012-05-30 19:13:07 +08:00
.. ocv:function :: void gpu::magnitude( const GpuMat& xy, GpuMat& magnitude, Stream& stream=Stream::Null() )
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. ocv:function :: void gpu::magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, Stream& stream = Stream::Null())
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param xy: Source complex matrix in the interleaved format ( ``CV_32FC2`` ).
2011-03-29 07:05:42 +08:00
2011-08-30 16:27:23 +08:00
:param x: Source matrix containing real components ( ``CV_32FC1`` ).
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param y: Source matrix containing imaginary components ( ``CV_32FC1`` ).
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param magnitude: Destination matrix of float magnitudes ( ``CV_32FC1`` ).
2011-03-23 18:56:20 +08:00
:param stream: Stream for the asynchronous version.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. seealso :: :ocv:func: `magnitude`
2011-02-23 04:43:26 +08:00
2011-03-03 15:29:55 +08:00
gpu::magnitudeSqr
2011-02-23 04:43:26 +08:00
---------------------
2011-08-30 16:27:23 +08:00
Computes squared magnitudes of complex matrix elements.
2011-02-23 04:43:26 +08:00
2012-05-30 19:13:07 +08:00
.. ocv:function :: void gpu::magnitudeSqr( const GpuMat& xy, GpuMat& magnitude, Stream& stream=Stream::Null() )
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. ocv:function :: void gpu::magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, Stream& stream = Stream::Null())
2011-03-29 07:05:42 +08:00
2011-08-30 16:27:23 +08:00
:param xy: Source complex matrix in the interleaved format ( ``CV_32FC2`` ).
2011-03-29 07:05:42 +08:00
2011-08-30 16:27:23 +08:00
:param x: Source matrix containing real components ( ``CV_32FC1`` ).
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param y: Source matrix containing imaginary components ( ``CV_32FC1`` ).
2011-03-23 18:56:20 +08:00
2011-08-30 16:27:23 +08:00
:param magnitude: Destination matrix of float magnitude squares ( ``CV_32FC1`` ).
2011-03-23 18:56:20 +08:00
:param stream: Stream for the asynchronous version.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
2011-02-23 04:43:26 +08:00
2011-03-03 15:29:55 +08:00
gpu::phase
2011-02-23 04:43:26 +08:00
--------------
2011-08-30 16:27:23 +08:00
Computes polar angles of complex matrix elements.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. ocv:function :: void gpu::phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees=false, Stream& stream = Stream::Null())
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param x: Source matrix containing real components ( ``CV_32FC1`` ).
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param y: Source matrix containing imaginary components ( ``CV_32FC1`` ).
2011-02-23 04:43:26 +08:00
2012-04-14 03:04:44 +08:00
:param angle: Destination matrix of angles ( ``CV_32FC1`` ).
2011-02-23 04:43:26 +08:00
2012-04-14 03:04:44 +08:00
:param angleInDegrees: Flag for angles that must be evaluated in degrees.
2011-02-23 04:43:26 +08:00
2011-02-26 19:05:10 +08:00
:param stream: Stream for the asynchronous version.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. seealso :: :ocv:func: `phase`
2011-02-23 04:43:26 +08:00
2011-03-03 15:29:55 +08:00
gpu::cartToPolar
2011-02-23 04:43:26 +08:00
--------------------
2011-08-30 16:27:23 +08:00
Converts Cartesian coordinates into polar.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. ocv:function :: void gpu::cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, GpuMat& angle, bool angleInDegrees=false, Stream& stream = Stream::Null())
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param x: Source matrix containing real components ( ``CV_32FC1`` ).
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param y: Source matrix containing imaginary components ( ``CV_32FC1`` ).
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param magnitude: Destination matrix of float magnitudes ( ``CV_32FC1`` ).
2011-02-23 04:43:26 +08:00
2012-04-14 03:04:44 +08:00
:param angle: Destination matrix of angles ( ``CV_32FC1`` ).
2011-02-23 04:43:26 +08:00
2012-04-14 03:04:44 +08:00
:param angleInDegrees: Flag for angles that must be evaluated in degrees.
2011-02-23 04:43:26 +08:00
2011-02-26 19:05:10 +08:00
:param stream: Stream for the asynchronous version.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. seealso :: :ocv:func: `cartToPolar`
2011-02-23 04:43:26 +08:00
2011-03-03 15:29:55 +08:00
gpu::polarToCart
2011-02-23 04:43:26 +08:00
--------------------
2011-08-30 16:27:23 +08:00
Converts polar coordinates into Cartesian.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. ocv:function :: void gpu::polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees=false, Stream& stream = Stream::Null())
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param magnitude: Source matrix containing magnitudes ( ``CV_32FC1`` ).
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param angle: Source matrix containing angles ( ``CV_32FC1`` ).
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param x: Destination matrix of real components ( ``CV_32FC1`` ).
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
:param y: Destination matrix of imaginary components ( ``CV_32FC1`` ).
2011-02-23 04:43:26 +08:00
2012-04-14 03:04:44 +08:00
:param angleInDegrees: Flag that indicates angles in degrees.
2011-02-23 04:43:26 +08:00
2011-02-26 19:05:10 +08:00
:param stream: Stream for the asynchronous version.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. seealso :: :ocv:func: `polarToCart`
2013-02-13 19:55:58 +08:00
gpu::normalize
--------------
Normalizes the norm or value range of an array.
.. ocv:function :: void gpu::normalize(const GpuMat& src, GpuMat& dst, double alpha = 1, double beta = 0, int norm_type = NORM_L2, int dtype = -1, const GpuMat& mask = GpuMat())
.. ocv:function :: void gpu::normalize(const GpuMat& src, GpuMat& dst, double a, double b, int norm_type, int dtype, const GpuMat& mask, GpuMat& norm_buf, GpuMat& cvt_buf)
:param src: input array.
:param dst: output array of the same size as ``src`` .
:param alpha: norm value to normalize to or the lower range boundary in case of the range normalization.
:param beta: upper range boundary in case of the range normalization; it is not used for the norm normalization.
:param normType: normalization type (see the details below).
:param dtype: when negative, the output array has the same type as ``src``; otherwise, it has the same number of channels as ``src`` and the depth ``=CV_MAT_DEPTH(dtype)``.
:param mask: optional operation mask.
:param norm_buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
:param cvt_buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
.. seealso :: :ocv:func: `normalize`