SimpleCV And Face Mask Extraction

Recently,by accident more than anything else, I stumbled upon a brilliant python module for Image Processing.  SimpleCV . As with all python modules, the ease of usage is unparalleled, even by the Matlab IP Toolkit.The Speed on the other hand is not as good as that of OpenCV but it is much faster than Matlab. For a more detailed comparison between the 3, you could read the blog article by one of the developers of SimpleCV, where he compares OpenCV,Matlab and SimpleCV on various parameters. As far as I could find out, SimpleCV uses the OpenCV library but has made it much more user friendly , now that it is in Python.

To install SimpleCV, type in the following commands in your shell

sudo apt-get install libopencv-*
sudo apt-get isntall python-opencv
sudo apt-get install python-numpy

sudo apt-get install python-pygame
sudo apt-get install python-setuptools

Go ahead and downlaod and extract the latest version of SimpleCV from Github .Change Directory (cd) into the extracted folder and run the script

sudo python install


My first SimpleCV program. It basically loads the image, finds the skin tone mask and thersholds the image to produce a B/W image with the mask values as TRUE. That is followed by erode and dilate to remove unwanted blobs. The final step is to show the output image.

from SimpleCV import *        # Use this instead of import SimpleCV.
                              #import SimpleCV doesn't work properly .
                              #This though imports all functionalities of
                              #the module.

img = Image("040001.jpg")                     # Loads the image.

img = img.getSkintoneMask(0)       # Gets the Skin Tone Mask and does the Threshold.

                                # PostProcessing,Noise Removal

img = img.erode(6)                             # Removes the stray bolbs
img = img.dilate(3)                            # Increases the size of face blob'window')                              # Final Image Output

Below are a few input and output images.The great thing is unlikeOpenCV and Matlab, since mask extraction is automated here,you don’t need to worry too much about the threshold values, or converting to HSV etc etc.And hence the results are better.


About ranjanritesh

I am currently working as a Software Engineer for Cisco Systems India in Bangalore. I’ve been working for Cisco since August 2013. I am a BITS Goa Alumni. I earned my Bachelors in Electronics and Instrumentation in August 2013 from there. My interests include Image Processing, Systems Programming and hacking on the Linux Kernel. I also like tinker a bit with Arduino and other microcontrollers.
This entry was posted in Blob Detection, Open Source, OpenCV, Python, SimpleCV, Tutorial and tagged , , , , , , . Bookmark the permalink.

5 Responses to SimpleCV And Face Mask Extraction

  1. jayrambhia says:

    Great post. and you know this getSkinTone() was just implemented in SimpleCV couple of weeks ago. Vijay Mahantesh has been working on it. and it’s good to see a fellow BITSian (Goa) working with SimpleCV. If you stuck at any point in SimpleCV, there’s a good SimpleCV forum.


  2. Pingback: Issues While Installing SimpleCV « bytesandlogics

  3. Rosetta says:

    Pretty! This has been a really wonderful article. Thanks for
    providing this information.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s