Report 2003

24
Skin Segmentation using MATLAB CONTENTS 1 INTRODUCTION.........................................2 2 IMAGE REPRESENTATION.................................4 3 HUMAN SKIN COLOR MODEL...............................5 4 SKIN SEGMENTATION....................................6 4.1 Binary skin classifiers...........................6 4.1.1 YCbCr.......................................... 6 4.1.2 RGB............................................ 6 4.1.3 HSV1........................................... 7 4.1.4 HSV2........................................... 7 4.1.5 HSI............................................ 8 4.1.6 rgb............................................ 8 4.2 Skin locus........................................ 9 5 SKIN SEGMENTATION ALGORITHM.........................10 5.1 Segmentation Algorithm...........................10 5.1.1 Skin segmentation algorithm using YCbCr model. 10 5.1.2 Skin segmentation using RGB model.............11 6 EXPERIMENT AND RESULTS..............................13 7 APPLICATIONS OF SKIN SEGMENTATION...................15 8 CONCLUSION AND FUTURE WORK..........................16 REFERENCES..................................... 17 Dept of ECE ,SDMCET, Dharwad Page 1

Transcript of Report 2003

Page 1: Report 2003

Skin Segmentation using MATLAB

CONTENTS1 INTRODUCTION..................................................................................................2

2 IMAGE REPRESENTATION...............................................................................4

3 HUMAN SKIN COLOR MODEL.........................................................................5

4 SKIN SEGMENTATION......................................................................................6

4.1 Binary skin classifiers......................................................................................6

4.1.1 YCbCr......................................................................................................6

4.1.2 RGB..........................................................................................................6

4.1.3 HSV1........................................................................................................7

4.1.4 HSV2........................................................................................................7

4.1.5 HSI...........................................................................................................8

4.1.6 rgb............................................................................................................8

4.2 Skin locus........................................................................................................9

5 SKIN SEGMENTATION ALGORITHM...........................................................10

5.1 Segmentation Algorithm...............................................................................10

5.1.1 Skin segmentation algorithm using YCbCr model................................10

5.1.2 Skin segmentation using RGB model....................................................11

6 EXPERIMENT AND RESULTS........................................................................13

7 APPLICATIONS OF SKIN SEGMENTATION.................................................15

8 CONCLUSION AND FUTURE WORK.............................................................16

REFERENCES.....................................................................................................17

Dept of ECE ,SDMCET, Dharwad Page 1

Page 2: Report 2003

Skin Segmentation using MATLAB

1 INTRODUCTION

In recent years, there has been a growing research interest in the problem of

segmenting skin regions in color images. Skin segmentation aims to locate skin

regions in an unconstrained input image. It plays an important role in many computer

vision tasks such as face detection, face tracking, hand segmentation for gesture

analysis, and filtering of objectionable Web images. In these tasks, results of skin

segmentation enable subsequent object detection to focus on reduced skin regions

instead of the entire input image [2]. To this end, skin segmentation is a very effective

tool because skin regions can be located fast with usually minimal amount of added

computation.

Most existing skin segmentation approaches are based on skin color. Skin

regions are detected by looking for pixels that have skin colors. In this mini project,

we propose an algorithm that combines color and edge information to segment skin

regions in color images. The presences of skin colors in the input image are first

detected using a skin color model. The detected skin-colored regions are then refined

using homogeneity property of the human skin.

Many machine vision applications for recognizing people and their activities have been

developed, such as surveillance system, security and control system, human computer

interaction, etc. One important task in those systems is face detection, which is

usually used as a front-end process to detect and localize a human face from images.

Many researchers have proposed various techniques to detect human faces

from images. In YCrCb color space was used to detect faces in the context of video

sequences. A two-dimensional Cr-Cb histogram was employed for separating a facial

region from the back-ground and a region-growing technique was applied on the

remaining area. Finally faces are detected by ellipse matching and using criteria based

on face’s characteristics under a normal illumination condition, the skin color falls into

a small region on the CbCr plane, and the luminance (Y) is uncorrelated with respect

to the CbCr. Thus, a pixel is classified as skin-like if its chrominance value falls into

the small region defined in CbCr plane, and the luminance (Y) falls into the interval

defined empirically [2].

Gaussian models were employed to build the skin color models based on

YCrCb or normalized RGB color spaces . The skin-likelihood image is obtained from

the model and will be a grayscale image whose gray values represent the likelihood of

