CS585: Image and Video Computing

HW1: Face Detection

 

Benjamin Ring

03 FEB 2006

 

 

Instructions for Use

 

Source:

            Face.java

            Interface.java

            ImageFunct.java

            Vect.java

 

1. Skin Color Observations

2. Face Detection Algorithm

3. Results

4. Discussion & Conclusion

 

 

NOTE: The Program Applet should launch as a separate window upon loading this page. See instructions for more details.

</COMMENT>

 

Instructions for Use: 

       

1. The program is embedded as an Applet on this page (see above). You should be asked to accept a security certificate to allow the applet to run. Once the Applet loads, simply select the “Get File” button to choose an image file. If the applet does not load ensure you are using at least IE v5.0 or Netscape v4.0. The full URL is http://cs-people.bu.edu/ringb/CS585/PA1/HW1-ring.htm. Because of the differences in various browsers and browser setting, the Applet may or may not load (and could cause the browser window to hang).

 

2. In order to run the program locally go to the program/ sub-directory and type the following to execute the program:  java Face

 

3. To compile the source code, type the following: javac Face.java

     

            NOTE 1: CSA.BU.EDU is still running Java v1.4.2; this program will not work on that system.

 

            NOTE 2: This program is an adaptation from one I wrote in CS640: Artificial Intelligence. In fact, this algorithm is “dumbed down” from the previous version in order to isolate the color component portion of the algorithm. I did this in order to highlight the limitations of a color-only based Face Detection algorithm.         

 

 

1. Skin Color Observations:

            Skin colors have predominantly red coloring in comparison to the green and blue components. In examining the skin colors, it is interesting to note that the blue component varies across the various tones. The supports the theory that the blue component does not contribute much to the color of flesh. The red-to-green ratio seems to vary; however, most of the colors lie within the range of 2:1 to 3:1 for red-to-green component. Also, it is worth noting that all the skin colors have red and green that are above a minimum threshold value, which I have approximately determined to be 40 on a scale of 0 to 255.

 

 

 

2. Face Detection Algorithm:

            The face detection algorithm is a simple color threshold and comparison method. Based on some analytical assessments of “average” skin colors, the program analyzes the Red and Green components of each pixel against two assessed average “flesh color” values on a 2D coordinate plane. By taking the Dot Product of each pixel’s Red & Green values with that of the two assessed “flesh color” values, the algorithm determines whether a pixel is or is not a flesh color. In addition, the program checks that each pixel’s Red & Green values are above a pre-determined “threshold.” The Algorithm is described below:

 

            1.         Load Image file into a bufferedImage

 

            2.         For each pixel (x, y) in the image:

 

                        IF (pixel.Red < 40  OR  pixel.Green < 40)

                                    Set output(x, y) = BLACK;

                        ELSE IF (DOT_PRODUCT (pixel, skin_color1) < 0.995)  OR

                                       (DOT_PRODUCT (pixel, skin_color2) < 0.995)

                                    Set output(x, y) = BLACK;

                        ELSE

                                    Set output(x, y) = pixel (x, y);

                                   

 

 

3. Results:

 

ORIGINAL

FILTERED-FACE

Betke.jpg

Ring.jpg

Sample-face.jpg

 

 

 

 

4. Discussion & Conclusion:

 

            A.        I was able to locate large portions of the face in the single-face image, along with many faces in a multiple face image.

 

            B.         I noticed that I was unable to properly identify darker areas of the face, such as those pixels under the chin. The differences in brightness in this area make it difficult for my simple algorithm to identify skin pixels on a face.

 

            C.        My algorithm improperly identified background pixels as “flesh colored” ones for the multiple-face image. Once particular example is an orange shirt which was partially identified as “flesh colored.” Also, certain hair tones also showed up as “flesh colored.” The reason for this false positive detection was due to the fact that these pixels’ colors were similar to those of the my sampled flesh colored ones.

 

            D.        The algorithm is very simple and does not take into account more complex issues such as brightness and background noise. To improve, would I include additional code to eliminate noise (such as convolution or diffusion) and I would conduct multiple passes through the image to ascertain the image’s overall brightness. This would help to better identify darker faces and lighter faces in a darker or lighter images. In addition, as an even better method, I would expand on the color comparison algorithm to use other features of the pictures, such as combining the color threshold with an edge detection algorithm to identify an entire face.

 

            E.         To describe the location of a face in an image, once must first identify those pixels in the image that are actually part of the face. Once identified, I would take the “Center of Mass” of all these identified pixels to determine the “center” of the face. One technique that I would use is to take the “average” location of the face in both the horizontal and vertical directions for all pixels identified as “flesh colored,”