-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
suboptimal cv::applyColorMap(...) with cv::ColorMap::operator()(...) #21640
Copy link
Copy link
Closed
Description
OpenCV 4.*
When using cv::applyColorMap(InputArray src, OutputArray dst, InputArray userColor), the cv::ColorMap::operator()(...) will be called
Unfortunately, the design of this operator along with the cv::LUT() usage will always perform one or two full clones of src:
// Turn into a BGR matrix into its grayscale representation.
if(src.type() == CV_8UC3)
cvtColor(src.clone(), src, COLOR_BGR2GRAY);
cvtColor(src.clone(), src, COLOR_GRAY2BGR);
// Apply the ColorMap.
LUT(src, _lut, _dst);
This is unfortunate, because in most cases src is a 8UC1 , and whatever userColor type, the operation to perform is just dst[i] = userColor[src[i]], and would not require any intermediate cv::Mat() allocation
Reactions are currently unavailable