%
% Optical Imaging and Spectroscopy
%
% David J. Brady
% Duke University
% www.opticalimaging.org
%
% Figure 3.12
%
%
% zero order spline plot
% 
close all;
xA=linspace(-7.485, 8.5, 1024);
xS=xA(5)-xA(4);
figure(1);set(gcf,'color','white');
f=sin(pi*xA)+2.5+.8*cos(.3*pi*xA)+.001*xA.^3+5*exp(-20*(xA-pi).^2);
%level 0
ds=kron(eye(16),ones(1,64));
ds=circshift(ds',32)';
fd=ds*f'/64;
subplot(4,1,1);plot(fd+1,'-k');
axis([0 17 -1 8]); hold on;
ds=kron(eye(16),[ones(1,32),-ones(1,32)]);
ds=circshift(ds',32)';
fd=ds*f'/64;
subplot(4,1,1);plot(fd,'-k'); title('Level 0');
%level -1
ds=kron(eye(32),ones(1,32));
ds=circshift(ds',16)';
fd=ds*f'/32;
subplot(4,1,2);plot(fd+1,'-k');
axis([0 33 -1 8]); hold on;
ds=kron(eye(32),[ones(1,16),-ones(1,16)]);
ds=circshift(ds',16)';
fd=ds*f'/32;
subplot(4,1,2);plot(fd,'-k'); title('Level -1');
%level -2
ds=kron(eye(64),ones(1,16));
ds=circshift(ds',8)';
fd=ds*f'/16;
subplot(4,1,3);plot(fd+1,'-k');
axis([0 65 -1 8]); hold on;
ds=kron(eye(64),[ones(1,8),-ones(1,8)]);
ds=circshift(ds',8)';
fd=ds*f'/16;
subplot(4,1,3);plot(fd,'-k'); title('Level -2')
%level -3
ds=kron(eye(128),ones(1,8));
ds=circshift(ds',4)';
fd=ds*f'/8;
subplot(4,1,4);plot(fd+1,'-k');
axis([0 129 -1 8]); hold on;
ds=kron(eye(128),[ones(1,4),-ones(1,4)]);
ds=circshift(ds',4)';
fd=ds*f'/8;
subplot(4,1,4);plot(fd,'-k'); title('Level -3');

