How to do it...

Go through the following steps to segment the skins using scikit-learn's GaussianMixture:

  1. Read the training dataset that you downloaded as a pandas DataFrame:
df = pd.read_csv('images/Skin_NonSkin.txt', header=None, delim_whitespace=True)df.columns = ['B', 'G', 'R', 'skin']

The next screenshot shows what the first few rows of the data look like:

  1. Plot the distribution of the RGB values for skin and nonskin examples separately, using boxplot:
g = sns.factorplot(data=pd.melt(df, id_vars='skin'), \    x='variable', y='value', hue='variable', col='skin', \    kind='box', palette=sns.color_palette("hls", 3)[::-1])

If you ...

Get Python Image Processing Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.