%
% Optical Imaging and Spectroscopy
%
% David J. Brady
% Duke University
% www.opticalimaging.org
%
% Figures 8.11 and 8.12
%
% LG analysis of the sampling from Fig. 3.9
% 
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);
%f=exp(-100*(xA+1).^2)+exp(-100*(xA-1).^2);
ds=kron(eye(16),ones(1,64));
ds=circshift(ds',32)';
fd=ds*f';
%fuI=interp1(fd'/64,linspace(1,16,1024),'spline');
fu=minLS(ds,fd);
fuLG=nullSpaceSmoothing(null(ds),fu);
figure(1);set(gcf,'color','white');colormap gray;
subplot(3,1,1);plot(xA,[f; fu'],'-k');title('(a)');
subplot(3,1,2);plot(xA,[f; fuLG'],'-k');title('(b)');
%subplot(3,1,3);plot(xA,[f;fuI],'-k');title('(c)');
subplot(3,1,3);imagesc(ds); axis tight;title('(c)');
[x,y]=meshgrid(xA,-7:8);
%ds=kron(round(0.7*rand(16,1024)),ones(1)).*(exp(-4*(x-y).^2)+exp(-4*(x+y).^2));
ds=abs(sinc(8*(x-y)));
ds=circshift(ds',32)';
fd=ds*f';
fu=minLS(ds,fd);
fuLG=nullSpaceSmoothing(null(ds),fu);
figure(2);set(gcf,'color','white'); colormap gray;
subplot(3,1,1);plot(xA,[f; fu'],'-k');title('(a)');
subplot(3,1,2);plot(xA,[f; fuLG'],'-k');title('(b)');
subplot(3,1,3);plot(xA,abs(sinc(8*xA)),'-k');title('(c)');
%subplot(3,1,3);imagesc(ds);axis off; axis tight;title('(c)');