1. Homepage
  2. Programming
  3. EIE522 Pattern Recognition Laboratory 1: Face Image Analysis and Representation Using Principal Component Analysis (PCA)

EIE522 Pattern Recognition Laboratory 1: Face Image Analysis and Representation Using Principal Component Analysis (PCA)

Engage in a Conversation
Hong KongThe Hong Kong Polytechnic UniversityEIE522Pattern RecognitionFace Image Analysis and RepresentationPCAMatlab


CourseNana.COM

EIE522 Laboratory 1:  CourseNana.COM


CourseNana.COM

Please generate a single PDF file for online submission. Please write your name and student number on the top of the first page of your Lab report. Since you need to submit MATLAB code, only a typewritten report is acceptable.  CourseNana.COM

(NO late submission is allowed)  CourseNana.COM

Face Image Analysis and Representation Using Principal Component Analysis (PCA)  CourseNana.COM

Objectives:  CourseNana.COM

In this laboratory exercise, you are given 20 face images, which are used as training samples for PCA. You are required to produce the eigenfaces of the training samples, which are then used to form an eigenspace for face representation and recognition based on 4 testing images. Through this exercise, you will learn the following:  CourseNana.COM

1. representation of a face image as a high-dimensional vector;  CourseNana.COM

2. generation of the principal components of a set of training images;  CourseNana.COM

3. approximation of images using the principal components; and  CourseNana.COM

4. face recognition using PCA.  CourseNana.COM


CourseNana.COM

For each procedure in the following, please provide the answer with detailed explanation and programming codes in the report.  CourseNana.COM

Software Tools: MATLAB is used throughout this laboratory. You may refer to the HELP menu for the MATLAB commands used in this laboratory.  CourseNana.COM

ORL Databasehttps://github.com/boenomarcus/face-recognition/tree/main/imgs/orl  CourseNana.COM

Procedures:  CourseNana.COM

(a) Reading the Training Images:  CourseNana.COM


CourseNana.COM

The 20 training face images1_1, 11_2, 21_3, 31_4,41_5, 51_6, 61_7, 71_8, 81_9, 91_10, 101_11, 111_12, 121_13, 131_14, 141_15, 151_16, 161_17, 171_18, 181_19, 191_20  CourseNana.COM

The images are in jpg format. Please rename the image files based on the following rule.  CourseNana.COM

xx_1.jpg -> 1.jpg,  CourseNana.COM

xx_2.jpg -> 2.jpg,  CourseNana.COM

xx_3.jpg -> 3.jpg, and so on.  CourseNana.COM

The filenames of these image files are “i.jpg”, where i = 1, …, 20. Run the following MATLAB codes to read the training face images:  CourseNana.COM

clear;  CourseNana.COM

NumOfSamples = 20;  CourseNana.COM

str_Path = 'c:\???\Training\';  CourseNana.COM

for i = 1: NumOfSamples  CourseNana.COM

str_Load = strcat(str_Path, num2str(i), '.jpg');  CourseNana.COM

Image = imread(str_Load);  CourseNana.COM

TrainingImage(:,i) = double(reshape(Image, [ ], 1));  CourseNana.COM

end  CourseNana.COM

What is the dimension of TrainingImage? What do the columns of this matrix represent? You may use the command “size(A)” to check the size of A.  CourseNana.COM

- 2 -  CourseNana.COM

(b) Calculating the Mean Face and the Demeaned Faces:  CourseNana.COM

You can calculate the mean of the training face images using the following MATLAB codes:  CourseNana.COM

for i = 1: NumOfSamples  CourseNana.COM

MeanFace = MeanFace+TrainingImage(:,i);  CourseNana.COM

end  CourseNana.COM

MeanFace = MeanFace/NumOfSamples;  CourseNana.COM

The demeaned faces of the training samples can be computed as follows:  CourseNana.COM

for i = 1: NumOfSamples  CourseNana.COM

DemeanFace(:,i) = TrainingImage(:,i) − MeanFace;  CourseNana.COM

end  CourseNana.COM

Display the mean face image and the demeaned face images. Note that the demeaned images can be displayed with grayscale bars using the following MATLAB codes:  CourseNana.COM

for i = 1: NumOfSamples  CourseNana.COM

Display = DemeanFace(:,i);  CourseNana.COM

Display = reshape(Display, [ImageHeight ImageWidth]);  CourseNana.COM

figure(i), imagesc(Display), colorbar, colormap(gray), title(‘Demeaned Face’);  CourseNana.COM

end  CourseNana.COM

You may save the figure in a particular image file format.  CourseNana.COM

(c) Computing the Eigenvalues and Eigenvectors/Eigenfaces:  CourseNana.COM

(i) With the demeaned face images DemeanFace, write a MATLAB code to compute the covariance matrix. Denote this covariance matrix as CovFace1. Note that the transpose of a vector x is x’ in MATLAB.  CourseNana.COM

What is the dimension of CovFace1?  CourseNana.COM

(ii) The MATLAB command [EV, ED] = eig(A) computes the eigenvectors and eigenvalues of the square matrix A and stores them in EV and ED, respectively. Use this command to compute the eigenvalues and eigenvectors of CovFace1. What observation can you see? Discuss your observation.  CourseNana.COM

