csci5521/assignments/hwk02/Eigenfaces.m

18 lines
414 B
Mathematica
Raw Normal View History

2023-10-12 23:51:06 +00:00
% implements Eigenfaces, returns nothings but displays a plot of the first
% 5 eigenvectors
function [] = Eigenfaces(training_data, test_data)
2023-10-22 04:32:00 +00:00
% stack data
data = vertcat(training_data, test_data);
2023-10-12 23:51:06 +00:00
2023-10-22 04:32:00 +00:00
% perform PCA
coeff = pca(data);
2023-10-12 23:51:06 +00:00
2023-10-22 04:32:00 +00:00
% show the first 5 eigenvectors (see homework for example)
for i = 1:5
subplot(3,2,i)
imagesc(reshape(coeff(:,i),32,30)');
end
% pause;
2023-10-12 23:51:06 +00:00
end % Function end