Skip to content

Instantly share code, notes, and snippets.

@seaslee
Created November 12, 2012 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seaslee/4059578 to your computer and use it in GitHub Desktop.
Save seaslee/4059578 to your computer and use it in GitHub Desktop.
plot faces and eigenface
close all;
clear;
clc;
X=[];
for i=1:10,
x=imread([int2str(i) '.pgm']);
[w,h]=size(x);
x=reshape(x,w*h,1);
x=double(x);
X=[X x];
end
for i=1:10,
subplot(2,5,i);
I=X(:,i);
I=uint8(I);
u=reshape(I,w,h);
imshow(u);
end
hold on;
figure;
[U,S]=pca(X);
for i=1:10,
subplot(2,5,i);
I=U(:,i);
minI=min(I);
maxI=max(I);
I=(I-minI)/(maxI-minI);
I=I*255;
I=uint8(I);
u=reshape(I,w,h);
imshow(u);
colormap(jet(256));
title(sprintf('%f',S(i,i)));
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment