-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlda.m
30 lines (26 loc) · 1.01 KB
/
lda.m
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
30
function [LowData, projMat, pcaProj, meanData] = lda(HiData, labelVec, para)
%% DESCRIPTION
% The function is to do dimension reduction for the HiData by LDA.
%
% INPUT:
% HiData: the data matrix whose each column stands for one
% image data;
% labelVec: the subject label for each image in HiData;
% para: the parameters required for the dimension
% reduction method.
%
% OUTPUT:
% LowData: the low-dimensional Data after LDA projection;
% projMat: the projection matrix for dimension reduction;
% meanData: the mean vector of the vectors in HiData.
%
% VERSION:
% 0.1 - 01/01/2013 First implementation,
% Matlab 2012a
%% PCA pre-processing
[pcaHiData, pcaProj, meanData] = pca(HiData, para);
%% Apply LDA
[~, ldaProj] = lda_core(pcaHiData, labelVec, para.ldaDim);
projMat = pcaProj*ldaProj;
LowData = ldaProj'*pcaHiData;
end