### Navigation

- index
- next |
- previous |
- OpenCV 2.4.6.1 documentation »
- OpenCV API Reference »
- ocl. OpenCL-accelerated Computer Vision »

# Matrix Reductions

## ocl::countNonZero

Returns the number of non-zero elements in src

C++:`` int `ocl::``countNonZero`(const oclMat& src)

  Parameters:

  - src – Single-channel array

Counts non-zero array elements.

## ocl::minMax

Returns void

C++:`` void `ocl::``minMax`(const oclMat& src, double* minVal, double* maxVal=0, const oclMat& mask=oclMat())

  Parameters:

  - src – Single-channel array
  - minVal – Pointer to returned minimum value, should not be NULL
  - maxVal – Pointer to returned maximum value, should not be NULL
  - 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

C++:`` void `ocl::``minMaxLoc`(const oclMat& src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, const oclMat& mask=oclMat())

  Parameters:

  - src – Single-channel array
  - minVal – Pointer to returned minimum value, should not be NULL
  - maxVal – Pointer to returned maximum value, should not be NULL
  - minLoc – Pointer to returned minimum location (in 2D case), should not be NULL
  - maxLoc – Pointer to returned maximum location (in 2D case) should not be NULL
  - 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

C++:`` Scalar `ocl::``sum`(const oclMat& m)

  Parameters:

  - 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

C++:`` Scalar `ocl::``sqrSum`(const oclMat& m)

  Parameters:

  - m – The Source image of all depth

Counts the squared sum of matrix elements for each channel.

## Help and Feedback

You did not find what you were looking for?

- Ask a question on the Q&A forum.
- If you think something is missing or wrong in the documentation, please file a bug report.

### Navigation

- index
- next |
- previous |
- OpenCV 2.4.6.1 documentation »
- OpenCV API Reference »
- ocl. OpenCL-accelerated Computer Vision »