Matrix Reductions
=============================

.. highlight:: cpp

ocl::countNonZero
------------------
Returns the number of non-zero elements in src

.. ocv:function:: int countNonZero(const oclMat &src)

    :param src: Single-channel array

Counts non-zero array elements.

ocl::minMax
------------------
Returns void

.. ocv:function:: void minMax(const oclMat &src, double *minVal, double *maxVal = 0, const oclMat &mask = oclMat())

    :param src: Single-channel array

    :param minVal: Pointer to returned minimum value, should not be NULL

    :param maxVal: Pointer to returned maximum value, should not be NULL

    :param mask: The optional mask used to select a sub-array

Finds global minimum and maximum in a whole array or sub-array. Supports all data types.

ocl::minMaxLoc
------------------
Returns void

.. ocv:function:: void minMaxLoc(const oclMat &src, double *minVal, double *maxVal = 0, Point *minLoc = 0, Point *maxLoc = 0,const oclMat &mask = oclMat())

    :param src: Single-channel array

    :param minVal: Pointer to returned minimum value, should not be NULL

    :param maxVal: Pointer to returned maximum value, should not be NULL

    :param minLoc: Pointer to returned minimum location (in 2D case), should not be NULL

    :param maxLoc: Pointer to returned maximum location (in 2D case) should not be NULL

    :param mask: The optional mask used to select a sub-array

The functions minMaxLoc find minimum and maximum element values and their positions. The extremums are searched across the whole array, or, if mask is not an empty array, in the specified array region. The functions do not work with multi-channel arrays.

ocl::Sum
------------------
Returns the sum of matrix elements for each channel

.. ocv:function:: Scalar sum(const oclMat &m)

    :param m: The Source image of all depth

Counts the sum of matrix elements for each channel.

ocl::sqrSum
------------------
Returns the squared sum of matrix elements for each channel

.. ocv:function:: Scalar sqrSum(const oclMat &m)

    :param m: The Source image of all depth

Counts the squared sum of matrix elements for each channel.