View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
PCA-based Face Recognition System

4.2 | 39 ratings Rate this file 112 Downloads (last 30 days) File Size: 180 KB File ID: #17032 Version: 1.0

PCA-based Face Recognition System


Amir Omidvarnia (view profile)


20 Oct 2007 (Updated )

This package implements 'Eigenface', a PCA-based face recognition system.

| Watch this File

File Information

This package implements a well-known PCA-based face recognition method, which is called 'Eigenface'.
All functions are easy to use, as they are heavy commented. Furthermore, a sample script and two small training and test databases are included to show their usage.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.2 (R2006a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (59)
28 Nov 2016 abhilash verma

great work ..thank you

19 Nov 2016 Ban gocrieng


Comment only
06 Jul 2016 Nazanin Nejatian

your work is great.thanks a lot Amir

12 Apr 2016 jeba shanthi

26 Oct 2015 vu hung


21 Oct 2015 noo no

noo no (view profile)

how calculate accuracy for this code

Comment only
27 Nov 2014 Carine

Carine (view profile)

Hello, this code does not give right results if the training database contains the image that we choose for testing. If the image chosen for testing is a face that already exists in training database but a different image of the face, it's not giving the correct results, anyone having same problem?

Comment only
17 Aug 2014 Shubhankar De

13 Jun 2014 poongothai rajan

i want to use hsv in pca...i extracted HSV feature from my data base..but want to then use pca ..any one know the procedure..if anyone have idea with this mail me..

Comment only
14 May 2014 poongothai rajan

@nadeer ataya ...even after chnaging am getting the same error

06 May 2014 Divyakant Meva

Hello, can u suggest how can I change dimension of all my 320x240 images to 200x180 images? It is urgent for me.

Comment only
02 May 2014 nadeer ataya

@poongothai rajan
changed images to .jpj

25 Apr 2014 poongothai rajan


i also got the same error..the solution is this will work for same dimension images..i changed all my images in the data base with same dimension eg(200*180);
then i got the output..try it best wises

Comment only
06 Apr 2014 Jackie

Jackie (view profile)

20 Mar 2014 suman

suman (view profile)

this code is not working for my own database i am getting error as
Error using ==> horzcat
CAT arguments dimensions are not consistent.

Error in ==> CreateDatabase at 47
T = [T temp]; % 'T' grows after each turn

Error in ==> example at 26
T = CreateDatabase(TrainDatabasePath); how to clear this errors... any one help me to clear this error

Comment only
07 Mar 2014 Pooja

Pooja (view profile)

The code is good but it doesnt work if d same person has his/her face tilted.I eanted a code for that. But good job though!!

22 Feb 2014 pakarat dung

thank youuuu

07 Jan 2014 Jack Claudiu

30 Dec 2013 Vipin Kamble

Great Work .. !!!!

17 Nov 2013 Nehal Patel

great your code it is not show eigenvalue is just recognize face with train image.can you tell me how to show eigenvalue?

31 Oct 2013 KARTHIK

Can the anyone tell me why the Eigenfaces is 36000*19 instead of 36000*20?

03 Sep 2013 Jai Gupta

@shruti, were u able to connect webcam and compare pictures taken by it with your database. i want to do the same, if anyone else can also help?

Comment only
12 May 2013 Shruti

Shruti (view profile)

great work!! i have created my own traindatabase , but if i eliminate test database and try to take the test image via webcam and store it directly into a matlab variable and then run the program , it is not recognising my image but rather match some other face in the traindatabase.. i have resized test image appropriately and no errors are found when i run the code.. just face recognition fails... please suggest if i need to make any changes in the code or any other measures need to be taken into account while image capture through webcam like lighting. or any specific background needed.. please reply and help me ..

Comment only
27 Mar 2013 Ibraheem Al-Dhamari

Thanks for the nice work. Try to add 2D PCA implementation.

07 Nov 2012 Caelyn Low

13 Aug 2012 debasish

debasish (view profile)

13 Jun 2012 debasish

debasish (view profile)

great work indeed!!very neatly computed!...I will be very happy if you can suggest how we can reject non-face images by calculating the Euclidean distance of the mean/centered test image from the face space??(Re:"Pentland and Turk:Eigenfaces for Recognition)

09 Jun 2012 Shamir Alavi

I've run the code several times using my own face database and it seems its trying to recognize on the basis of same file names in both training and test folders !!! I changed the file names several times to check this theory and as suspected, the recognition came out to be wrong. Only once it truly recognized the same face having different file names. Most of the times, it was just matching both 1.jpg files regardless of whose picture i put there.

09 Jun 2012 Moussab Bennehar


I noticed that you don't sort the eigenvectors at all. All you did was keeping the eigenvalues that are greater than 1 and their associated eigenvectors.
Can you tell me why please.

26 May 2012 Kyle Lee

Can the author or anyone tell me why the Eigenfaces is 36000*19 instead of 36000*20? Why the D[1 1] would be negative value that causes the dimemsion to be 19?

Comment only
20 May 2012 Partha Bera


22 Feb 2012 kumar reddy


Comment only
28 Nov 2011 Mingqin


28 Nov 2011 Ramya loganathan

nice work.... very thanks.. when i am trying to import another photos but it shows
??? Error using ==> horzcat
CAT arguments dimensions are not consistent.

Error in ==> CreateDatabase at 47
T = [T temp]; % 'T' grows after each turn

Error in ==> example at 26
T = CreateDatabase(TrainDatabasePath); how to clear this errors... any one help me to clear this error..........

Comment only
27 Aug 2011 Liam Mescall

Impressive - thanks for the help

Comment only
22 Jul 2011 Divya Muralitharan

its really a great job...

13 Apr 2011 sanyuktha

A really excellent piece of work. Thank You.
How to make this program reject unknon faces(those faces which are not in train database)?

Comment only
03 Mar 2011 dwi arliani

how to get the original eigenvalue (without eliminating eigenvalue under threshold)?because it cause error when i run Recognition.m.
it says "minus
Matrix dimensions must agree." because i realize that eigenfaces result is 19x20.. but the testing image is 20x20..
thx for your help :)

Comment only
06 Feb 2011 Anselm Griffin

Like all the other comments well done. Simple and to the point

12 Dec 2010 Muhamad nasri

good, but I found a little problem, when running EigenfaceCore.m, says "??? Input Argument 'T' is undefined", how to solved this problem ?? please to help me

02 Jul 2010 Namal Fernando

This is a really great work sir... But can I know how we can train this system to identify new faces.

25 Apr 2010 Ganesh AS

Hello, taking 19 of 20 eigen values is no feature extraction :D

Comment only
27 Mar 2010 raja

raja (view profile)

great work sir...i can understand it easily as it is commented well..thanks

05 Jan 2010 Alex

Alex (view profile)

Code is well commented and it works well, however, the images used for training are the same that are used for testing. No wonder it works!

29 Jul 2009 manzoor lone

i am very very very happy with with the pca based face recognition

Comment only
28 Jul 2009 daba Dabarera

Thank you very much!

29 Apr 2009 Nick Yeow

i am trying to use eigenface method in my project (face recognition via web cam).
but when i try import other picture into training & test image then run it. But error message pop-up
:"All matrices on a row in the bracketed expression must have the
same number of rows"
Any ideals to solve it?
thanks..very appreciate

27 Apr 2009 Sergio Rodriguez

13 Apr 2009 Hanaa

Hanaa (view profile)


How do you detect facial features using template matching?

I'll be very grateful for your help. Thanks! :)

Comment only
07 Dec 2008 sara

sara (view profile)

good job ,thank you

09 Nov 2008 Emmanuel Muring

very very thankful..but i need a program that detect a fece so i can interface it with the face recognition program..God bless

Comment only
18 Oct 2008 hba osman

12 Jun 2008 Abdullah Janazerah

you r great man

Comment only
06 Jun 2008 lili chen

05 Jun 2008 lili chen

Very good

31 May 2008 maggie King


24 Apr 2008 abc xyz

simple, nicely implemented, commented extremely well

13 Feb 2008 Qureshi i

Good job done

29 Dec 2007 karl karlos


Contact us