Dept of ECE ,SDMCET, Dharwad Page 2

Page 3: Report 2003

Skin Segmentation using MATLAB

the pixel belonging to skin. Then, skin regions and non-skin regions are obtained by

thresholding the skin-likelihood image. Faces are detected by computing the ratio of

width and height, and the number of holes representing eyes and mouth inside the

extracted skin regions. The performances of different skin models and different color

spaces (HSV, YCrCb, RGB, normalized RGB, etc) have been studied. Those models

have shown a relative robustness against illumination changes under a limited

condition, and when illumination color is uniform over the face. The skin locus defined

as the range of skin chromaticity’s under varying illumination in normalized RGB

color space was proposed to extract skin color [3].

The drawback of the Gaussian models used in is the high computational time in

calculating the probability of each pixel in the image. The very low computational time

is achieved by a simple method using the skin locus However; the skin locus is camera

dependent. Different camera parameters have different skin loci.

Many different methods for discriminating between skin and non-skin pixels

are available in the literature. These can be grouped in three types of skin modeling:

parametric, nonparametric, and explicit skin cluster definition methods [4]. The

Gaussian parametric models assume that skin color distribution can be modeled by an

elliptical Gaussian joint probability density function. Nonparametric methods estimate

skin color distribution from the histogram of the training data without deriving an

explicit model of skin color model. The simplest, and often applied, methods build

what is called an “explicit skin cluster” classifier which expressly defines the

boundaries of the skin cluster in certain color spaces. The underlying hypothesis of

methods based on explicit skin clustering is that skin pixels exhibit similar color

coordinates in an appropriately chosen color space. These binary methods are very

popular as they are easy to implement and do not require a training phase. The main

difficulty in achieving high skin recognition rates with the smallest possible number of

false positive pixels is that of defining accurate cluster boundaries through simple,

often heuristically chosen decision rules [4].

Dept of ECE ,SDMCET, Dharwad Page 3

Page 4: Report 2003

Skin Segmentation using MATLAB

2 IMAGE REPRESENTATION

There are five types of images.

1. Grayscale: A grayscale image M pixels tall and N pixels wide is represented as a

matrix of double data type of size M×N. Element values (e.g., MyImage(m,n)) denote

the pixel grayscale intensities in [0,1] with 0=black and 1=white[7].

2. Truecolor RGB: A true color red-green-blue (RGB) image is represented as a

three-dimensional M×N×3 double matrix. Each pixel has red, green, blue components

along the third dimension with values in [0,1], for example, the color components of

pixel (m,n) are MyImage(m,n,1) = red, MyImage(m,n,2) = green, MyImage(m,n,3) =

blue [7]

3.Indexed: Indexed (paletted) images are represented with an index matrix of size

M×N and a colormap matrix of size K×3. The colormap holds all colors used in the

image and the index matrix represents the pixels by referring to colors in the

colormap. For example, if the 22nd color is magenta MyColormap(22,:) = [1,0,1],

then MyImage(m,n) = 22 is a magenta-colored pixel [7].

4. Binary: A binary image is represented by an M×N logical matrix where pixel

values are 1 (true) or 0 (false) [7].

5. Uint8: This type uses less memory and some operations compute faster than with

double types. For simplicity, this tutorial does not discuss uint8 further [7].

Grayscale is usually the preferred format for image processing. In cases requiring

color, an RGB color image can be decomposed and handled as three separate

grayscale images. Indexed images must be converted to grayscale or RGB for most

operations.

Dept of ECE ,SDMCET, Dharwad Page 4

Page 5: Report 2003

Skin Segmentation using MATLAB

3 HUMAN SKIN COLOR MODEL

A human skin color model is used to decide if a color is a skin or nonskin color.

Major requirements of a skin color models are listed below [3]:

Very low false rejection rate at low false detection rate:

Skin color detection is first step in skin segmentation; therefore it is imperative

that almost all skin colors are detected while keeping the false detection rate low.

False detections can be handled later when more a priori knowledge about the object

of interest (i.e. face, hand) is available.

Detection of different skin color types:

There are many skin color types, ranging from whitish and yellowish to Blackish

and brownish, which must be all classified in one class, skin color.

Handling of ambiguity between skin and non skin colors:

There are many objects in the environment that have the same color as skin. In

these instances, even a human observer cannot determine if a particular color is from

a skin or nonskin region without taking into account contextual information. An

