File Exchange

image thumbnail

Karhunen-Loeve Decomposition for Statistical Recognition and Detection

version 1.0.0.0 (1.52 KB) by Alex Chirokov
Karhunen-Loeve Decomposition for Face Recognition

22 Downloads

Updated 07 Nov 2005

No License

This MATLAB script implements Karhunen-Loeve decomposition which is classical algorithm for face recognition and detection. Script uses ATT faces database http://www.uk.research.att.com/facesataglance.html
which can be downloaded from
http://www.uk.research.att.com/facedatabase.html

Computing Eigenvalues and Eigenvectors of images set
Encoding Face Images with a Linear Combination Key (KL decomposition)
Decoding a Key into an Image (reconstruction)
Comparing images using key, searching for similar images.

Comments and Ratings (23)

sara

Ivelina Stefanova

Easy to grasp, straightforward, with nice visualization.

troy rainmaker

Works fine. Short and efficient.

Anton Kylling

Just what i needed to debug my own code

mahmoud sayed

ma ng

it's ok

christian cabrera

Ithink it would work i just have found it and i think i need the database you have in the link but ist is broken i Would like to know if you can send me the files or xplain somewhere hhow do we have to choose the data base... Thanks ...

swathi reddy

The MATLAB script is excellent. It helped me a lot for my class project. ThankYou so much Alex chirokov. nice job :)

chat sang

it ok

venki raj

nice to work with

wei zhang

The codes are effective in detecting human
faces

l l

Error in ==>\KarhunenLoeve.m
On line 19 ==> x = double(x)/255;
%convert to double and normalize
can not work! anyone help me?

K GOPAL

Quite Appreciable Work.....

Jerome Bahans

Very clear, interesting, perfect !

Agu Osoka

Just skimmed through and it works fine. Good stuff!!!

Mutaz Shukair

Really very great function, I liked it specially it is easy to follow up and to understand.

Alexandre Chirokov

Dear Paul Silvanovich

this line needed to normalize vectors
V = x*V*(abs(D))^-0.5;

[V,D] = eig(cov_mat);
returns unit eigen vectors.

V = x*V; !this line will produce non-unit vectors

one way to normalize them is to do this
V = x*V*(abs(D))^-0.5;
(but this is not the only way)

check it with: norm(V);

Alex Chirokov

Dear Paul Silvanovich

The algorithm to transform images into eigenfaces is described well in Turk and Pentland [1], but I will describe it briefly here. Each image could be represented as a matrix of MxN pixels, with each element an 8-bit grayscale value. If all images are represented as such, they can each be turned into a vector of length MN. Next, the average face can be found, and each image can then be represented as a difference from the average. The difference vectors can then all be used as columns in a matrix A (matrix x in the code). The eigenfaces are then the eigenvectors of the covariance matrix C = A*A' (A' - is the transpose of A). However, since images are very high dimensional, the covariance matrix is likely quite large (if images are 92x112, C will be huge 10304x10304 ), thus a straightforward eigenvector computation is prohibitively expensive.
This problem can be solved by noticing that in the equation
A*A'*A*vi = u*A*vi,
the eigenvectors of C are A*vi, where vi are the eigenvectors of A'*A, which is a square matrix with dimension equal to the number of images in the data set. Since the number of images in the data set is usually much less than the size of an image, this computation is likely to be tractable.

[1] M. Turk, and A. Pentland, ?Eigenfaces for Recognition,? Journal of Cognitive
Neuroscience, vol. 3, no. 1, pp. 71-86, 1991.

Paul Silvanovich

What for in KarhunenLoeve.m
V = x*V*(abs(D))^-0.5; ?

low weiwei

i like it!

Anas Qutieshat

very intersting :)
but found it hard to go through the code

Updates

1.0.0.0

Code was updated to find the most similar and the most different faces. Also distance map of face database is now computed and shown.

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