Problem 2: Recognizing famous Wellesley alums

Wellesley College is proud to have some very distinguished alumnae! For this problem, you'll write a program to recognize the faces of three of our special graduates: Madeleine Albright '59, Hillary Clinton '69 and Pamela Melroy '83. The assign3_programs folder contains three face images whose identity is assumed to be known (albright.jpg, clinton.jpg, melroy.jpg) and three face images to be recognized by your program (face1.jpg, face2.jpg, face3.jpg). The file recognize.m contains initial code that loads the six face images into variables in the MATLAB workspace and displays them using subplot and imshow (the top three images are the known faces and the bottom images are the "unknown" faces):

figure window with 6 face images

In lecture, we explored the problem of fingerprint identification and discovered the shocking truth that Sohie is behind the recent string of crimes in the CS department! Given a partial fingerprint lifted from the crime scene, stored in the variable finger, and Sohie's partial fingerprint stored in the variable sohie, we calculated the average difference between the brightness values stored in the two images:

sohieDiff = mean(mean(abs(finger-sohie)));

After computing this difference for our other suspects Randy and Scott, we determined that Sohie's fingerprint was the closest match!

Recognition using the full image

Using the same strategy for calculating how well the pattern of brightnesses match between two images, first add code to the recognize.m code file to calculate the average difference between the face1 image and each of the three known face images stored in the variables albright, clinton and melroy. Then add code to determine which of the three known faces is the best match to face1 using the three average differences that you calculated. Print a message indicating the identity of face1. Then repeat this process for the unknown faces stored in face2 and face3. Tip: cutting and pasting, and then making small modifications to the copied code, will save a lot of time!. Your program should be able to recognize the faces correctly.

Recognition using partial images

Real face recognition systems face many challenges: hair styles change, and faces appear with different expressions, poses and directions of gaze, and with different backgrounds and lighting. To cope with variations in hair styles and backgrounds, the recognition process is often based on a cropped area of the face that excludes the hair and background. For this part of the problem, you'll attempt to recognize the three faces using a cropped region of the faces that includes only the eyes, nose and mouth. The original images were carefully constructed so that they have the same overall size, with the region around the eyes, nose and mouth covering roughly the same area of each image. Create a set of six new variables that each store a small region of one of the original face images containing only the eyes, nose and mouth. Use the same coordinates for the upper left and lower right corners of the rectangular region that you select for all six images. Use imtool to help identify appropriate coordinates (as you move your mouse over the image displayed with imtool, the (X,Y) coordinates of the mouse are displayed in the lower left corner of the display window - remember that the order of these coordinates should be reversed when specifying the row and column of the corresponding locations of the matrix storing the image). Using subplot and imshow, display the six cropped images, as shown in the example below (again, consider copying and pasting code here!):

figure window with 6 face images

Repeat your code (with modifications to use the cropped images) to recognize the cropped versions of the face1, face2 and face3 images. Are you still able to recognize the three faces correctly?

Be sure to add comments to your recognize.m code file.