On Sep 20, 10:32 pm, "anirbid.baner...@gmail.com"
<anirbid.baner...@gmail.com> wrote:
> Hello,
>
> I am using the following matlab code to implement the principal
> component analysis algorithm for face recognition. I have used nImg =
> 100 images for the training set and I have generated eigenvectors(V)
> and eigenvalues (D) corresponding to these 100 images. Now I would
> like to construct eigenfaces from this set. The matrices v,d
> correspond to the eigenvectors and eigenvalues of the eigenfaces.
> However, I am stuck at this particular point. I am comparing the
> eigenvalues of D w.r.t a number say 0.05, I am getting the entire V,
> D. The if condition is returning values greater/less than 0.05. Where
> I am mistaken?
>
> Thanks for your advice.
>
What is C? How is it determined from 100 images?
> ...
> ...
> % Find Eigenvectors and eigenvalues V, D
> [V, D] = eig(C);
C must be square
> % Find Eigenfaces  that is eliminate all the eigenvectors that have
> % v,d are the nonzero eigenvectors and eigenvalues corresponding to
> nImg'
> % where nImg' < nImg
>
> v=[];
> d=[];
> for icnt = 1:size(V,2)
> if (D(icnt,icnt) >= 0.05)
> v = [v V(:,icnt)];
> d = [d D(icnt,icnt)];
> end
> end
> close all;
d = fliplr(diag(D)); % Monotonically nonascending order
v = fliplr(V);
t = sum(d) % = trace(D)
You have to determine the pseudorank, r, by specifying cutoff
values for eigenvalues or pseudotrace = sum of eigenvalues.
Three criteria for determining the pseudorank, r, come to mind
1. Use the default tol defined to determine rank(C) = rank(D)
help rank
tol = max(size(C)) * norm(C) * eps
d(r) > tol >= d(r+1)
2. Specify d(r+1) as a specified % of d(1) = max(d)
d(r) > 0.01*d(1) >= d(r+1)
3. Specify sum(d(1:r)) as a specified % of t = sum(d)
sum(d(1:r)) >= 0.95 > sum(d(1:r1)
I prefer the third criterion.
Hope this helps.
Greg
