-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathfisherfaces.m
More file actions
29 lines (29 loc) · 737 Bytes
/
fisherfaces.m
File metadata and controls
29 lines (29 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
%% FischerFaces
% Input: X, y, k, Training Label, Training Data, Testing Labels, Testing
% Data
%Output: W, mu, Accuracy
% Note: Run from RunFF.m
function [W , mu,acc ] = fisherfaces (X ,y ,k,labeltr,train,labelte,test )
% number of samples
N = size(X,1);
% number of classes
labels = unique (y) ;
c = length ( labels );
if( nargin < 3)
k = c -1;
end
k = min (k ,(c -1) );
% get (N-c) principal components
[ Wpca , mu ] = pca2(X , y , 50) ;
[ Wlda , mu_lda ] = lda2( project ( Wpca , X , mu ) , y , k);
W = Wpca * Wlda ;
[outlabel] = outputlabel(W,mu,labeltr,train,labelte,test,k);
%% Accuracy
for i=1:length(labelte)
if(labelte(i,1)==outlabel(i,1))
count = count+1;
end
end
acc=count/length(labelte)
% err=1-acc
end