(iii) Use another method, which computes the eigenvalues and eigenvectors with a smaller covariance matrix.  CourseNana.COM

Compare the runtime required for Parts (ii) and (iii). Discuss your answer.  CourseNana.COM

How many non-zero eigenvectors or non-zero eigenvalues are available? Discuss your answer.  CourseNana.COM

Display the eigenvectors, in the form of image, according to the eigenvalues in descending order.  CourseNana.COM

- 3 -  CourseNana.COM

(d) Image Representation using Eigenfaces:  CourseNana.COM

(i) You should use an array, say order, to store the indices of the eigenvalues in descending order.  CourseNana.COM

(ii) Select a demeaned image Demeanface(:,i) in the training set, and project it onto the eigenvectors as follows:  CourseNana.COM

for j = 1:N % N is the number of eigenvectors available  CourseNana.COM

coef(i,j) = DemeanFace(:,i)’*EV(:,order(j));  CourseNana.COM

end  CourseNana.COM

(iii) Reconstruct the training image using M = 4, 8, … eigenfaces as follows:  CourseNana.COM

for j = 1:M  CourseNana.COM

ReconstImage = ReconstImage+coef(i,j)*EV(:,order(j));  CourseNana.COM

end  CourseNana.COM

ReconstImage = MeanFace + ReconstImage;  CourseNana.COM

Display the reconstructed images using different values of M, and compute the corresponding differences to the original image in terms of the mean squared error. Discuss your results.  CourseNana.COM

Note that the sum of squared error between two images A and B can be computed as follows:  CourseNana.COM

Difference = A − B;  CourseNana.COM

SSE = sum(sum(Difference.*Difference));  CourseNana.COM

(iv) Reading the Testing Images:  CourseNana.COM

The 4 testing face images: 7_1, 37_4, 201_21, 231_24  CourseNana.COM

Please rename the image files based on the following.  CourseNana.COM

7_1.jpg -> 1.jpg,  CourseNana.COM

37_4_2.jpg -> 2.jpg,  CourseNana.COM

201_21.jpg -> 3.jpg,  CourseNana.COM

231_24.jpg -> 4.jpg  CourseNana.COM

Project these images to the eigenspace and then reconstruct them with all the eigenfaces available. Display the original images and the corresponding reconstructed images, and compute their errors. Discuss your results.  CourseNana.COM

(e) Face Recognition using Eigenfaces:  CourseNana.COM

Suppose the coefficients of projecting the two testing face images are stored in TCoeff(i,:), where i = 1, 2. Compute the Euclidean distances of the projection coefficients between the testing images and the training images.  CourseNana.COM

Display the two testing images and their corresponding three training images which have the smallest computed Euclidean distances. Discuss your results.  CourseNana.COM

Your report should also include conclusion, discussion and full MATLAB code with remarks.  CourseNana.COM

ORL Face Database References:  CourseNana.COM

ORL database: The Olivetti Research Laboratory (ORL), AT&T Laboratories Cambridge.  CourseNana.COM

F. Samaria, A. Harter, "Parameterisation of a Stochastic Model for Human Face Identification". IEEE Workshop on Applications of Computer Vision 1994.  CourseNana.COM

Link: https://github.com/boenomarcus/face-recognition/tree/main/imgs/orl  CourseNana.COM

− END −  CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Hong Kong代写,The Hong Kong Polytechnic University代写,EIE522代写,Pattern Recognition代写,Face Image Analysis and Representation代写,PCA代写,Matlab代写,Hong Kong代编,The Hong Kong Polytechnic University代编,EIE522代编,Pattern Recognition代编,Face Image Analysis and Representation代编,PCA代编,Matlab代编,Hong Kong代考,The Hong Kong Polytechnic University代考,EIE522代考,Pattern Recognition代考,Face Image Analysis and Representation代考,PCA代考,Matlab代考,Hong Konghelp,The Hong Kong Polytechnic Universityhelp,EIE522help,Pattern Recognitionhelp,Face Image Analysis and Representationhelp,PCAhelp,Matlabhelp,Hong Kong作业代写,The Hong Kong Polytechnic University作业代写,EIE522作业代写,Pattern Recognition作业代写,Face Image Analysis and Representation作业代写,PCA作业代写,Matlab作业代写,Hong Kong编程代写,The Hong Kong Polytechnic University编程代写,EIE522编程代写,Pattern Recognition编程代写,Face Image Analysis and Representation编程代写,PCA编程代写,Matlab编程代写,Hong Kongprogramming help,The Hong Kong Polytechnic Universityprogramming help,EIE522programming help,Pattern Recognitionprogramming help,Face Image Analysis and Representationprogramming help,PCAprogramming help,Matlabprogramming help,Hong Kongassignment help,The Hong Kong Polytechnic Universityassignment help,EIE522assignment help,Pattern Recognitionassignment help,Face Image Analysis and Representationassignment help,PCAassignment help,Matlabassignment help,Hong Kongsolution,The Hong Kong Polytechnic Universitysolution,EIE522solution,Pattern Recognitionsolution,Face Image Analysis and Representationsolution,PCAsolution,Matlabsolution,