pub fn min_max_loc_sparse(
a: &impl SparseMatTraitConst,
min_val: Option<&mut f64>,
max_val: Option<&mut f64>,
min_idx: Option<&mut i32>,
max_idx: Option<&mut i32>,
) -> Result<()>
Expand description
Finds the global minimum and maximum in an array.
The function cv::minMaxLoc finds the minimum and maximum element values and their positions. The extrema are searched across the whole array or, if mask is not an empty array, in the specified array region.
In C++, if the input is multi-channel, you should omit the minLoc, maxLoc, and mask arguments (i.e. leave them as NULL, NULL, and noArray() respectively). These arguments are not supported for multi-channel input arrays. If working with multi-channel input and you need the minLoc, maxLoc, or mask arguments, then use Mat::reshape first to reinterpret the array as single-channel. Alternatively, you can extract the particular channel using either extractImageCOI, mixChannels, or split.
In Python, multi-channel input is not supported at all due to a limitation in the binding generation process (there is no way to set minLoc and maxLoc to NULL). A workaround is to operate on each channel individually or to use NumPy to achieve the same functionality.
§Parameters
- src: input single-channel array.
- minVal: pointer to the returned minimum value; NULL is used if not required.
- maxVal: pointer to the returned maximum value; NULL is used if not required.
- minLoc: pointer to the returned minimum location (in 2D case); NULL is used if not required.
- maxLoc: pointer to the returned maximum location (in 2D case); NULL is used if not required.
- mask: optional mask used to select a sub-array.
§See also
max, min, reduceArgMin, reduceArgMax, compare, inRange, extractImageCOI, mixChannels, split, Mat::reshape
§Overloaded parameters
- a: input single-channel array.
- minVal: pointer to the returned minimum value; NULL is used if not required.
- maxVal: pointer to the returned maximum value; NULL is used if not required.
- minIdx: pointer to the returned minimum location (in nD case); NULL is used if not required; Otherwise, it must point to an array of src.dims elements, the coordinates of the minimum element in each dimension are stored there sequentially.
- maxIdx: pointer to the returned maximum location (in nD case). NULL is used if not required.
§C++ default parameters
- min_idx: 0
- max_idx: 0