-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWPCA_Svd.m
More file actions
22 lines (15 loc) · 783 Bytes
/
WPCA_Svd.m
File metadata and controls
22 lines (15 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
% Author : Cong Jie, Ng
% Paper : Ng, C. J., and Teoh, A. B. J. "DCTNet: A Simple Learning-Free Approach for Face Recognition." In 2015 Asia-Pacific Signal and Information Processing Association Annual Summit and Conference (APSIPA), 761-68, 2015.
function projMat = WPCA_Svd(X, dimension)
rglEpsilon = 0.001;
X = bsxfun(@minus, X, mean(X, 2));
[eigVectors_PCA, eigValues_PCA, ~] = svd(X, 0);
eigVectors_PCA = eigVectors_PCA(:, 1 : dimension);
eigVectors_PCA = eigVectors_PCA';
assert(size(eigVectors_PCA, 1) == dimension);
eigValues_PCA = diag(eigValues_PCA.^2);
eigValues_PCA = eigValues_PCA(1 : dimension);
% Whitening PCA
eigValues_wPCA = diag(1./sqrt(eigValues_PCA + rglEpsilon));
projMat = eigValues_wPCA * eigVectors_PCA;
end