effective skin color model should address this ambiguity between skin and nonskin

colors.

Robustness to variation in lighting conditions:

Skin color can appear markedly different under different lighting. It is impractical

to construct a skin color model that works under all possible lighting conditions.

However, a good skin color model should exhibit some sort of robustness to

variations in lighting conditions. In our work, we aim to create a skin color model for

typical office lighting and daylight conditions.

Dept of ECE ,SDMCET, Dharwad Page 5

Page 6: Report 2003

Skin Segmentation using MATLAB

4 SKIN SEGMENTATIO N

4.1 Binary skin classifiers

The methods considered in this paper separate skin and non skin colors using a

piecewise linear decision boundary. These explicit skin cluster methods propose a set

of fixed skin thresholds in a given color space. Some color spaces permit searching

skin color pixels in the 2D chromatic space, reducing dependence on lighting variation,

others, such as the RGB space, address the lighting problem by introducing different

rules depending on illumination conditions (uniform daylight, or flash). There are d

different color spaces; They are named for the color space adopted; YCbCr, RGB,

HSV1, HSV2,HSI and rgb . The details of their implementation can be found in the

referenced papers and are summarized in the subsections here below [4].

4.1.1 YCbCr

Chai and Nagan developed an algorithm that exploits the spatial distribution

characteristics of human skin color.A skin color map is derived and used on the

chrominance components of the input image to detect pixels that appear to be skin The

algorithm then employs a set of regularization processes to reinforce those regions of

skin-color pixels that are more likely to belong to the facial regions. We u se only their

color segmentation step here. Working in the YCbCr space the authors find that the

ranges of Cb and Cr most representatives for the skin-color reference map were:

77 ≤ Cb ≤ 127 and 133 ≤ C r ≤ 173

4.1.2 RGB

Kovac et al work within the RGB color space and deal with the illumination

conditions under which the image is captured. Therefore, they classify skin color by

heuristic rules that take into account two different conditions: uniform daylight and

flash or lateral illumination

Uniform daylight illumination:

Dept of ECE ,SDMCET, Dharwad Page 6

Page 7: Report 2003

Skin Segmentation using MATLAB

R > 95 , G > 40 , B > 20

Max {R, G, B} – Min {R, G, B} < 15

|R - G| > 15, R > G, R > B

Flashlight or day light lateral illumination:

R > 220, G > 120, B > 170

|R-G| ≤ 15, B < R, B < G

4.1.3 HSV1

Tsekeridou and Pitas work within the HSV color space and select pixels

having skin-like colors by setting the Following thresholds:

V≥ 40;

0.2 < S < 0.6;

00 < H < 250 or 3350 < H < 3600

The selected range of H restricts segmentation ton reddish colors and the saturation

range selected ensures the exclusion of pure red and very dark red colors, both of

which are caused by small variations in lighting conditions. The threshold on V is

introduced to discard dark colors.

4.1.4 HSV2

Starting from a training data set composed of skin color samples, Garcia and

Tiziritas compute the color histogram in hue-saturation-value (HSV) color space, and

estimate the shape of this skin color subspace. They find a set of planes by successive

adjustments depending on segmentation results, recording the equations shown below

which define the six bounding planes found in the HSV color space case, where H

[1800 1800]

V ≥ 40

H ≤ (-0.4V + 75)

Dept of ECE ,SDMCET, Dharwad Page 7

Page 8: Report 2003

Skin Segmentation using MATLAB

10 ≤ S ≤ (-H-0.1V+110)

If H > 0 S ≤ (0.08(100-V)H+0.5V)

