%
% Optical Imaging and Spectroscopy
%
% David J. Brady
% Duke University
% www.opticalimaging.org
%
% Figure 3.13 and 3.14
%
% wavelet decomposition
%
foo=imread('faraday.jpg');
foo=single(foo(:,:,1));
foo=interp2(foo,linspace(1,size(foo,2),768)',linspace(1,size(foo,1),1024));
figure(1);
set(gcf,'color','white');axis image; axis off;colormap gray;
subplot(1,2,1);imagesc(foo);axis image; axis off;title('(a)');
[C, S]=wavedec2(foo,3,'Haar');
Cp=[reshape(C(1:(S(1,1)*S(1,2))),S(1,1),S(1,2)), ];
subplot(1,2,2);imagesc(Cp);axis image; axis off;title('(b)')
figure(2);
set(gcf,'color','white');axis image; axis off;colormap gray;
Cp=[reshape(C((S(1,1)*S(1,2)+1):(2*S(1,1)*S(1,2))),S(1,1),S(1,2)), reshape(C((2*S(1,1)*S(1,2)+1):(3*S(1,1)*S(1,2))),S(1,1),S(1,2)),reshape(C((3*S(1,1)*S(1,2)+1):(4*S(1,1)*S(1,2))),S(1,1),S(1,2))];
subplot(3,1,1);imagesc(Cp);axis image; axis off;title('(a)');
Cp=[reshape(C((4*S(1,1)*S(1,2)+1):(4*S(1,1)*S(1,2)+S(3,1)*S(3,2))),S(3,1),S(3,2)),...
    reshape(C((4*S(1,1)*S(1,2)+S(3,1)*S(3,2)+1):(4*S(1,1)*S(1,2)+2*S(3,1)*S(3,2))),S(3,1),S(3,2)),...
    reshape(C((4*S(1,1)*S(1,2)+2*S(3,1)*S(3,2)+1):(4*S(1,1)*S(1,2)+3*S(3,1)*S(3,2))),S(3,1),S(3,2))];
subplot(3,1,2);imagesc(Cp);axis image; axis off;title('(b)');
Cp=[reshape(C((4*S(1,1)*S(1,2)+3*S(3,1)*S(3,2)+1):(4*S(1,1)*S(1,2)+3*S(3,1)*S(3,2)+S(4,1)*S(4,2))),S(4,1),S(4,2)),...
   reshape(C((4*S(1,1)*S(1,2)+3*S(3,1)*S(3,2)+S(4,1)*S(4,2)+1):(4*S(1,1)*S(1,2)+3*S(3,1)*S(3,2)+2*S(4,1)*S(4,2))),S(4,1),S(4,2)),...
   reshape(C((4*S(1,1)*S(1,2)+3*S(3,1)*S(3,2)+2*S(4,1)*S(4,2)+1):(4*S(1,1)*S(1,2)+3*S(3,1)*S(3,2)+3*S(4,1)*S(4,2))),S(4,1),S(4,2))];
subplot(3,1,3);imagesc(Cp);
axis image; axis off;title('(c)');
