skin segmentation


can someone help me or give-me some advice in making a skin segmentation on a image.

Thank you

Could you post some more details on exactly what you mean by “skin segmentation”, or an example image of what you’re trying to accomplish?

If you’re looking for tracking skin, there are a number of posts about “color tracking” you should check out.

Hi !
I had good results with this method:
convert PImage to an opencv Colorimage
convert to HSV
search for REDs and build a gray Image

search for faces with Facedetection
calculate the averarge HSV-values from found faces

greetings ascorbin



by skin segmentation i’m refering to skin tracking.
but the problem is that i’m not searching for a specific color, its about skin or a probability to be skin, because i’m trying to do a hand tracker without calibration.

i’m not trying to find faces but hands, the main point is to find hands and their signs (fingers).

i found some skin classifier rules with pixel based skin detection and the simpliest i found was :

(R, G, B) is classified as skin if:
R > 95 and G > 40 and B > 20 and
max{R, G, B} − min{R, G, B} > 15 and
|R − G| > 15 and R > G and R > B

there is a simplier way to do this?

Thank you

Hi outdoors,
I think handtracking is one of the hardest things and theres no simple solution at the moment. Im working on this topic since a year and tried combinations of color tracking, blob tracking, feature tracking, optical flow, adaptive background learning, and so on. I dont know a really stable solution yet…:?
have you tried HandVu ?

hey ascorbin,

handu have the main problem that you have to calibrate it for your hand and the point that i want to achieve is to be general or at least have a good true detection rate.

well about color i have some result with the formula that i showed before, but it seems that i losing some component from the original image.

i’m doing a treshold and then for each pixel that is non black i get the pixel in my original image like this:

colorAlphaImg = new unsigned char[320 * 240*3];
for (int i = 0; i < 320*240; i++){


colorAlphaImg[i\*3+0] = zonaInteresse[i\*3+0];
colorAlphaImg[i\*3+1] = zonaInteresse[i\*3+1];
colorAlphaImg[i\*3+2] = zonaInteresse[i\*3+2];

i think i’m losing the alpha component. i will try to upload some images to show what i mean.

Thank you.

you know: camera, light and skin color can vary a lot, because of day/night/sun/lamps and so on, so i used my face just as a color picker

this is my image after some operations

can you give-me some advice to make the countourn of the hand
because i cant figure it out… in your image you have just the thing i want to acomplish.

as you can see my skin classifier is not perffect but it is a pretty good start :slight_smile:

Thank you

here is my code, inmho HSV gives definetly the better result, you need to include ofxopencv for this operations

// feed the blobfinder  
		camImg_hsv = camImg;  
		unsigned char* pixels = camImg_hsv.getPixels();  
		min_h = facetrack_thread.min_h;  
		max_h = facetrack_thread.max_h;  
		min_s = facetrack_thread.min_s;  
		max_s = facetrack_thread.max_s;  
		min_v = facetrack_thread.min_v;  
		max_v = facetrack_thread.max_v;  
		for(int i=0; i<track_width*track_height/2; i++) {  
			int p_h = pixels[i*3] + 90;  
			if( p_h >= 180) p_h -= 180;  
			bool good_h = p_h >= min_h && p_h <= max_h;  
			bool good_s = pixels[i*3+1] >= min_s && pixels[i*3+1] <= max_s;  
			bool good_v = pixels[i*3+2] >= min_v && pixels[i*3+2] <= max_v;  
			if(good_h && good_s && good_v) search_pixels[i] = 255; else search_pixels[i] = 0;  
		searchImg = search_pixels;  
		contourFinder.findContours(searchImg, min_searchsize, max_searchsize, 100, false);  

hum… i’m already using ofxOpenCv
i tried to use the contourFinder but it doesnt draw the countour, instead it draw the bounding box.

what do you mean by inmho Hsv?
but for inmho Hsv i have to know the color of skin that i’m searching.

hm, the contourfinder should draw bounding box AND contour. inmho should mean in my humble opinion or so, i think its correctly written as IMHO, just a thing like ROFL…egal
for the HSV val try searching around H = 0 ±10 (in my code H=90±10), S > 20, V > 20


about countour it was some bug, i just copied from another example and it works. so now… i back to color, because my contourn gives me my arm also.

i have been i great help :slight_smile:

do you know some aprouch to count the fingers?

Thank you

well… for the fingers you basically have to search your contour for spikes. find your own math function or ->
havent tried this


thank you for you help :slight_smile: