2011-02-22 21:43:26 +01:00
Matrix Reductions
=================
.. highlight :: cpp
2011-08-30 10:27:23 +02:00
2011-02-22 21:43:26 +01:00
2011-03-03 08:29:55 +01:00
gpu::meanStdDev
2011-02-22 21:43:26 +01:00
-------------------
2011-08-30 10:27:23 +02:00
Computes a mean value and a standard deviation of matrix elements.
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: void gpu::meanStdDev(const GpuMat& mtx, Scalar& mean, Scalar& stddev)
2012-03-02 21:59:13 +01:00
.. ocv:function :: void gpu::meanStdDev(const GpuMat& mtx, Scalar& mean, Scalar& stddev, GpuMat& buf)
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
:param mtx: Source matrix. ``CV_8UC1`` matrices are supported for now.
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
:param mean: Mean value.
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
:param stddev: Standard deviation value.
2011-02-22 21:43:26 +01:00
2012-02-22 11:00:53 +01:00
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `meanStdDev`
2011-02-22 21:43:26 +01:00
2011-03-03 08:29:55 +01:00
gpu::norm
2011-02-22 21:43:26 +01:00
-------------
2011-08-30 10:27:23 +02:00
Returns the norm of a matrix (or difference of two matrices).
.. ocv:function :: double gpu::norm(const GpuMat& src1, int normType=NORM_L2)
.. ocv:function :: double gpu::norm(const GpuMat& src1, int normType, GpuMat& buf)
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: double gpu::norm(const GpuMat& src1, const GpuMat& src2, int normType=NORM_L2)
2011-02-22 21:43:26 +01:00
2011-06-18 22:19:03 +02:00
:param src1: Source matrix. Any matrices except 64F are supported.
2011-03-23 11:56:20 +01:00
2011-06-18 22:19:03 +02:00
:param src2: Second source matrix (if any) with the same size and type as ``src1``.
2011-03-23 11:56:20 +01:00
2011-03-29 01:05:42 +02:00
:param normType: Norm type. ``NORM_L1`` , ``NORM_L2`` , and ``NORM_INF`` are supported for now.
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `norm`
2011-02-22 21:43:26 +01:00
2011-03-03 08:29:55 +01:00
gpu::sum
2011-02-22 21:43:26 +01:00
------------
2011-08-30 10:27:23 +02:00
Returns the sum of matrix elements.
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: Scalar gpu::sum(const GpuMat& src)
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: Scalar gpu::sum(const GpuMat& src, GpuMat& buf)
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
:param src: Source image of any depth except for ``CV_64F`` .
2011-03-23 11:56:20 +01:00
2011-03-29 01:05:42 +02:00
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
2011-03-23 11:56:20 +01:00
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `sum`
2011-02-22 21:43:26 +01:00
2011-03-03 08:29:55 +01:00
gpu::absSum
2011-02-22 21:43:26 +01:00
---------------
2011-08-30 10:27:23 +02:00
Returns the sum of absolute values for matrix elements.
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: Scalar gpu::absSum(const GpuMat& src)
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: Scalar gpu::absSum(const GpuMat& src, GpuMat& buf)
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
:param src: Source image of any depth except for ``CV_64F`` .
2011-03-23 11:56:20 +01:00
2011-03-29 01:05:42 +02:00
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
2011-03-23 11:56:20 +01:00
2011-08-30 10:27:23 +02:00
2011-02-22 21:43:26 +01:00
2011-03-03 08:29:55 +01:00
gpu::sqrSum
2011-02-22 21:43:26 +01:00
---------------
2011-08-30 10:27:23 +02:00
Returns the squared sum of matrix elements.
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: Scalar gpu::sqrSum(const GpuMat& src)
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: Scalar gpu::sqrSum(const GpuMat& src, GpuMat& buf)
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
:param src: Source image of any depth except for ``CV_64F`` .
2011-03-23 11:56:20 +01:00
2011-03-29 01:05:42 +02:00
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
2011-03-23 11:56:20 +01:00
2011-08-30 10:27:23 +02:00
2011-02-22 21:43:26 +01:00
2011-03-03 08:29:55 +01:00
gpu::minMax
2011-02-22 21:43:26 +01:00
---------------
2011-08-30 10:27:23 +02:00
Finds global minimum and maximum matrix elements and returns their values.
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: void gpu::minMax(const GpuMat& src, double* minVal, double* maxVal=0, const GpuMat& mask=GpuMat())
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: void gpu::minMax(const GpuMat& src, double* minVal, double* maxVal, const GpuMat& mask, GpuMat& buf)
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
:param src: Single-channel source image.
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
:param minVal: Pointer to the returned minimum value. Use ``NULL`` if not required.
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
:param maxVal: Pointer to the returned maximum value. Use ``NULL`` if not required.
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
:param mask: Optional mask to select a sub-matrix.
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
2011-03-23 11:56:20 +01:00
2011-04-01 00:07:17 +02:00
The function does not work with `` CV_64F `` images on GPUs with the compute capability < 1.3.
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `minMaxLoc`
2011-02-22 21:43:26 +01:00
2011-03-03 08:29:55 +01:00
gpu::minMaxLoc
2011-02-22 21:43:26 +01:00
------------------
2011-08-30 10:27:23 +02:00
Finds global minimum and maximum matrix elements and returns their values with locations.
2011-06-16 14:48:23 +02:00
.. ocv:function :: void gpu::minMaxLoc(const GpuMat& src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, const GpuMat& mask=GpuMat())
2011-02-22 21:43:26 +01:00
2011-06-16 14:48:23 +02:00
.. ocv:function :: void gpu::minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point* minLoc, Point* maxLoc, const GpuMat& mask, GpuMat& valbuf, GpuMat& locbuf)
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
:param src: Single-channel source image.
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
:param minVal: Pointer to the returned minimum value. Use ``NULL`` if not required.
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
:param maxVal: Pointer to the returned maximum value. Use ``NULL`` if not required.
2011-02-22 21:43:26 +01:00
2012-03-29 08:50:05 +02:00
:param minLoc: Pointer to the returned minimum location. Use ``NULL`` if not required.
2011-02-22 21:43:26 +01:00
2012-03-29 08:50:05 +02:00
:param maxLoc: Pointer to the returned maximum location. Use ``NULL`` if not required.
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
:param mask: Optional mask to select a sub-matrix.
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
:param valbuf: Optional values buffer to avoid extra memory allocations. It is resized automatically.
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
:param locbuf: Optional locations buffer to avoid extra memory allocations. It is resized automatically.
2011-03-23 11:56:20 +01:00
2011-06-30 02:41:41 +02:00
The function does not work with `` CV_64F `` images on GPU with the compute capability < 1.3.
2011-03-23 11:56:20 +01:00
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `minMaxLoc`
2011-02-22 21:43:26 +01:00
2011-03-03 08:29:55 +01:00
gpu::countNonZero
2011-02-22 21:43:26 +01:00
---------------------
2011-08-30 10:27:23 +02:00
Counts non-zero matrix elements.
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: int gpu::countNonZero(const GpuMat& src)
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
.. ocv:function :: int gpu::countNonZero(const GpuMat& src, GpuMat& buf)
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
:param src: Single-channel source image.
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
2011-03-23 11:56:20 +01:00
2011-06-18 22:19:03 +02:00
The function does not work with `` CV_64F `` images on GPUs with the compute capability < 1.3.
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `countNonZero`
2011-12-27 09:25:47 +01:00
gpu::reduce
2012-03-02 21:59:13 +01:00
-----------
2011-12-27 09:25:47 +01:00
Reduces a matrix to a vector.
.. ocv:function :: void gpu::reduce(const GpuMat& mtx, GpuMat& vec, int dim, int reduceOp, int dtype = -1, Stream& stream = Stream::Null())
: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())`` .
2012-10-17 19:42:09 +02:00
2011-12-27 09:25:47 +01: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`