% Optical Imaging and Spectroscopy
%
% David J. Brady
% Duke University
% www.opticalimaging.org
%
%
dog=imread('saturn.png');
figure(1);set(gcf,'color','white'); 
dog=single([dog(:,:,1) dog(:,:,2) dog(:,:,3)]);
subplot(3,1,1);imagesc(dog);axis off; colormap gray;
title('(a)');
[U, S, V]=svd(dog);
Ur=U(:,1:100);
subplot(3,1,2);imagesc(Ur*Ur'*dog);axis off; colormap gray;
title('(b)');
subplot(3,2,5);plot([Ur(:,1),Ur(:,2)+.05,Ur(:,3)+.1,Ur(:,4)+.2,Ur(:,5)+.3],'-k');
title('(c)');
dv=dog(:,300)/max(dog(:,300));
subplot(3,2,6);plot([dv,U(:,1:10)*U(:,1:10)'*dv+0.3,U(:,1:50)*U(:,1:50)'*dv+0.6,U(:,1:100)*U(:,1:100)'*dv+0.9],'-k');
title('(d)');