24 lines
No EOL
749 B
Matlab
24 lines
No EOL
749 B
Matlab
% implements the Back Projection algorithm, returns nothing but displays
|
|
% the first 5 eigenfaces of the training data after being 'back-projected'
|
|
% using the first 10, 50, and 100 eigenvectors of the data.
|
|
function [] = Back_Project(training_data, test_data, n_components)
|
|
|
|
% stack data
|
|
data = vertcat(training_data, test_data);
|
|
|
|
% perform PCA
|
|
coeff = pca(data);
|
|
|
|
% for each number of principal components
|
|
for n_idx = 1:length(n_components)
|
|
n = n_components(n_idx);
|
|
|
|
% TODO: perform the back projection algorithm using the first n_components(n) principal components
|
|
W = coeff(:,1:n);
|
|
|
|
% TODO: plot first 5 images back projected using the first
|
|
% n_components(n) principal components
|
|
|
|
end
|
|
|
|
end % Function end |