At the forefront of Artificial Intelligence
  Home Articles Reviews Interviews JDK Glossary Features Discussion Search
Home » Articles » Machine Vision » Skin Detection

Messing with Skin Recognition

Last Updated: 4th December, 2001

I was a little bored today, so I experimented with something I'd had kicking around for a while: skin and face recognition. I had read an interesting paper by J. Kapur (the paper has been removed since I wrote this TechFile) on the topic (that was based on another by M. Fleick), so I thought I'd give it a try and modifed ED256 accordingly.

I cut quite a few corners because I didn't want to hack the ED256 code up too much, but this was my basic algorithm. I first converted the RGB image into a logarthmic-opponent (IRgBy) format. The formula for this is:

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

L(x) = 105 * log10(x+1)
Now, I started cutting some large corners. With M.Fleick's formula, she calculates the hue and saturation and a texture map. The texture map denotes how "textured" a certain area is, since skin is generally untextured, this is a very useful property. What I did, though, was skip all of this, and merely calculate the hue of the image:
hue = atan2(Rg,By) * (180 / 3.141592654f)
I then ran the hue through a kth-order ring filter (trust me, a lot simpler than it sounds!) and ANDed it with the original image - it produced some fairly decent effects.

Images

The first one is Tiger Woods, and he came out very well. Picked up his face and the revealed skin above his wrists. It managed to get rid of everything else perfectly, including the cap. This was the example image used in the Kapur's paper. For those of you that saw this TechFile earlier, I'd also tested it with a Britney Spears picture and a picture of a friend of mine.

Tiger Woods

All in all, for a relatively simple algorithm, I think it did quite well. Fleick talks about a two-pass filter, and like I mentioned earlier she uses a much more complicated algorithm than I do. I plan on rewriting ED256 pretty soon making it much more efficient, and easier for me to do things like this (perhaps mess with a plug-in system, but I doubt it)...so perhaps when I do this, I'll completely implement her algorithm (or a derivative thereof).

Addendum

I've found that the algorithm I've described above allows green through, which is a bit of a problem! Nevertheless, some additional tweaks should allow this to also be filtered out. Note that the skin filter algorithm described here has been implemented in Image Analysis Explorer.

Skin Detection using Video

I thought I'd try using this algorithm with my Logitech QuickCam by accessing the video stream (see AISolutions article). For this, I found the best way to do it was to calculate the hue and the saturation, and create a "mask" to AND with the source video data. The bounds that Fleick puts on the saturation, hue and texture amplitude (the I part of IRgBy). With my camera and my surroundings (I sit in front of a skin-coloured wooden wardrobe, with a window to my immediate right), I found that saturation didn't play a major part in filtering out the information. I found the following to work:
    if (I <= 5 && (hue >= 4 && hue <= 255)) {
        r = 255;
    } else {
        r = 0;
    }
Where r is the BYTE that governs the mask value, a value of 255 means the area is (apparently) skin. Below are two screenshots I took, one from the LEGO Cam before the filter is applied, the second is after the filter is applied.

Note how the natural light from the right (on the left in the picture) has caused the program to blot out right-hand portions of my hand. The most obvious fault with this is that it picks up the wardrobe behind me, but it is fairly skin coloured, and it blotted out the pictures and CDs that are stuck on it.

Submitted: 15/04/2001

Article content copyright © James Matthews, 2001.
 Article Toolbar
Print
BibTeX entry

See Also
- Image Analysis Explorer Pro
External Links
- Naked People Skin Filter
- Face Detection Homepage

Search

Latest News
- Generation5 10-year Anniversary (03/09/2008)
- New Generation5 Design! (09/04/2007)
- Happy New Year 2007 (02/01/2007)
- Where has Generation5 Gone?! (04/11/2005)
- NeuroEvolving Robotic Operatives (NERO) (25/06/2005)

What's New?
- Back-propagation using the Generation5 JDK (07/04/2008)
- Hough Transforms (02/01/2008)
- Kohonen-based Image Analysis using the Generation5 JDK (11/12/2007)
- Modelling Bacterium using the JDK (19/03/2007)
- Modelling Bacterium using the JDK (19/03/2007)


All content copyright © 1998-2007, Generation5 unless otherwise noted.
- Privacy Policy - Legal - Terms of Use -