%
% Optical Imaging and Spectroscopy
%
% David J. Brady
% Duke University
% www.opticalimaging.org
%
% Figure 4.16
%
% high pass imaging
%
figure(2);set(gcf,'color','white');
imgD=imread('ghost.jpg');
imgD=double(imgD(:,:,1));
imgD=imgD(400:944,75:610);
pip=size(imgD);
imgD=interp2(imgD,linspace(1,pip(2),256),linspace(1,pip(1),256)');
imgD=max(max(imgD))-imgD;
xrange=linspace(-128,128,256);
subplot(2,2,1);imagesc(xrange,xrange,imgD);colormap 'gray'; axis square;
title('original image');xlabel('wavelengths');
imgD=[zeros(256),zeros(256);zeros(256),imgD];
fnumber=1;
apertureRange=linspace(-1,1,512);
[x,y]=meshgrid(apertureRange,apertureRange);
field=sqrt(x.^2+y.^2);
lowPassFilter=P(fnumber*field);
imgL=fftshift(ifft2(lowPassFilter.*fftshift(fft2(imgD))));
imgL=abs(imgL(1:256,1:256));
subplot(2,2,2);imagesc(xrange,xrange,imgL);colormap 'gray'; axis square;
title('low pass image');xlabel('wavelengths');
highPassFilter=P(fnumber*field)-P((1/.2)*fnumber*field);
imgL=fftshift(ifft2(highPassFilter.*fftshift(fft2(imgD))));
imgL=abs(imgL(1:256,1:256));
subplot(2,2,3);imagesc(xrange,xrange,imgL);colormap 'gray'; axis square;
title('.8 high pass image');xlabel('wavelengths');
highPassFilter=P(fnumber*field)-P((1/.9)*fnumber*field);
imgL=fftshift(ifft2(highPassFilter.*fftshift(fft2(imgD))));
imgL=abs(imgL(1:256,1:256));
subplot(2,2,4);imagesc(xrange,xrange,imgL);colormap 'gray'; axis square;
title('.1 high pass image');xlabel('wavelengths');