Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Ok, here is a small pseudocode (almost runnable) to start with:

void createPalette(uchar lowerb,uchar upperb)
{
    Mat palette(100,180,CV_8UC3);
    for each pixel (x,y) in palette {
        if((x>lowerb)&&(x<upperb))active=255 else active=0;
       // for each pixel: hue=x, saturation=max, luminosity=0 (black) if the pixel is inactive
        palette.at<Vec3b>(y,x)=Vec3b(x,255,active); 
    }
    Mat paletteRGB;
    cvtColor(palette,paletteRGB,COLOR_HSV2RGB)
    imshow("Palette",paletteRGB);
}

To create the color palette, it's best to create it in the HSV space, then transform it to RGB. The Value channel can be used to simulate the thresholding (set the masked pixels to black).

You can modulate the saturation on the Y axis.