views:

233

answers:

1

I am trying to show the hue component of the image from my webcam. I have split apart the image into the hue component but I can't figure out how to show the hue component as the pure colors. For example if one pixel of the image was B=189 G=60 R=60 then in HSV, H=0. I don't want the draw image to be the the gray values of hue but the RGB equivalent of the hue or H=0 -> B=0 G=0 R=255

IplImage *image, *imageHSV, *imageHue;
image = cvQueryFrame(capture); //image from webcam
imageHSV = cvCreateImage( cvGetSize(image), IPL_DEPTH_8U, 3 );
imageHue = cvCreateImage( cvGetSize(image), IPL_DEPTH_8U, 1 );
cvCvtColor( image, imageHSV, CV_BGR2HSV );
cvSplit( imageHSV, imageHue, 0, 0, 0 );

I have a feeling there is a simple solution so any help is appreciated.

+2  A: 

If I understand you correctly, you want to "correctly" visualize just the Hue component. You can create another imageSat and imageVal, one-channel each and filled with 255 (maximum). Then cvMerge your imageHue with the other two, to create a new HSV image, and convert that back to RGB/BGR for final display.

zerm
That works perfectly, thank you! I tried cvMerge before but I guess I never thought to fill each image with the max value.
jhaip
If you don't care for S/V, you don't need to split it, just set them already to maximum.I don't know by heart, but i think cvSetCOI(hsvimg, 2); cvSet(hsvimg, 255); as well as the same for 3 might work already. Dont forget to reset the COI (channel of interest) back to 0 (=no channel, use whole image) when your done.
zerm