2011-02-23 04:43:26 +08:00
Matrix Reductions
=================
.. highlight :: cpp
2011-08-30 16:27:23 +08:00
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
cuda::norm
----------
2011-08-30 16:27:23 +08:00
Returns the norm of a matrix (or difference of two matrices).
2013-08-20 19:05:49 +08:00
.. ocv:function :: double cuda::norm(InputArray src1, int normType)
2011-08-30 16:27:23 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: double cuda::norm(InputArray src1, int normType, GpuMat& buf)
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: double cuda::norm(InputArray src1, int normType, InputArray mask, GpuMat& buf)
2013-02-13 19:54:50 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: double cuda::norm(InputArray src1, InputArray src2, int normType=NORM_L2)
2011-02-23 04:43:26 +08:00
2011-06-19 04:19:03 +08:00
:param src1: Source matrix. Any matrices except 64F are supported.
2011-03-23 18:56:20 +08:00
2011-06-19 04:19:03 +08:00
:param src2: Second source matrix (if any) with the same size and type as ``src1``.
2011-03-23 18:56:20 +08:00
2011-03-29 07:05:42 +08:00
:param normType: Norm type. ``NORM_L1`` , ``NORM_L2`` , and ``NORM_INF`` are supported for now.
2011-02-23 04:43:26 +08:00
2013-02-13 19:54:50 +08:00
:param mask: optional operation mask; it must have the same size as ``src1`` and ``CV_8UC1`` type.
2011-03-29 07:05:42 +08:00
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. seealso :: :ocv:func: `norm`
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
cuda::sum
---------
2011-08-30 16:27:23 +08:00
Returns the sum of matrix elements.
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: Scalar cuda::sum(InputArray src)
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: Scalar cuda::sum(InputArray src, GpuMat& buf)
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: Scalar cuda::sum(InputArray src, InputArray mask, GpuMat& buf)
2013-02-13 19:54:50 +08:00
2011-03-29 07:05:42 +08:00
:param src: Source image of any depth except for ``CV_64F`` .
2011-03-23 18:56:20 +08:00
2013-02-13 19:54:50 +08:00
:param mask: optional operation mask; it must have the same size as ``src1`` and ``CV_8UC1`` type.
2011-03-29 07:05:42 +08:00
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
2011-03-23 18:56:20 +08:00
2011-08-30 16:27:23 +08:00
.. seealso :: :ocv:func: `sum`
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
cuda::absSum
------------
2011-08-30 16:27:23 +08:00
Returns the sum of absolute values for matrix elements.
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: Scalar cuda::absSum(InputArray src)
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: Scalar cuda::absSum(InputArray src, GpuMat& buf)
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: Scalar cuda::absSum(InputArray src, InputArray mask, GpuMat& buf)
2013-02-13 19:54:50 +08:00
2011-03-29 07:05:42 +08:00
:param src: Source image of any depth except for ``CV_64F`` .
2011-03-23 18:56:20 +08:00
2013-02-13 19:54:50 +08:00
:param mask: optional operation mask; it must have the same size as ``src1`` and ``CV_8UC1`` type.
2011-03-29 07:05:42 +08:00
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
2011-03-23 18:56:20 +08:00
2011-08-30 16:27:23 +08:00
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
cuda::sqrSum
------------
2011-08-30 16:27:23 +08:00
Returns the squared sum of matrix elements.
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: Scalar cuda::sqrSum(InputArray src)
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: Scalar cuda::sqrSum(InputArray src, GpuMat& buf)
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: Scalar cuda::sqrSum(InputArray src, InputArray mask, GpuMat& buf)
2013-02-13 19:54:50 +08:00
2011-03-29 07:05:42 +08:00
:param src: Source image of any depth except for ``CV_64F`` .
2011-03-23 18:56:20 +08:00
2013-02-13 19:54:50 +08:00
:param mask: optional operation mask; it must have the same size as ``src1`` and ``CV_8UC1`` type.
2011-03-29 07:05:42 +08:00
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
2011-03-23 18:56:20 +08:00
2011-08-30 16:27:23 +08:00
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
cuda::minMax
------------
2011-08-30 16:27:23 +08:00
Finds global minimum and maximum matrix elements and returns their values.
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: void cuda::minMax(InputArray src, double* minVal, double* maxVal=0, InputArray mask=noArray())
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: void cuda::minMax(InputArray src, double* minVal, double* maxVal, InputArray mask, GpuMat& buf)
2011-02-23 04:43:26 +08:00
2011-02-26 19:05:10 +08:00
:param src: Single-channel source image.
2011-02-23 04:43:26 +08:00
2011-03-29 07:05:42 +08:00
:param minVal: Pointer to the returned minimum value. Use ``NULL`` if not required.
2011-02-23 04:43:26 +08:00
2011-03-29 07:05:42 +08:00
:param maxVal: Pointer to the returned maximum value. Use ``NULL`` if not required.
2011-02-23 04:43:26 +08:00
2011-02-26 19:05:10 +08:00
:param mask: Optional mask to select a sub-matrix.
2011-02-23 04:43:26 +08:00
2011-03-29 07:05:42 +08:00
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
2011-03-23 18:56:20 +08:00
2011-04-01 06:07:17 +08:00
The function does not work with `` CV_64F `` images on GPUs with the compute capability < 1.3.
2011-02-23 04:43:26 +08:00
2011-08-30 16:27:23 +08:00
.. seealso :: :ocv:func: `minMaxLoc`
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
cuda::minMaxLoc
---------------
2011-08-30 16:27:23 +08:00
Finds global minimum and maximum matrix elements and returns their values with locations.
2013-08-20 19:05:49 +08:00
.. ocv:function :: void cuda::minMaxLoc(InputArray src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, InputArray mask=noArray())
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: void cuda::minMaxLoc(InputArray src, double* minVal, double* maxVal, Point* minLoc, Point* maxLoc, InputArray mask, GpuMat& valbuf, GpuMat& locbuf)
2011-02-23 04:43:26 +08:00
2011-02-26 19:05:10 +08:00
:param src: Single-channel source image.
2011-02-23 04:43:26 +08:00
2011-03-29 07:05:42 +08:00
:param minVal: Pointer to the returned minimum value. Use ``NULL`` if not required.
2011-02-23 04:43:26 +08:00
2011-03-29 07:05:42 +08:00
:param maxVal: Pointer to the returned maximum value. Use ``NULL`` if not required.
2011-02-23 04:43:26 +08:00
2012-03-29 14:50:05 +08:00
:param minLoc: Pointer to the returned minimum location. Use ``NULL`` if not required.
2011-02-23 04:43:26 +08:00
2012-03-29 14:50:05 +08:00
:param maxLoc: Pointer to the returned maximum location. Use ``NULL`` if not required.
2011-02-23 04:43:26 +08:00
2011-02-26 19:05:10 +08:00
:param mask: Optional mask to select a sub-matrix.
2011-02-23 04:43:26 +08:00
2011-03-29 07:05:42 +08:00
:param valbuf: Optional values buffer to avoid extra memory allocations. It is resized automatically.
2011-02-23 04:43:26 +08:00
2011-03-29 07:05:42 +08:00
:param locbuf: Optional locations buffer to avoid extra memory allocations. It is resized automatically.
2011-03-23 18:56:20 +08:00
2011-06-30 08:41:41 +08:00
The function does not work with `` CV_64F `` images on GPU with the compute capability < 1.3.
2011-03-23 18:56:20 +08:00
2011-08-30 16:27:23 +08:00
.. seealso :: :ocv:func: `minMaxLoc`
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
cuda::countNonZero
------------------
2011-08-30 16:27:23 +08:00
Counts non-zero matrix elements.
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: int cuda::countNonZero(InputArray src)
2011-02-23 04:43:26 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: int cuda::countNonZero(InputArray src, GpuMat& buf)
2011-02-23 04:43:26 +08:00
2011-02-26 19:05:10 +08:00
:param src: Single-channel source image.
2011-02-23 04:43:26 +08:00
2011-03-29 07:05:42 +08:00
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
2011-03-23 18:56:20 +08:00
2011-06-19 04:19:03 +08:00
The function does not work with `` CV_64F `` images on GPUs with the compute capability < 1.3.
2011-08-30 16:27:23 +08:00
.. seealso :: :ocv:func: `countNonZero`
2011-12-27 16:25:47 +08:00
2013-08-20 19:05:49 +08:00
cuda::reduce
------------
2011-12-27 16:25:47 +08:00
Reduces a matrix to a vector.
2013-08-20 19:05:49 +08:00
.. ocv:function :: void cuda::reduce(InputArray mtx, OutputArray vec, int dim, int reduceOp, int dtype = -1, Stream& stream = Stream::Null())
2011-12-27 16:25:47 +08:00
:param mtx: Source 2D matrix.
:param vec: Destination vector. Its size and type is defined by ``dim`` and ``dtype`` parameters.
:param dim: Dimension index along which the matrix is reduced. 0 means that the matrix is reduced to a single row. 1 means that the matrix is reduced to a single column.
:param reduceOp: Reduction operation that could be one of the following:
* **CV_REDUCE_SUM** The output is the sum of all rows/columns of the matrix.
* **CV_REDUCE_AVG** The output is the mean vector of all rows/columns of the matrix.
* **CV_REDUCE_MAX** The output is the maximum (column/row-wise) of all rows/columns of the matrix.
* **CV_REDUCE_MIN** The output is the minimum (column/row-wise) of all rows/columns of the matrix.
:param dtype: When it is negative, the destination vector will have the same type as the source matrix. Otherwise, its type will be ``CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), mtx.channels())`` .
2013-01-23 17:59:14 +08:00
2013-06-11 19:45:04 +08:00
:param stream: Stream for the asynchronous version.
2011-12-27 16:25:47 +08:00
The function `` reduce `` reduces the matrix to a vector by treating the matrix rows/columns as a set of 1D vectors and performing the specified operation on the vectors until a single row/column is obtained. For example, the function can be used to compute horizontal and vertical projections of a raster image. In case of `` CV_REDUCE_SUM `` and `` CV_REDUCE_AVG `` , the output may have a larger element bit-depth to preserve accuracy. And multi-channel arrays are also supported in these two reduction modes.
.. seealso :: :ocv:func: `reduce`
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
cuda::meanStdDev
----------------
2013-06-11 19:45:04 +08:00
Computes a mean value and a standard deviation of matrix elements.
2013-08-20 19:05:49 +08:00
.. ocv:function :: void cuda::meanStdDev(InputArray mtx, Scalar& mean, Scalar& stddev)
.. ocv:function :: void cuda::meanStdDev(InputArray mtx, Scalar& mean, Scalar& stddev, GpuMat& buf)
2013-06-11 19:45:04 +08:00
:param mtx: Source matrix. ``CV_8UC1`` matrices are supported for now.
:param mean: Mean value.
:param stddev: Standard deviation value.
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
.. seealso :: :ocv:func: `meanStdDev`
2013-08-20 19:05:49 +08:00
cuda::rectStdDev
----------------
2013-06-11 19:45:04 +08:00
Computes a standard deviation of integral images.
2013-08-20 19:05:49 +08:00
.. ocv:function :: void cuda::rectStdDev(InputArray src, InputArray sqr, OutputArray dst, Rect rect, Stream& stream = Stream::Null())
2013-06-11 19:45:04 +08:00
:param src: Source image. Only the ``CV_32SC1`` type is supported.
:param sqr: Squared source image. Only the ``CV_32FC1`` type is supported.
:param dst: Destination image with the same type and size as ``src`` .
:param rect: Rectangular window.
:param stream: Stream for the asynchronous version.
2013-08-20 19:05:49 +08:00
cuda::normalize
---------------
2013-06-04 17:32:35 +08:00
Normalizes the norm or value range of an array.
2013-08-20 19:05:49 +08:00
.. ocv:function :: void cuda::normalize(InputArray src, OutputArray dst, double alpha = 1, double beta = 0, int norm_type = NORM_L2, int dtype = -1, InputArray mask = noArray())
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: void cuda::normalize(InputArray src, OutputArray dst, double alpha, double beta, int norm_type, int dtype, InputArray mask, GpuMat& norm_buf, GpuMat& cvt_buf)
2013-06-04 17:32:35 +08:00
2013-06-11 19:45:04 +08:00
:param src: Input array.
2013-06-04 17:32:35 +08:00
2013-06-11 19:45:04 +08:00
:param dst: Output array of the same size as ``src`` .
2013-06-04 17:32:35 +08:00
2013-06-11 19:45:04 +08:00
:param alpha: Norm value to normalize to or the lower range boundary in case of the range normalization.
2013-06-04 17:32:35 +08:00
2013-06-11 19:45:04 +08:00
:param beta: Upper range boundary in case of the range normalization; it is not used for the norm normalization.
2013-06-04 17:32:35 +08:00
2013-06-11 19:45:04 +08:00
:param normType: Normalization type ( ``NORM_MINMAX`` , ``NORM_L2`` , ``NORM_L1`` or ``NORM_INF`` ).
2013-06-04 17:32:35 +08:00
2013-06-11 19:45:04 +08:00
: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)``.
2013-06-04 17:32:35 +08:00
2013-06-11 19:45:04 +08:00
:param mask: Optional operation mask.
2013-06-04 17:32:35 +08:00
: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`
2013-08-20 19:05:49 +08:00
cuda::integral
--------------
2013-06-11 19:45:04 +08:00
Computes an integral image.
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: void cuda::integral(InputArray src, OutputArray sum, Stream& stream = Stream::Null())
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: void cuda::integral(InputArray src, OutputArray sum, GpuMat& buffer, Stream& stream = Stream::Null())
2013-06-04 17:32:35 +08:00
2013-06-11 19:45:04 +08:00
:param src: Source image. Only ``CV_8UC1`` images are supported for now.
2013-06-04 17:32:35 +08:00
2013-06-11 19:45:04 +08:00
:param sum: Integral image containing 32-bit unsigned integer values packed into ``CV_32SC1`` .
2013-06-04 17:32:35 +08:00
2013-06-11 19:45:04 +08:00
:param buffer: Optional buffer to avoid extra memory allocations. It is resized automatically.
2013-06-04 17:32:35 +08:00
2013-06-11 19:45:04 +08:00
:param stream: Stream for the asynchronous version.
2013-06-04 17:32:35 +08:00
2013-06-11 19:45:04 +08:00
.. seealso :: :ocv:func: `integral`
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
cuda::sqrIntegral
-----------------
2013-06-11 19:45:04 +08:00
Computes a squared integral image.
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: void cuda::sqrIntegral(InputArray src, OutputArray sqsum, Stream& stream = Stream::Null())
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: void cuda::sqrIntegral(InputArray src, OutputArray sqsum, GpuMat& buf, Stream& stream = Stream::Null())
2013-06-04 17:32:35 +08:00
2013-06-11 19:45:04 +08:00
:param src: Source image. Only ``CV_8UC1`` images are supported for now.
2013-06-04 17:32:35 +08:00
2013-06-11 19:45:04 +08:00
:param sqsum: Squared integral image containing 64-bit unsigned integer values packed into ``CV_64FC1`` .
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
2013-06-04 17:32:35 +08:00
:param stream: Stream for the asynchronous version.