How Set a ColorBar for the ColorMap C++?

Hello, how to create a colorbar for a colormap? I have a grayscale image 16bit, and Iapplied the colormap jet to it. But there is no colorbar to correlate the image to the color.
I would like to create a colorbar ranging from the min value to the max value of my grayscale, for instance, 0 to 700.

I have see a code that create the colorbar ranging from 0-255, but this do not give us any relevant information about real image intensity which is 16 bit.

@tim Could you help me with this? :slight_smile:

You might consider using a combination of std::iota and cv::applyColormap, something like this (NOTE: untested example) and then use it to coordinate intensity to color:

static cv::Mat colorMat;
if(colorMat.empty()){
std::vector < uchar> _colors(255*255);
std::iota(_colors.begin(), _colors.end(), 0);
}
cv::applyColorMap(cv::Mat(_colors), colorMat, cv::COLORMAP_RAINBOW);