[][src]Function opencv::cudaarithm::reduce

pub fn reduce(
    mtx: &dyn ToInputArray,
    vec: &mut dyn ToOutputArray,
    dim: i32,
    reduce_op: i32,
    dtype: i32,
    stream: &mut Stream
) -> Result<()>

Reduces a matrix to a vector.

Parameters

  • mtx: Source 2D matrix.
  • vec: Destination vector. Its size and type is defined by dim and dtype parameters.
  • 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.
  • 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.
  • 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()) .
  • stream: Stream for the asynchronous version.

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.

See also

reduce

C++ default parameters

  • dtype: -1
  • stream: Stream::Null()