# Yale Face Database - Introduction to Computer Vision - Assignment, Exercises for Computer Vision. Alliance University

PDF (270 KB)
3 pages
1000+Number of visits
Description
During the studies,their is a program called Introduction to computer vision offered in our university, this course is very helpful. The main points disucss in these lecture slides are:Yale Face Database, Recognition Us...
20points
this document
Preview3 pages / 3

CSE152 – Intro to Computer Vision – Assignment #4 Instructor: Prof. David Kriegman.

http://cseweb.ucsd.edu/classes/sp12/cse152-a

Due Date: Fri. June 8, 2012.

Instructions:

• Attempt all questions

• Submit your assignment electronically by email to [email protected] with the subject line CSE152 Assignment 4. The email should include 1) A 1) a written report that includes all necessary output images and written answers (e.g., as a Word file or PDF), and 2) all necessary Matlab code. Attach your code and report as a zip or tar file.

The Yale Face Database

In this assignment, we will have a look at some simple techniques for object recognition, in particular, we will try to recognize faces. The face data that we will use is derived from the Yale Face Database. For more information, see http://cvc.yale.edu/projects/yalefacesB/yalefacesB.html. The database consists of 5760 images of 10 individuals, each under nine poses and 64 dierent lighting conditions. The availability of such standardized databases is important for scientic research as they provide a common testing ground to test the efficacy of different algorithms.

Figure 1: The Yale face database B.

In this assignment, we will only use 640 images corresponding to a frontal orientation of the face. These faces are included in the file yaleBfaces.zip. You will find the faces divided into five different subsets. Subset 0 consists of images where the light source direction is almost frontal, so that almost all of the face is brightly illuminated. From subset 1 to 4, the light source is progressively moved toward the horizon, so that the effects of shadows increase and not all pixels are illuminated. The faces in subset 0 will be used as training images, and subsets 1 to 4 will be used as test images.

1 Recognition Using Eigenfaces

• Write a function [W,mu]=eigenTrain(trainset,k) that takes as input aN×dmatrix trainset of vectorized images from subset 0, where N = 70 is the number of training images and d = 2500 is the number of pixels in each training image. Perform PCA on the data and compute the top k = 20 eigenvectors. Return the k × d matrix of eigenvectors W , and a d dimensional vector mu encoding the mean of the training images. You should use the matlab command svds to find the first k eigenvectors. You can use the provided function loadSubset.m to

1

• Rearrange each of the top 20 eigenvectors you obtained in the previous step into a 2D image of size 50 × 50. Display these images by appending them together into a 500 × 100 image (a 10 × 2 grid of images). (4 points)

• Select one image per person from subset 0 (e.g., the 10 images person01 01.png, person02 01.png, ... person10 01.png). Show what each of these images would look like when using only the top k eigenvectors to reconstruct them, for k = 1, 2, 3, 4, 5, ...10. This reconstruction procedure should project each image into a k dimensional space, project that k dimensional space back into a 2500 dimensional space, and finally resize that 2500 vector into a 50 × 50 image. (7 points)

• Write a function called testlabels=eigenTest(trainset,trainlabels,testset,W,k) that takes as input the same N × d matrix trainset of vectorized images from subset 0, an N dimensional vector trainlabels that encodes the class label of each training image (e.g., 1 for person01, 2 for person02, etc.), an M × d matrix testset of M vectorized images from one of the test subsets (1-4), the output of PCA W , and the number of eigenvectors to use k. Project each image from trainset and testset onto the space spanned by the first k eigenvectors. For each test image, find the nearest neighbor in the training set using an L2 distance in this lower dimensional space and predict the class label as the class of the nearest training image. Your function should return an M dimensional vector testlabels encoding the predicted class label for each test example. Evaluate eigenTest on each test subset 1-4 separately for values k = 1...20 (so it should be evaluated 4 × 20 times). Plot the error rate (fraction of incorrect predicted class labels) of each subset as a function of k in the same plot, and use the matlab legend function to add a legend to your plot. (10 points)

• Repeat the experiment from the previous step, but throw out the first three eigenvectors. That is, use k eigenvectors starting with the fourth eigenvector. Produce a plot similar to the one in the previous step. How do you explain the difference in recognition performance from the previous part? (5 points)

• Explain any trends you observe in the variation of error rates as you move from subsets 1 to 4 and as you increase the number of eigenvectors. Use images from each subset to reinforce your claims. (4 points)

2 Recognition Using Fisherfaces

• Write a function called [W,mu]=fisherTrain(trainset,trainlabels,c) that takes as input the same N × d matrix trainset of vectorized images from subset 0 and the corresponding class labels trainlabels, and the number of classes c = 10. Your function should do the following (10 points):

– Compute the mean mu of the training data, and use PCA to compute the first N − c principal components. Let this be WPCA.

– Use WPCA to project the training data into a space of dimension N − c. – Compute the between-class scatter matrix SB and the within class scatter matrix SW on

the N − c dimensional space from the previous space. – Compute Wfld, by solving for the generalized eigenvectors of the c−1 largest generalized

eigenvalues for the problem SBwi = λiSWwi. You can use the matlab function eig to solve for the generalized eigenvalues of SB and SW .

2

– The fisher bases will be a W = WfldWPCA, where W is (c−1)×d, Wfld is (c−1)×(N−c), and WPCA is (N − c) × d.

• As in the Eigenfaces exercise, rearrange the top 9 Fisher bases you obtained in the previous part into images of size 50 × 50 and stack them into one big 450 × 50 image. (5 points)

• As in the eigenfaces exercise, perform recognition on the testset with Fisherfaces. As before, use a nearest neighbor classifier, and evaluate results separately for each test subset 1-4 for values k = 1...9. Plot the error rate of each subset as a function of k in the same plot, and use the matlab legend function to add a legend to your plot. Explain any trends you observe in the variation of error rates with different subsets and different values of k, and compare performance to the Eigenface method. (10 points)

Writeup

I will be looking for the following in our writeup:

• All images should be clearly labeled and have a short paragraph/caption explaining what the figure is about.

• Your document should be properly formatted and organized.

• If a question asks you to “explain the results“, then write a paragraph using complete sentences. Try to come up with reasonable explanations for the results you are getting. This may involve doing a little research including material outside of lecture notes and the textbook. It may be possible to earn extra credit if your research includes external sources, but be sure to cite your sources.

3