Is there something like a MATLAB color bar for OpenCV?

I am writing a C ++ application using the OpenCV 3.0 library. I play with the colormap function, but I would like to add a color panel (see the example below from MATLAB) to the image window. Even if it is on the side / external, thus, the user has an idea of โ€‹โ€‹the range. Any suggestions? Thanks in advance!

Colorbar Example from MATLAB

+4
source share
1 answer

If you want to draw the panel on the right separately, this might work for you:

/*Aim:- Generate a 20x255 colorbar starting at point (200,50)*/
int b=0,g=255,r=255;//start at yellow
int y=50;//start at y=50, then increment
while(g>0)//run till green color reaches 0
{
  b++;
  g--;
  r--;//gradually convert yellow to blue
  y++;
  Scalar color=Scalar(b,g,r);
  rectangle(img,Point(200,y),Point(220,y+1),color,1);
}

Let me know if this gives the expected result.

0
source

All Articles