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?
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 newReduceTypes:cv::REDUCE_MAX_INDandcv::REDUCE_MIN_IND. As opposed tocv::REDUCE_MAXwhich reduces to the max value,cv::REDUCE_MAX_INDwill reduce the the index of the max value (cv::REDUCE_MIN_INDwill work similarly).(An alternative name might be
cv::REDUCE_MAX_ELEMwhich is consistent with the C++std::max_element())In the
fcn_semsegm.cppexample, the wholecolorizeSegmentation()function could be reduced to areduce(...REDUCE_MAX_IND)andremap(). 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?