-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Add support for new type of reduce(): REDUCE_MAX_IND #10286
Description
When working with DNNs, one often gets a vector, matrix or tensor of values where one needs to find the index of the maximal (or minimal) element.
The function cv::reduce() seems perfect for this and should be able to do it, given 2 new ReduceTypes: cv::REDUCE_MAX_IND and cv::REDUCE_MIN_IND. As opposed to cv::REDUCE_MAX which reduces to the max value, cv::REDUCE_MAX_IND will reduce the the index of the max value (cv::REDUCE_MIN_IND will work similarly).
(An alternative name might be cv::REDUCE_MAX_ELEM which is consistent with the C++ std::max_element())
In the fcn_semsegm.cpp example, the whole colorizeSegmentation() function could be reduced to a reduce(...REDUCE_MAX_IND) and remap(). The function is copied and used again in torch_enet.cpp.
Before running off to implement this, I'd like some comments and suggestions on this idea.
Thoughts?