Using the result from the previous section, we proceed to determine
which regions can possibly determine a frontal human face. To do so, we
need to determine the number of skin regions in the image.
A skin region is defined as a closed region in the image, which can have 0, 1 or more holes inside it. Its color boundary is represented by pixels with value 1 for binary images. We can also think about it as a set of connected components within an image [2]. All holes in a binary image have pixel value of zero (black).
The process of determining how many regions we have in a binary image is by labeling such regions. A label is an integer value. We used an 8connected neighborhood (i.e., all the neighbors of a pixel) in order to determine the labeling of a pixel. If any of the neighbors had a label, we label the current pixel with that label. If not, then we use a new label. At the end, we count the number of labels and this will be the number of regions in the segmented image.
To separate each of the regions, we scan through the one we are looking
for and we create a new image that will have ones in the positions where
the label we are searching occurs. The others are set to zero. After this,
we iterate through each of the regions found in order to determine if the
region might suggest a frontal human face or not. Figure 7 shows
the segmented skin regions from last section as well as a particular skin
region selected by the system that correspond to the face of the baby image.

E = C  H
where E: is the Euler number
C: The number of connected components
H: The number of holes in a region.
The development tool (Matlab) provides a way to compute the Euler number. For our case, we already set the number of connected components (i.e. the skin region) to 1 since we are considering 1 skin region at a time. The number of holes is, then:
H = 1  E
where H: The number of holes in a region
E: The Euler number.
Once the system has determined that a skin region has more than one
hole inside the region, we proceed to analyze some characteristics in that
particular region. We first create a new image with that particular region
only. The rest is set to black.
where: B is the matrix of size [n x m] representation of the region.
A is the area in pixelsof the region
Note that for this computation, we are also considering the holes that the region has.
The axis will be computed by finding the line for which the sum of the squared distances between region points and the line is minimum. In other words, we compute the leastsquares of a line to the region points in the image [5]. At the end of the process, the angle of inclination (theta) is given by:
where:
and:
First, we fill out the holes that the region might have. This is to
avoid problems when we encounter holes. Since the image is rotated some
angle theta, the need to rotate our region theta degrees so that it is
completely vertical. We now proceed to determine the height and width by
moving 4 pointers: one from the left, right, top and bottom of the image.
If we find a pixel value different from 0, we stop and this is the coordinate
of a boundary. When we have the 4 values, we compute the height by subtracting
the bottom and top values and the width by subtracting the right and the
left values.
The ratio should also have an upper limit. We determined by analyzing the results in our experiments that a good upper limit should be around 1.6. There are some situations however, that we indeed have a human face, but the ratio is higher. This happens when the person has no shirt or is dressed in such a way that part of the neck and below is uncovered. In order to account for this cases, we set the ratio to be 1.6 and eliminate the region below the corresponding height to this ratio.
While the above improves the classification, it can also be a drawback
for cases such as the arms that are very long. If the skin region for the
arms has holes near the top, this might yield into a false classification.


At this point, we have all the required parameters to do the matching
between the part of the image corresponding to the skin region and the
template human face. Template matching is described in the next section.
Next: Template Matching Previous: Skin Segmentation Contents: Face Detection