Click here to Skip to main content
15,881,882 members
Articles / Programming Languages / C#
Article

Skin Recognition in C#

Rate me:
Please Sign up or sign in to vote.
2.86/5 (35 votes)
28 Aug 20041 min read 94.4K   3.6K   50   5
Skin Recognition in C#.

Sample Image - Skin_RecC_.jpg

Introduction

     This article is based on a project I started this summer. Originally the project was a simple edge detection system, but now its turning into a face recognition system.

The first thing that I did done when implementing a skin filter is to convert from RGB color space

to IRgBy color space by using this formula:

I = [L(R) + L(B) + L(G)] / 3
Rg = L(R) - L(G)
By = L(B) - [L(G) +L(R)] / 2

where L is a logarithmic function.

The next thing is to find out the hue, by using this formula:
hue = atan2(Rg,By) * (180 / 3.141592654f)

if (I <= 5 && (hue >= 4 && hue <= 255))
{
     //skin
}
else
{
     /*not skin color it black*/
     modified.SetPixel(x, y, Color.Black);
}
 

 

An example of how you would call the method Vision.DetectSkin(Bitmap original, ref Bitmap modified)

Bitmap original = new Bitmap(@"C:\mypicture.bmp");
Bitmap modified = original;
Vision.DetectSkin(original, ref modified);
//now if you save modified and the look at it you will see that it 
//detected all the skin from the original image

As you can see from the picture the algorithm isn't perfect yet and it needs some touching up.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalask about a manuscript (old document) recognition algorithm Pin
Sitti Rachmawati Yahya22-May-08 12:08
Sitti Rachmawati Yahya22-May-08 12:08 
Generalrecognition Pin
amir mortazavi26-Jan-05 23:34
amir mortazavi26-Jan-05 23:34 
GeneralI would have waited Pin
Richard Parsons30-Aug-04 11:51
Richard Parsons30-Aug-04 11:51 
Sorry for the low rating but I would have waited to release this until the algorithm was more accurate.
GeneralReferences Pin
Steven Campbell30-Aug-04 10:43
Steven Campbell30-Aug-04 10:43 
GeneralRe: References Pin
rajpatil22-Sep-05 10:10
rajpatil22-Sep-05 10:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.