Created
November 12, 2012 14:05
-
-
Save seaslee/4059578 to your computer and use it in GitHub Desktop.
plot faces and eigenface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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