




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





Due: October 3 at 10:59am - Problem 1. Due: October 8 at 10:59am - Problems 2. Due: October 15 at 10:59am - Problems 3.
The assignment is worth 15% of your total grade. It is graded out of a total of 100 (plus 10 possible extra points).
Goals.
In this assignment you will use what you have learned about bases, projection, templates, and eigen-representations. You will also use Gaussian densities and maximum-likelihood estimation. This is a simple version of a real problem and consequently uses many of tools we will learn (though in a simplified form). This assignment might provide a good base for more advanced projects.
Summary.
You will be working with a training database of face images taken of the class. You will build a low-dimensional model of the face appearance using Principal Component Analysis. You will build a simple probabilistic model of faces and then use this to detect faces in images taken of the whole class.
Files you need.
The face training images that you should work with are in the directory
/course/cs143/data/Faces08/mugs
The individual images that you will use for face detection are located in
/course/cs143/data/Faces08/individual
while the group pictures of the class are in
/course/cs143/data/Faces08/group ‘‘motion_lab.JPG’’ will be used for problem 3; ‘‘classroom.JPG’’ is for extra credit.
Additionally, we provided three Matlab scripts problem[1-3].m in the di- rectory /course/cs143/asgn/asgn2/, which you should start from. Their main purpose is to make it easier for us to grade your homework. You are therefore asked to copy those files and modify them, so that they perform the appropriate task and display your results. You are of course free to write your own scripts and/or functions and only add calls to these from the scripts we provided.
What to hand in.
You will hand in your Matlab code, which is supposed to show all your re- sults, and any text or explanations that are required. Please hand in the modified problem[1-3].m scripts as well as any other Matlab scripts or functions that your solution requires. Make sure that all your results are displayed properly! You will also hand in any text or explanations electronically. They should either be in plain text format, in Postscript, in PDF or in DOC. To handin the assignment run the commands below from the folder that con- tains your solutions. The entire contents of that folder will be zipped and sent to us.
/course/cs143/bin/cs143_handin asgn2_p
%The new ’img’ will be a row vector. imgvec=img(maskInd);
%To put ’img’ back into a matrix tempimg=zeros(maskSz); tempimg(maskInd)=imgvec; imgvec=tempimg;
%Alternately you can do element-wise % multiplication. The resulting image % will have nan’s around the borders img=img.*mask;
Using the first M = 6 principal components from above, build an approx- imate probabilistic likelihood model p(x|Ω) where x is a vectorized image patch (x ∈ RN^ ), where N is the size of the region of interest specified by the image mask (ie. from the previous Matlab example, length(maskInd)), and Ω is the object class (faces in this case). Assume that face images can be represented by their mean and covariance. In this case we would have
p(x|Ω) =
(2π)N/^2
det(Σ)−^1 /^2 exp(−
(x − x¯)T^ Σ−^1 (x − ¯x))
where x¯ is the mean face image and Σ is the covariance matrix. The term (x − ¯x)T^ Σ−^1 (x − x¯) is called the Mahalanobis distance.
We can use the eigendecomposition to rewrite Σ as U S^2 U T^ /(N −1), where S and U are the matrices returned by svd(A).
Plugging that into the Mahalanobis distance we get
d(x) = (x − ¯x)T
( U S^2 U T N − 1
)− 1 (x − x¯)
= (x − ¯x)T^ U
( S^2 N − 1
)− 1 U T^ (x − ¯x)
= yT^ Λ−^1 y
where y = U T^ (x−¯x) represents the coefficients of the projection of the data onto the subspace spanned by U T^ and Λ is the diagonal matrix of variances (λi) as computed in the previous problem.
The Mahalanobis distance can now be written as a simple sum (remember that we are building only an approximate model so we are summing from 1 to M = 6):
d(x) =
∑^ M
i=
y i^2 λi
Define the approximate image likelihood using this formula. Also, feel free to ignore the normalization constant.
λi along each principal direction. Show each random face and compute its log likelihood using the approximate model.
but you will most likely need to tweak the parameters. In the end, the faces you want to detect should be roughly the same size (judged, for example, by the distance between the eyes) and the same inten- sity (you can check this by using the Data Cursor in Matlab’s figure window) as the mean face.
% Assume I is the image you’re searching in. % For the individual pictures: I = imresize(I,0.36); % Scale correction I = I (^) * 1.3 % Luminosity correction
% For the group image I = imresize(I,1.25); % Scale correction I = I (^) * 1.1 % Luminosity correction.
Students seeking graduate credit are not required to complete the extra credit problems in part 3; these may be done for extra credit at your dis- cretion. Instead, graduate students should implement, test, and compare the enhanced distance function defined in Moghaddam & Pentland; that is, use equation 7. The paper is available here:
http://www.cs.brown.edu/courses/cs143/Papers/moghaddam95probabilistic.pdf
(5 extra pts) Apply a multiresolution approach for detecting faces. Construct a 3-level image pyramid of the group image and each of the training images. Com- pute the likelihood at the coarse level. Choose the locations that maximize the likelihood and use these to constrain the search at the next level. Repeat until the finest level. Display an image showing the detected face locations at each level. How much computation is saved by this coarse-to-fine imple- mentation?
(10 extra pts) Get your face detector to work on the classroom images. These are much harder due to the large scale and illumination changes.
(10 extra pts) Once you detected the faces, try to automatically recognize the persons by comparing the projection coefficients of the detected faces to the coeffi- cients of the training images.