I need to change the hue of some pixels of my image, but i don't know how to set them!
I converted the image in HSV with CV_BGR2HSV
and now i'm cycling with a for by rows and cols...
how can I access each pixel's hue?
for setting RGB i'm using this code...
CvScalar s;
s=cvGet2D(imgRGB,i,j); // get the (i,j) pixel value
printf("B=%f, G=%f, R=%f\n",s.val[0],s.val[1],s.val[2]);
s.val[0]=240;
s.val[1]=100;
s.val[2]=100;
cvSet2D(imgRGB,i,j,s); // set the (i,j) pixel value
You already converted your image to HSV, so the 3 layers of the image now correspond to Hue, Saturation and Value:
s.val[0]
is the hue.s.val[1]
is the saturation.s.val[2]
is the value.So go ahead and use exactly the same method as for your RGB images to get and set the pixel values.