%
%
% Optical Imaging and Spectroscopy
%
% David J. Brady
% Duke University
% www.opticalimaging.org
%
%
% 2D filters shown in Fig. 3.2
%
%
%square aperture
uScale=-1:.01:1;
xScale=-10:.01:10;
figure(1);
set(gcf,'color','white');
ip1=sinc(xScale)'*sinc(xScale);
subplot(3,3,1); imagesc(uScale,uScale,rect(uScale)'*rect(uScale));title('Square filter');axis 'square';colormap 'gray';
subplot(3,3,2); imagesc(xScale,xScale,ip1);title('Impulse response');axis 'square';colormap 'gray';
subplot(3,3,3); plot(xScale,sinc(xScale),'-k');title('Impulse response cross section');axis 'square';
% circular aperture
[x,y]=meshgrid(uScale,uScale);
pop=sqrt(x.^2+y.^2);
[xp,yp]=meshgrid(xScale,xScale);
pip=sqrt(xp.^2+yp.^2);
ip2=jinc(pip);
subplot(3,3,4); imagesc(uScale,uScale,rect(pop));title('Circular filter');axis 'square';colormap 'gray';
subplot(3,3,5); imagesc(xScale,xScale,ip2);title('Impulse response');axis 'square';colormap 'gray';
subplot(3,3,6); plot(xScale,ip2(1001,:),'-k');title('Impulse response cross section');axis 'square';
%
%Gaussian aperture
pop=(x.^2+y.^2);
[xp,yp]=meshgrid(xScale,xScale);
pip=(xp.^2+yp.^2);
ip3=exp(-pi*pip);
subplot(3,3,7); imagesc(uScale,uScale,exp(-pi*pop));title('Gaussian filter');axis 'square';colormap 'gray';xlabel('1/D');
subplot(3,3,8); imagesc(xScale,xScale,ip3);title('Impulse response');axis 'square';colormap 'gray';xlabel('D');
subplot(3,3,9); plot(xScale,ip3(1001,:),'-k');title('Impulse response cross section');axis 'square';xlabel('D');