If H< 0 S ≤ (0.5 ≤ (0.5H+35)

4.1.5 HSI

Hsieh et al use the HSI color space system to design their color classification

algorithm because it is stable for skin colour under different lighting conditions.

These rules apply to the intensity I, hue H and saturation S, and are detailed as follows

I > 40

00 < H < 280 and 3320 < H < 3600

3090 < H < 3310

The thresholds are empirically determined from the training set and the color

system transformation from RGB to HSI is defined as follows

I1= 1/3(R+G+B); I2=1/2(R-B); I3=1/4(2G-R-B);

H=

4.1.6 rgb

Gomez and Morales use a constructive induction approach to determine the

skin map. Starting with the three rgb components in a normalized form and a simple

set of arithmetic operators, the authors produce a model for skin detection. The

algorithm uses a Restricted Covering Algorithm (RCA) as its selective learner. The

RCA searches for single rules in parallel. Among the different combination rules

presented by the authors, we have chosen the one with the highest precision and

success rate:

>1.185, r.b/(r+g+b)2 > 0.107 and r.g/(r+g+b)2 > 0.112

Dept of ECE ,SDMCET, Dharwad Page 8

Page 9: Report 2003

Skin Segmentation using MATLAB

Where rgb are the normalized coordinates obtained as;

r = g = b =

4.2 Skin locus

Color distribution of human skin from various countries has been investigated in

[16], which is a shell-shaped area in the r-g color space (normalized RGB color space)

that is called as skin locus, where r = and g = They proposed a physical

based model of skin color that can be used to detect skin color, when the spectrum of

the light source and the camera characteristics are known [5].

we employed a skin color distribution obtained empirically to develop the skin

locus in the r-g color space. The upper and lower bounds of the skin locus are

quadratic functions, which the quadratics coefficients are found using least square

estimation of the sampled points on the boundaries. In [5], the upper bound quadratic

function is g = -1.367 r2 +1.0743r + 0.1452, while the lower bound quadratic function

is g = -0.776r2 + 0.5601r +0.1766

Dept of ECE ,SDMCET, Dharwad Page 9

Page 10: Report 2003

Skin Segmentation using MATLAB

5 SKIN SEGMENTATION ALGORITHM

Skin detection has been performed pixel-wise and used only the color

information of individual pixels. Experimental results in Section 4 indicate that the

cluster methods of skin color models are very accurate in detecting skin colors.

However, pixel-wise color segmentation is not sufficient for skin detection purpose

because pixels in the image background (ie. nonskin pixels) may also have skin colors

and this leads to false detection. Another issue is that the true skin regions may be

blended with the nearby skin-colored background, and this can have an adverse effect

on subsequent processing of skin regions [5]. There is a clear need to reduce the

amount of false detections and to separate true skin regions from possible false

detection.

5.1 Segmentation Algorithm

5.1.1 Skin segmentation algorithm using YCbCr model

The steps of the proposed skin segmentation algorithm are described below.

Steps 1-2 are for skin color detection, Step 3-4 are for skin segmentation using edge

and color. Step 5-6 are post-processing.

Step-1: Read color human image.

Step-2: convert the image to YCbCr color space.

YCbCr map = rgb2ycbcr (map) converts the RGB values in map to the YCbCr

color space.map must be an M-by-3 array. YCbCr map is an M-by-3 matrix that

contains the YCbCr luminance (Y) and chrominance (Cb and Cr) color values as

columns. Each row in ycbcfmap represents the equivalent color to the corresponding

row in the RGB color map, map.

YCBCR = rgb2ycbcr (RGB) converts the true color image RGB to the equivalent

image in the YCbCr color space. RGB must be an M-by-N-by-3 array.

Step-3: Classify the colors in color space models using by using tresholding

Step-4: The resulted image is a clustered image.

Step-5: Label every pixel in the image using the results from color models.

Dept of ECE ,SDMCET, Dharwad Page 10

Page 11: Report 2003

Skin Segmentation using MATLAB

Step-6: Convert the image back to rgb color space and show the skin segmented

image

If the input is uint8, YCBCR is uint8, where Y is in the range [16 235], and Cb

and Cr are in the range [16 240]. If the input is a double, Y is in the range [16/255

235/255] and Cb and Cr are in the range [16/255 240/255]. If the input is uint16, Y is

in the range [4112 60395] and Cb and Cr are in the range [4112 61680] [7].

rgbmap = ycbcr2rgb(ycbcrmap) converts the YCbCr values in the colormap

ycbcrmap to the RGB color space. If ycbcrmap is M-by-3 and contains the YCbCr

luminance (Y) and chrominance (Cb and Cr) color values as columns, rgbmap is

returned as an M-by-3 matrix that contains the red, green, and blue values equivalent

to those colors.

RGB = ycbcr2rgb(YCBCR) converts the YCbCr image YCBCR to the

equivalent true color image RGB.

5.1.2 Skin segmentation using RGB model

In the second approach we have used RGB color space model to

identify the skin regions. The steps are as follows

Step-1: Read the image

Step-2: Separate the color indexed image into its RGB components

Step-3: Convert the RGB matrices into a gray-scale intensity image

Step-4: R, G, B is classified as skin if:

R > 95 and G > 40 and B > 20 and

(Max{R, G, B} - min{R, G, B}) > 15 and

|R-G| > 15 and R > G and R > B

The select region is the skin region. By this we obtain the result.

An RGB image, sometimes referred to as a true color image, is stored as an m-by-

n-by-3 data array that defines red, green, and blue color components for each

Dept of ECE ,SDMCET, Dharwad Page 11

Page 12: Report 2003

Skin Segmentation using MATLAB

individual pixel. RGB images do not use a palette. The color of each pixel is

determined by the combination of the red, green, and blue intensities stored in each

color plane at the pixel's location. Graphics file formats store RGB images as 24-bit

images, where the red, green, and blue components are 8 bits each. This yields a

potential of 16 million colors. The precision with which a real-life image can be

replicated has led to the nickname "true color image."

Dept of ECE ,SDMCET, Dharwad Page 12

Page 13: Report 2003

Skin Segmentation using MATLAB

6 EXPERIMENT AND RESULTS

This algorithm was applied on a variety of Images. Around 50 images are

tested. The Algorithm was implemented in MATLAB.7. The outputs were compared

pixel-wise with the manually segmented skin images.

.

Fig-1: Input image Fig-2: Skin Segmented image

The figure-1 shows the input image and figure-2 shows the skin segmented image by

using the first approach of segmentation algorithm as discussed section [5.1.1].

Dept of ECE ,SDMCET, Dharwad Page 13

Page 14: Report 2003

Skin Segmentation using MATLAB

Fig-3 Input image Fig-4 Skin segmented image

The figure-3 shows the original input image and figure-4 shows the skin segmented

image using the second approach as discussed in section [5.1.2].

Dept of ECE ,SDMCET, Dharwad Page 14

Page 15: Report 2003

Skin Segmentation using MATLAB

7 APPLICATIONS OF SKIN SEGMENTATION

Person Detection

Face Detection and Face Tracking

Hand Tracking for

Gesture Recognition

Other Human Computer Interaction

A filter for pornographic content on the internet

Other uses in video applications

Dept of ECE ,SDMCET, Dharwad Page 15

Page 16: Report 2003

Skin Segmentation using MATLAB

8 CONCLUSION AND FUTURE WORK

In our work, a segmentation algorithm for face detection in color images was

proposed. We have presented a novel skin color model, rgb2YCrCb and RGB to

detect human faces. Skin region segmentation was performed using a combination

of RGB, and YCbCr subspaces, which demonstrated evident discrimination

between skin and non-skin regions. The experimental results showed that our new

approach in modeling skin color was able to achieve a good detection success rate. The

algorithm gives computationally a very efficient as well as quite an accurate approach

for skin detection which may be applied in real time.

In future works, we will improve our method for detecting multiple faces under

various orientations, incorporate video images for face detection and tracking to

increase the performance, and implement our method in to the real hardware system

Dept of ECE ,SDMCET, Dharwad Page 16

Page 17: Report 2003

Skin Segmentation using MATLAB

REFERENCES

[1] M.-H. Yang, D. Kriegman, and N. Ahuja, “Detecting Faces in Images: A

Survey”, IEEE Trans. PAMI Vol. 24

[2] R. L. Hsu, M. A. Mottaleb, and A. K. Jain. Face detection in color images. IEEE

Trans. Pattern Analysis and Machine Intell., 24:696–706, 2002.

[3] D. Chai and K. N. Ngan, "Face segmentation using skin color map in videophone

applications," IEEE Trans. CCVT,vol. 9, no. 4, pp. 551-564, 1999

[4] C. Garcia and G. Tziritas, "Face detection using quantized skin color regions

merging and wavelet packet analysis,"IEEE Trans. on Multimedia, vol. 1, no. 3, pp.

264-277,1999.

[5] P. Viola and M. Jones, “Rapid Object Detection Using a Boosted Cascade of

Simple Features”, IEEE Conf. CVPR, Vol. 1, pp. 511-518, 2001.

[6]http://www.visualstatistics.net/VisualStatistics/Multimedia/

correlation_assumtions.htm

[7] R. C. Gonzalez and R E Woods , “Digital Image Processing” 2nd edition, Pearson

education(Asia) Prentice Hall of India,2004

[8] K.Jain, ”Fundamentals of Digital Image Processing” Pearson Education(Asia)

Prentice Hall of India, 2004

Dept of ECE ,SDMCET, Dharwad Page 17