ECEN 4616/5616 Jan 30, 2013 1 Scalar Diffraction Plane Wave Spectrum: In the previous lecture, we showed that a general plane wave solution to the ElectroMagnetic wave equation can be written as: E(r, t ) A cosk r t Or, in complex exponential notation: E exp i k x x k y y k z z t , where the dot product between the position and wave vectors has been expanded, and the Real() function is assumed. This plane wave is uniquely identified by its intersection with the x,y,z=0 plane at t=0, if the wavelength is known. This intersection is defined by the equations: E exp i k x x k y y , or E A expi 2 ux vy , where the variable subsitutions: u=kx/2, v=ky/2 have been made, where u,v are spatial frequencies and the expression fits into the definition of the Fourier Transform between a function and the spatial frequencies that compose it, via the transform pair: Au , v E x, y exp i 2 ux vy dx dy E x, y Au , v exp i 2 ux vy du dv Note: The spatial frequency representation above (boxed equation) describes the intersection of a plane wave with the x,y,z=0 plane at t=0 – it is not a plane wave, nor is it a solution of the EM Wave equation. It is, in fact, a static 2-D function that changes sinusoidally in a particular direction with a particular cycle length. In the Discrete Fourier Transform, each spatial frequency has an integral number of cycles over the array. An example of a spatial frequency function is shown in two views below: ECEN 4616/5616 Jan 30, 2013 2 The result of these manipulations is that we can decompose a harmonic (sinusoidal in time) field in an aperture into a set of spatial frequencies, each of which uniquely identifies a plane wave (given the harmonic frequency, or the wavelength of the plane waves). This collection of plane waves we call the “Plane Wave Spectrum” (PWS) of the field. This set of plane waves, intersecting at the x,y,z=0 plane would re-create the field. We can, of course, use the Fourier Transform to decompose any 2D function into spatial frequencies – however, identifying the spatial frequency spectrum as a Plane Wave Spectrum only makes sense if the field is created by EM waves (as with an illuminated aperture), or can be the source of EM waves (such as an antenna). Calculating PSFs from the Pupil Function (review): Every optical design program will give a pupil function as an amplitude and phase distortion from an ideal spherical wave at the exit pupil of an optical system. In this situation, the Point Spread Function (PSF) of the optical system can be calculated simply by finding the Plane Wave Spectrum of the pupil function. The curvature which was subtracted out can be conceptually re-inserted by assuming an ideal lens at the exit pupil with the appropriate focal length (the distance from the exit pupil to the image plane): ECEN 4616/5616 Jan 30, 2013 3 D x phi f The lens directs each component of the PWS to a specific point on the image plane. The angle of each plane wave and the focal length allow the scaling of the PSF to be calculated. A paraxial approximation can be made by assuming that all the points of the PSF are equally spaced, and equal to the spacing between the 0th and 1st plane waves in, say, the x-z plane. This would give x f , where f is the distance to the image plane, and D D is the size of the digital array (not necessarily the size of the pupil, which may be embedded in a larger array of zeros). Non-paraxially, one can calculate (from the geometry) the direction cosines for each element of the PWS and determine which point on the image plane that element is directed to. This will give a non-uniformly spaced array, which can be resampled into a uninform array (by Matlab’s “interp2.m” function, for example). Calculating through-focus PSFs from the Pupil function: Often, we wish to calculate the shape of the PSF when the optical system is out of focus (or, equivalently, at positions before or after the image plane). This can be done by adding phase curvature to the pupil function. There is no reason not to use the paraxial c assumption that a sphere is r 2 , where c is the power and r is the radial distance from 2 the z-axis, since wavefront sags (at the edge of the pupil) of only a few wavelengths will result in significant defocus. Note that we can identify the curvature of the wavefront directly with power. The distance from the image plane that this represents can be determined by the thin lens combination equation: 1 1 c f z f ECEN 4616/5616 Jan 30, 2013 Digitally, if we have a pupil function, P, we can add curvature by the expression: P = P*exp(i*2*pi*c*r2). Following are examples of calculating the thru-focus PSFs (and associated MTFs) of a perfect optical system. The code that produces these images is in Appendix A. PSFs Through Focus 4 ECEN 4616/5616 Jan 30, 2013 MTFs Through focus Extended Depth of Field (EDOF) Optical Systems: If we add, for example, a cubic phase distortion to the pupil, and then look at the PSFs and MTFs through focus, we see a remarkable result. First, the cubic distortion is exp(i*a*(x3 + y3)), and looks like this: Through-focus PSFs and MTFs for a pupil with 1.5 (at edge of pupil) cubic phase: 5 ECEN 4616/5616 Jan 30, 2013 6 Cubic PSFs Through Focus Cubic Phase MTFs Through Focus Compared with the PSFs and MTFs of a perfect system, the cubic phase system has significantly less change through focus, at the expense of somewhat reduced MTFs. Note, that there are no zeros in the MTFs, however, so that information has not been lost. ECEN 4616/5616 Jan 30, 2013 7 The PSFs (and hence the image) and the MTFs can be recovered from a cubic phase system by digital filtering. If the PSFs are constant enough, a single filter will suffice for a wide defocus range. The Matlab code that produced the above plots is listed in Appendix B. Propagation of a Plane Wave: Referring back to the equation of a plane wave: E A exp i k x x k y y k z z t The intersection (spatial frequency) of this wave with the plane x,y,z=0 at t=0 is: E Aei exp i k x x k y y . Aei exp i 2 ux vy Evidently, the spatial frequencies on a plane x,y,z, down the z-axis will be: E Aei exp i k x x k y y k z z Aei k z z exp i 2 ux vy All we have to do, therefore, is to multiply each component of the PWS by exp(ikzz), where the kz is specific to that component. This will give us the spatial frequency spectrum on the x,y plane at z, which we can then inverse transform to get the propagated field. Details, details: The PWS, as returned by the FFT, does not identify the spatial frequencies. They are identified by the order in which the spectrum is arranged. We will list the order as the number of cycles over the array (which is a whole number). For an odd length, N, of input array the frequencies are: N 1 N 1 0,1,2, , 2 , 2 , ,1 , and for N even: N N 0,1,2, , 2 1, 2 , ,1 . The odd length array is more symmetrical and less prone to induce “fencepost” errors while coding. Modern computers are so fast that it usually isn’t worth the trouble to use array lengths that are powers of two (which the FFT does the fastest). If, for example, the number of periods for the x-direction of one component is m, then we can find the x-direction cosine and kx by: ECEN 4616/5616 Jan 30, 2013 u 8 m m N x D m D Once both kx and ky are found, kz can be found by the expression: k x 2u 2 kz k 2 k x2 k y2 2 2 k x2 k y2 The propagation phase, kz*Z can then be calculated and added to the spatial frequency for that component of the PWS to get the corresponding spatial frequency at the destination plane. These spatial frequencies can then be summed up to get the propagated field. Still more problems with the DFT: The Discrete Fourier Transform is done on a finite number of points, say N, and produces the same number of spatial frequencies. These spatial frequencies are only orthogonal if they have an integer number of cycles across the array. This can cause problems due to the “phantom” copies of the frequencies that conceptually exist beyond N. For example, the spatial frequency decomposition of a retangular pulse is shown below: ECEN 4616/5616 Jan 30, 2013 When these components are added up, they re-create exactly the rectangular pulse. All of these components repeat every N points, however: 9 ECEN 4616/5616 Jan 30, 2013 10 When we add up the extended spatial frequency components, we get the pulse repeated every N points: When we are using the described method of beam propagation, we are not only propagating light from the central aperture, but from every copy of it, conceptually extending to . If the beam spreads far enough that light overlaps from adjacent copies of the pupil, spurious data will result. ECEN 4616/5616 Jan 30, 2013 Beam Propagation Example: Zone Plate: (The code that does this is in Appendix C.) A zone plate designed for a wavelength of 0.5 micron and a focal length of 1000 mm: The light intensity plotted near the focal length – the zone plate works as a lens. 11 ECEN 4616/5616 Jan 30, 2013 Appendix A: Thru-focus PSF calculations: %FILE: ThruFocusDemo.m %Demonstrates calculation of thru-focus PSFs % %Make the array 5 times the size of the pupil, % for adequate PSF resolution: Asize = 5; N = 101; %Size of array; x = linspace(-Asize,Asize,N); [X,Y] = meshgrid(x,x); R = sqrt(X.^2 + Y.^2); %R is now an array with values equal to the distance % from the center of the N x N array: %Create a circular, uniform pupil: P = zeros(N,N); P(R<=1) = 1; % Defocus = -2:.5:2; %Array of defocus amounts to use on Pupil %The defocus is in waves at the edge of the pupil: NDefocus = length(Defocus); %Calculate the psf through focus: PSFs = zeros(N,N,1,NDefocus); for ii = 1:NDefocus DF = exp(i*2*pi*Defocus(ii)*R.^2); DF(P==0) = 0; %Truncate to aperture DP = P.*DF; %Defocus phase added to pupil %Transform and square the pupil to get the PSF array: psf = abs(fftshift(fft2(ifftshift(DP)))).^2; %Normalize the psf: psf = psf/max(max(psf)); PSFs(:,:,1,ii) = psf; %Calculate the MTFs while we're at it: %(We don't use 'fftshift', since we only want to extract % a central slice, and that will be at the edge of the % array before shifting.) mtf = abs(fft2(psf)); mtf = mtf(1,1:20)'; mtf = mtf/max(mtf); %Normalize to 1.0 MTFs(:,ii) = mtf; end % %Create a montage of the through-focus PSFs figure montage(PSFs) title('-2\lambda : 0.5\lambda : 2\lambda Misfocus') %Plot the associated MTFs: xm = linspace(0,1,length(mtf)); figure for ii = 1:NDefocus subplot(3,3,ii) plot(xm,MTFs(:,ii)) title(['Defocus: ' num2str(Defocus(ii)) ' \lambda']); end 12 ECEN 4616/5616 Jan 30, 2013 Appendix B: Extended depth of field calculations %FILE: ThruFocusEDOF.m %Demonstrates extended depth of field % for a cubic phase pupil % %Make the array 5 times the size of the pupil, % for adequate PSF resolution: Asize = 5; N = 101; %Size of array; x = linspace(-Asize,Asize,N); [X,Y] = meshgrid(x,x); R = sqrt(X.^2 + Y.^2); %R is now an array with values equal to the distance % from the center of the N x N array: %Create a circular, uniform pupil: P = zeros(N,N); P(R<=1) = 1; % %Add cubic phase to the pupil: Ac = 1.5; %Waves of cubic phase at edge of pupil C = Ac*(X.^3 + Y.^3); P = P.*exp(i*2*pi*C); P(R>1) = 0; %Clip amplitude and phase to actual pupil size. % Defocus = -2:.5:2; %Array of defocus amounts to use on Pupil %The defocus is in waves at the edge of the pupil: NDefocus = length(Defocus); %Calculate the psf through focus: PSFs = zeros(N,N,1,NDefocus); for ii = 1:NDefocus DF = exp(i*2*pi*Defocus(ii)*R.^2); DF(P==0) = 0; %Truncate to aperture DP = P.*DF; %Defocus phase added to pupil %Transform and square the pupil to get the PSF array: psf = abs(fftshift(fft2(ifftshift(DP)))).^2; %Normalize the psf: psf = psf/max(max(psf)); PSFs(:,:,1,ii) = psf; %Calculate the MTFs while we're at it: %(We don't use 'fftshift', since we only want to extract % a central slice, and that will be at the edge of the % array before shifting.) mtf = abs(fft2(psf)); mtf = mtf(1,1:20)'; mtf = mtf/max(mtf); %Normalize to 1.0 MTFs(:,ii) = mtf; end % %Create a montage of the through-focus PSFs figure montage(PSFs) title('-2\lambda : 0.5\lambda : 2\lambda Misfocus') xlabel([num2str(Ac) ' \lambda cubic phase']) %Plot the associated MTFs: 13 ECEN 4616/5616 Jan 30, 2013 xm = linspace(0,1,length(mtf)); figure for ii = 1:NDefocus subplot(3,3,ii) plot(xm,MTFs(:,ii)) title(['Defocus: ' num2str(Defocus(ii)) ' \lambda']); end Appendix C: Beam Propagation (Zone Plate) %FILE: ZonePlateDemo.m %Demonstrates Fourier propagation of light thru zone plate % %*********Input Parameters************************** %Wavelength of the light (mm) Lam = 0.5e-3; %(0.5 microns) k = 2*pi/Lam; %Wavenumber %Size of the array (mm): D = 10; %Diameter of the Zone Plate: ZPdia = 5; %(mm) %Number of samples across the array: N = 501; %Focal length of the zone plate: Zfl = 1000; %(mm) %Distances to propagate the field (mm): Z = Zfl-400:100:Zfl+400; %*************************************************** %Construct the zone plate: x = linspace(-D/2,D/2,N); [X,Y] = meshgrid(x,x); R = sqrt(X.^2 + Y.^2); %R is now an array with values equal to the distance % from the center of the N x N array: %Find approximate (paraxial) zone plate zone edges: ZPzones = sqrt(Zfl*Lam : Zfl*Lam : (ZPdia/2)^2); %Fill in the Zone Plate: Lz = length(ZPzones); Fill = 1; P = zeros(N,N); for ii = Lz:-1:1 rz = ZPzones(ii); if Fill == 0 P(R<rz) = 1; Fill = 1; else P(R<rz) = 0; Fill = 0; end end figure(1) imagesc(P),axis image, colormap(gray) title(['Zone Plate for ' num2str(Zfl) ' mm fl; \lambda = ' num2str(Lam*1000) '\mum']) xlabel(['Zone Plate diameter = ' num2str(ZPdia) ' (mm)']) 14 ECEN 4616/5616 Jan 30, 2013 set(gca,'XTickLabel',[]) set(gca,'YTickLabel',[]) %*************************************************** %**********Calculate the Plane Wave Spectrum*********** % (Don't bother with fftshift, as results will be re-transformed) PWS = fft2(P); % %*********Find the FFT Frequencies******************* %Construct an array of FFT frequencies: % (This should be a seperate function) %Is N odd or even? if N/2 == floor(N/2) %(N even) FreqArray = [0:(N/2)-1 -(N/2):-1]; else %(N odd) FreqArray = [0:(N-1)/2 -(N-1)/2:-1]; end %Make arrays of x, y frequencies: [L,M] = meshgrid(FreqArray,FreqArray); % %*******Calculate the Propagation Phase Shift************ %Calculate the phase shift due to propagation of Z: kx = 2*pi/D * L; ky = 2*pi/D * M; %Arrays of kx, ky components % SqRtArg = k^2 - kx.^2 - ky.^2; %Remove any evanescent waves: SqRtArg(SqRtArg<0) = 0; %Find the z-component of the wave vector: kz = sqrt(SqRtArg); %kz is now an NxN array of kz components % %*********Propagate the field*************** Lz = length(Z); %PSFs = zeros(N,N,1,Lz); for ii = 1:Lz %Find the propagation phases: PropPhase = exp(i*kz*Z(ii)); %**********Find the field at Z**************** %Add the Propagation phase to the PWS: A2 = PWS.*PropPhase; %Convert the propagated PWS back to a field: P2 = ifft2(A2); %Display the intensity map of the field figure(2) psf = P2.*conj(P2); subplot(3,3,ii) imagesc(psf), axis image, colorbar, colormap('gray') set(gca,'XTickLabel',[]) set(gca,'YTickLabel',[]) title(['Distance: ' num2str(Z(ii)) ' mm']) end 15