1 % =================================================================
2 % Sparse Feature Fidelity (SFF) Version 2.0
3 % Copyright(c) 2013 Hua-wen Chang
5 % ----------------------------------------------------------------
6 % WHITENING AND DIMENSIONALITY REDUCTION BY PCA
9 % X matrix with image patches as columns
12 % E principal component transformation (orthogonal)
13 % D variances of the principal components
14 % =================================================================
16 function [V,E,D] = pca(X)
19 covarianceMatrix = X*X'/size(X,2);
20 [E, D] = eig(covarianceMatrix);
21 [dummy,order] = sort(diag(-D));
24 dsqrtinv = real(d.^(-0.5));
25 Dsqrtinv = diag(dsqrtinv(order));