File Exchange

## Face recognition using PCA

version 1.0.0.0 (2.81 KB) by Baba Dash

### Baba Dash (view profile)

Principal Component Analysis for Face Recognition

Updated 04 Mar 2014

This program recognizes a face from a database of human faces using PCA. The principal components are projected onto the eigenspace to find the eigenfaces and an unknown face is recognized from the minimum euclidean distance of projection onto all the face classes.

### Cite As

Baba Dash (2019). Face recognition using PCA (https://www.mathworks.com/matlabcentral/fileexchange/45750-face-recognition-using-pca), MATLAB Central File Exchange. Retrieved .

sarine_nassima

### sarine_nassima (view profile)

thank you;
but when we will calculate the accuracy recognition of this method what we can do???

Its Ok

APARNA SASIDHARAN

jin li

### jin li (view profile)

your coding is very helpful to do face recognition, but if someone need to reconstruct the image by eigenface. the formula to calculate weights should be correct. I spend 2 days to read paper, most of them did not use the right formula to calculate the weights. Here is the formula
W=inverse(eigenface Transpose * eigenface)* eigenface Transpose * (image matrix- image mean)
while eigenface=(image matrix- image mean)*eigenvector
if each image is N*N, the number of training images is M , then image matrix is N^2 *M
if we choose first K eigenvectors, so the eigenface will be N^2 *K
the weight (W) is K*K

Akshay Karthik Thana Sekar

### Akshay Karthik Thana Sekar (view profile)

how will this work?

Ahmed Elkabbany

SiGyi

Nga Wai

### Nga Wai (view profile)

I also used this method and I want to know, how I can solve the persons who are not in the database. Please tell me, how to calculate the threshold value for solving unknown face. Thank You!

Soundaraj Thevan

### Soundaraj Thevan (view profile)

How to create a databath

SUBASH P

### SUBASH P (view profile)

when test image is in database then it shows the equivalent image, if the test image is not in database then it shows another person image as Equivalent image
why it is not showing any error (or) return something as "image not found in database"

sarine_nassima

### sarine_nassima (view profile)

hello; the databse used in this code its: yalefaces database

udit jain

### udit jain (view profile)

can i know which database has been used

Manjusha Chavan

### Manjusha Chavan (view profile)

i am getting error on this -temp = reshape(img',r*c,1); it says to use Permute instead of img' , but after modification it again gives error

Silvina Hariati

### Silvina Hariati (view profile)

@Baba Dash ... Sir, Can you help me about feature extraction using PCA? and what this code can be used in iris feature extraction?

satyajit mollick

APARNA NAGARAJAN

### APARNA NAGARAJAN (view profile)

There is an error in line 104 and 121..U have to project all M face images on eigen space(not the first K faces). Hence size(A,2) would be the appropriate.

aya elnahas

### aya elnahas (view profile)

where is the dataset to use for this project ?

Harshini D P

### Harshini D P (view profile)

can anyone help me out in how to execute this code? did it really work?

Rawand Ashoor

lysia pildash

### lysia pildash (view profile)

we need code for face recognition using hog feature

aarthi priya rajendran

### aarthi priya rajendran (view profile)

did any one help me out to like how to write a code for group face detection and recognize a face

Satish Attuluri

### Satish Attuluri (view profile)

5ererweer hfuu ffyf uyryfg

Dang Hai Toan

Thanks

kiet tran

thanks

android boy

### android boy (view profile)

can someone teach me how to run this program? I am confuse specially in the facerecog.m code which indicates Thumbs.db, do i need to create directory?

santosh

mustafa mutlu

### mustafa mutlu (view profile)

Thank you very much for your contribution.

### Bagus Adhi Kusuma (view profile)

would i ask, First i have many template that different size. can i use PCA with various size of templates?. The second question is, my template have smaller size than source image, can i use PCA to detect a small part in my source image? Thank you very much sir.

M. Farez

### M. Farez (view profile)

is there a tutorial for this?

Pham Hong Son

### Pham Hong Son (view profile)

Dear sir. Can you show me how to launch this project in MATLAB, i've used ver 2009. Please give me the video tutorial .
MY skype : vn680260

poorani balraj

salman khan

### salman khan (view profile)

dear sir,
i need some help about your code. i am new in matlab.

Ankit Pal

### Ankit Pal (view profile)

m beginner in matlab.
thankyou

Ankit Pal

### Ankit Pal (view profile)

sir thanku for code and plz help me a little with codes m new with matlab.

zhuangzhaung

Alvindra Pratama

### Alvindra Pratama (view profile)

how to change euclidean into mahalanobis? because i want use mahalanobis, not euclidean

Hello pls help it's giving me an error of inner matrix dimension must agree

Hello pls I need your help.am getting this error of inner matrix dimensions must agree.am confused pls help

walid bakiri

### walid bakiri (view profile)

i think this is a mistak
for i = 1 : size(A,2) insted
for i = 1 : size(eigenfaces,2)
!!
%%%%%%% finding the projection of each image vector on the facespace (where the eigenfaces are the co-ordinates or dimensions) %%%%%

projectimg = [ ]; % projected image vector matrix
for i = 1 : size(eigenfaces,2)
temp = eigenfaces' * A(:,i);
projectimg = [projectimg temp];
end

%%%%% extractiing PCA features of the test image %%%%%

u should project all face traninig set in egenFaces ur loop stop just into eigenfaces Size not A traning Set face matrix.

Juan Sebastian Quiroga Taborda

### Juan Sebastian Quiroga Taborda (view profile)

Very cool!
At uni we are talking about this program. Is there any particular dataset I can use for it?
Thanks

Ayman Afaneh

good

salam jabbar

Good

thiyo ps

good job

Hafiz Umar

ANJA TURK

### ANJA TURK (view profile)

I will be really grateful if you can instruct me how to use your file.

Ganesh Raut

nice..

hary muharramon

pca nice

xu

Jishnu C Rajan

annmaria

annmaria

Nam Nam

### Nam Nam (view profile)

##### MATLAB Release Compatibility
Created with R2008a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux