3. LabExercise: Skin Color Detection¶
The learning set is collection of images. Each color image in the set
is of shape MxNx3 with an 8 bit RGB encoding. Please use the
scipy.ndimage.imread
function so the image dtype
is
uint8
.
For each color image also a mask image is available of shape MxNx4. The added ‘color’ component is a transparancy mask and is set to 255 (fully transparant) for all pixels. The RGB color is (0,0,0) for non skin pixels, and (255,255,255) for all skin pixels.
The matplotlib imshow
function knows how to deal with
transparancies in RGBa images. You can do two consecutive imshow
’s
and you get a nice overlay.
The set is organized in 4 directories:
- FacePhoto (face images)
- GroundT_FacePhoto (mask images, the file names are the same as in FacePhoto directory)
- FamilyPhoto
- GroundT_FamilyPhoto (mask images, the file names are the same as in FamilyPhoto directory)
A zip file containing these 4 directories is
SkinColor.zip
.
The following code read an image and its corresponding mask and displays both of them:
In [1]: from scipy.ndimage import imread
In [2]: f = imread('python/data/SkinColor/FacePhoto/0520962400.jpg')
In [3]: m = imread('python/data/SkinColor/GroundT_FacePhoto/0520962400.png')
In [4]: plt.subplot(121)