I trying to do skin color detection in Opencv.
1) First i converted the image into HSV from RGB
cvCvtColor(frame, hsv, CV_BGR2HSV);
2) Than i had applied skin color threshold in the HSV image
cvInRangeS(hsv, hsv_min, hsv_max, mask); // hsv_min & hsv_max are the value for skin detection
3) So it generates the mash which has only skin color but in Black & white image, so i converted that image in to RGB
cvCvtColor(mask, temp, CV_GRAY2RGB);
4) so now i want the skin color in only RGB value.
for(c = 0; c < frame -> height; c++) {
uchar* ptr = (uchar*) ((frame->imageData) + (c * frame->widthStep));
uchar* ptr2 = (uchar*) ((temp->imageData) + (c * temp->widthStep));
for(d = 0; d < frame -> width; d++) {
if(ptr2[3*d+0] != 255 && ptr2[3*d+1] != 255 && ptr2[3*d+2] != 255 && ptr2[3*d+3] != 255 ){
ptr[3 * d + 0] = 0;
ptr[3 * d + 1] = 0;
ptr[3 * d + 2] = 0;
ptr[3 * d + 3] = 0;
}
}
}
now i am not getting the image that i want actually that has only skin color in RGB.
Any Solution,
Thanks

1st Original Image 2nd Skin Detected Image in Black & White 3rd Output (Not Actual)