EECS-841 Homework 2: Celebrity Look-Alikes using Eigenfaces - Prof. Brian Potetz, Assignments of Electrical and Electronics Engineering

Instructions for a homework assignment in the eecs-841 course, where students are required to write matlab routines to identify celebrity look-alikes using the eigenfaces technique. The assignment includes two parts: offline processing to compute eigenfaces and online processing to find the nearest match. The description also suggests some discussion questions related to the results and potential improvements.

Typology: Assignments

Pre 2010

Uploaded on 03/11/2009

koofers-user-zl3
koofers-user-zl3 🇺🇸

9 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Homework #2
EECS-841
Due: Monday, Oct 6 (midnight)
Total Points: 8
Celebrity Look-Alikes
Although the technology for facial recognition is still a quickly evolving work in progress, even simple
facial recognition approaches are sufficiently powerful for another application: identifying which celebrity
looks most like you. In this assignment, we will use the eigenfaces technique discussed in class to write a
matlab program that identifies which celebrity you most resemble.
1. Offline Processing: Computing the Eigenfaces (3 pts)
Write a matlab routine
function [mean_face, eigenfaces, singularvalues, celebrity_PCA_coefs] =
ComputeEigenfaces(celebrity_directory, binary_mask)
where celebrity_directory is a directory containing the celebrity photo database available from the
class website. Each of these images is a 330x280x3 color image, and the scale, rotation, and offset of
each image has been normalized so that the eyes of each celebrity are in the same location. Use
dir([celebrity_directory, '*.jpg'])
to get a list of files in the celebrity directory.
binary_mask is the boolean 330x280x3 array that is found at the class website. This boolean mask
zeros-out parts of the images that typically lie outside of faces, so that the image background does not
affect the results.
ComputeEigenfaces first computes the mean celebrity face, and then "centers" the celebrity images by
subtracting out this mean face. mean_face should be a 330x280x3 array.
Next, ComputeEigenfaces should apply the binary mask to each image, to zero-out the background.
Next, compute the eigenfaces. To do this, you will first want to construct an array that contains each
celebrity image. It is convenient here to keep only those pixels that are not masked out. You can do this
by:
unmasked_pixels = find(binary_mask);
im_vector = im(unmasked_pixels);
Later, when you need obtain the masked image from im_vector, use:
full_im = zeros(size(binary_mask));
full_im(unmasked_pixels) = im_vector;
pf3

Partial preview of the text

Download EECS-841 Homework 2: Celebrity Look-Alikes using Eigenfaces - Prof. Brian Potetz and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

Homework # EECS- Due: Monday, Oct 6 (midnight) Total Points: 8 Celebrity Look-Alikes Although the technology for facial recognition is still a quickly evolving work in progress, even simple facial recognition approaches are sufficiently powerful for another application: identifying which celebrity looks most like you. In this assignment, we will use the eigenfaces technique discussed in class to write a matlab program that identifies which celebrity you most resemble.

1. Offline Processing: Computing the Eigenfaces (3 pts) Write a matlab routine function [mean_face, eigenfaces, singularvalues, celebrity_PCA_coefs] = ComputeEigenfaces(celebrity_directory, binary_mask) where celebrity_directory is a directory containing the celebrity photo database available from the class website. Each of these images is a 330x280x3 color image, and the scale, rotation, and offset of each image has been normalized so that the eyes of each celebrity are in the same location. Use dir([celebrity_directory, '*.jpg']) to get a list of files in the celebrity directory. binary_mask is the boolean 330x280x3 array that is found at the class website. This boolean mask zeros-out parts of the images that typically lie outside of faces, so that the image background does not affect the results. ComputeEigenfaces first computes the mean celebrity face, and then "centers" the celebrity images by subtracting out this mean face. mean_face should be a 330x280x3 array. Next, ComputeEigenfaces should apply the binary mask to each image, to zero-out the background. Next, compute the eigenfaces. To do this, you will first want to construct an array that contains each celebrity image. It is convenient here to keep only those pixels that are not masked out. You can do this by: unmasked_pixels = find(binary_mask); im_vector = im(unmasked_pixels); Later, when you need obtain the masked image from im_vector, use: full_im = zeros(size(binary_mask)); full_im(unmasked_pixels) = im_vector;

Once you have an array that contains each image vector, compute the eigenfaces using the Matlab function svd. Note that you have far more unmasked pixels (51951) than celebrity images (147), so most of the 51951 eigenfaces will be degenerate. Thereʼs no need to compute them all. Use: [U, S, V] = svd(X, 0); to compute the eigenvectors and singular values. To compute similar faces, there is no need to use all 147 eigenfaces. In this assignment, we will use only

  1. Select the 10 eigenfaces with the highest singular values, and save them in the matrix eigenfaces. eigenfaces should be a 320x280x3x10 matrix. Also save the singular vectors in the 10x1 array singularvalues. Look up the matlab function diag for getting the diagonal of a matrix. Finally, we will need to have the PCA coefficients for each celebrity. In the 147x10 matrix celebrity_PCA_coefs, store these coefficients so that offcenter = reshape(eigenfaces, [3302803,10]) * celebrity_PCA_coefs(i,:)'; recon = mean_face + reshape(offcenter, [330, 280, 3]); will approximate the original celebrity face. Don't expect good reconstructions here. Remember it is characterizing each face by only 10 numbers. ComputeEigenfaces should take just a few seconds to run. 2. Online Processing: Finding the Nearest Match (3 pts) Now write a function function closest_celebrities = ComputeLookAlike(face_im, celebrity_directory, binary_mask, mean_face, eigenfaces, singularvalues, celebrity_PCA_coefs) that accepts a face image face_im. The other input variables are as described above. The function should find the two celebrity faces that most closely match the input image. ComputeLookAlike should then do two things: First, your function should open a figure window, and using the matlab routine subplot, diplay from left to right the input image, the nearest celebrity match, and the second nearest celebrity match. Second, ComputeLookAlike should return a 1x2 vector containing the indicies (into the array celebrity_PCA_coefs) of the two nearest celebrity matches (in order). 3. Discussion (2 pts) Test your function on a photograph of yourself. Use the program FaceAligner, available from the class website, to register a photograph so that the eyes line up with the celebrity photographs. When you run FaceAligner, just click on the left eye, then the right eye (meaning your left & right, not the photograph subject's left & right). Also, registered photographs of most of the students are available online.