thygate labs


The skin detection algorithm is very simple.
I read about it in a hackaday article about an FPGA Real time video anonymizer project.

It considers a pixel is skin if 50 < R - G < 250, where R and G are the red and green channels from a 8-bit RGB pixel representation. Since the algorithm is based on the difference between R and G and not their absolute values, it does a pretty good job of detecting skin of various shades.

Surprised by the simplicity of this algorithm, and wanting to see it in action myself I decided to try to implement it in GLSL, which seems perfect for the task.

There already is an excellent javascript image effects library powered by WebGL, glfx.js. I cloned the existing hueSaturation GLSL shader and split it up into two sections based on the skin detection algorithm, so it has 2 different sets of hue and saturation parameters, one for pixels identified as skin, and one for pixels identified as background. An optional denoise second-pass is added to clean up the hard edges. Being able to set different hue and saturation parameters for skin and background will allow us to clearly test the algorithm's performance.

I continued to tweak the values and added the additional requirements of B < G and a minimal G value to further reduce false-positives. However, often I was able to get acceptable performace by tweaking only the initial requirements for a specific scene.

In conclusion, the algorithm seems to perform pretty well in most of the test cases I was able to throw at it, but it is by no means perfect. It can probably be used with reasonable reliability when deployed under controlled and optimal lighting conditions.

I encourage you to play with it and evaluate it by trying it out yourself using the LIVE VIDEO INPUT. Be sure to share your results and findings here

2015 November 30, Bob Thiry (