Demonstration Meeting - BYU -

Download Report

Transcript Demonstration Meeting - BYU -

Using MATLAB to Compute
Diffraction Patterns of
Complex Apertures
Stephen Schultz
Department of Electrical and Computer Engineering
Brigham Young University
SPIE Optics + Photonics
August 29, 2007
Lens Focus
• Fresnel becomes Fraunhofer at focal plane
• 2D Fourier transform
Ex, y, z   Co E f
x
x
f
fy 
• Take 2D transform of complex structures
– Slits
– Multiple slits
– Letters
– Pictures
– Fingerprints
SPIE Optics + Photonics
August 29, 2007
y
f
Fourier Transform with MATLAB
•
Built-in Fast Fourier Transform (FFT)
– Y = fft2(X)
– Performs a Discrete Fourier Transform (DFT)
M
N
F  p, q    f m, n e
 2 
 j
 pm
M 
e
 2 
 j
 qn
 N 
m 0 n 0
•
p  0, 1,, M  1
q  0,1,, N  1
– Uses the Cooley-Tukey algorithm
– Fastest with sizes 2n
Process
1. Discretize the aperture
2. Compute DFT
3. Relate integer parameter to spatial coordinates
SPIE Optics + Photonics
August 29, 2007
MATLAB Fourier Transform
1. Aperture discretization
• Create gray scale image in graphics program
– Black is blocking
– White is transmitting
– Gray scale would be variable amplitude
• Save as a gif file (In illustrator)
– Save for Web and Devices
– Set the image size (faster with 2n pixels)
– No transparency, not interlaced
• Read file into MATLAB
– A=imread(‘slit’, ‘gif’)
SPIE Optics + Photonics
August 29, 2007
MATLAB Fourier Transform
2. Computing DFT
•
Computing DFT
– Use the two-dimensional FFT command
E=fft2(A)
– Puts center of the beam in the corners
– Use the fftshift command to put it into the center
E=fftshift(fft2(A))
A=imread(‘slit’, ‘gif’)
fft2( A )
SPIE Optics + Photonics
August 29, 2007
fftshift( fft2( A ) )
Convert FFT to Continuous Fourier Transform (FT)
3. Spatial Coordinates
• FFT is a Discrete Fourier Transform (DFT)
We need to relate the DFT to the FT
• We will do this with a 1D analysis and then extend it to 2D
by just replacing the FFT command with FFT2
• Start with a sampled version of the g(x)
SPIE Optics + Photonics
August 29, 2007
Convert FFT to Continuous Fourier Transform (FT)
3. Spatial Coordinates
• Use an FFT, which is a discrete Fourier Transform (DFT)
N 1
G p    g n e
 2
 j
 N

 pm

p  0,1,, N  1
m 0
G(p)=fft(g)
1
0.5
0
0
20
p
40
60
G(p)=fftshift( fft(g) )
• MATLAB assumes that it starts at zero rather than –x so
you need to shift it using the fftshift command
1
0.5
0
0
SPIE Optics + Photonics
August 29, 2007
20
p
40
60
Convert FFT to Continuous Fourier Transform (FT)
3. Spatial Coordinates
• Convert the DFT to a discrete time Fourier transform
(DTFT)
– The index is scaled by the number in the array
– f=p/N
DTFT
1
0.5
0
−0.5
0
f=1/N
0.5
SPIE Optics + Photonics
August 29, 2007
Convert FFT to Continuous Fourier Transform (FT)
3. Spatial Coordinates
FT
1
0.5
0
−2
analytic FT sinc2 (fx)
• Convert the DTFT into a continuous Fourier transform (FT)
– Use the sampling period scaling factor x=Dx n
– fx=f/Dx
• Compare this to the analytic triangle function
1
0.5
0
fx=f / Dx
2
0
−2
SPIE Optics + Photonics
August 29, 2007
0
fx
2
Convert FFT to Continuous Fourier Transform (FT)
3. Spatial Coordinates
• Summary of spatial coordinates
– Relate to discrete frequency
– Relate to spatial frequency
f 
fx 
1
p
M
1 1
p
Dx M
– Fraunhofer diffraction relationship f x 
– Spatial coordinates x   f
x
f
1 1
1 1  N N
p f
  

Dx N
Dx N  2
2
SPIE Optics + Photonics
August 29, 2007
MATLAB Fourier Transform
3. Spatial Coordinates
•
For the FFT the number of frequency points equals the initial spatial
points
•
The spatial extent of the diffraction pattern x   f
•
More pixels causes the analysis plane to be bigger
M=256
1
x f
W
 M M
 2  2 


SPIE Optics + Photonics
August 29, 2007
1 1 N
1
  f
Dx N 2
2Dx
M=64
Spatial Resolution
3. Spatial Coordinates
• Spatial resolution, Dx, independent of number of pixels
x f
1 1  N N
  

Dx N  2
2
Dx   f
1 1
1
 f
Dx N
W
• Need larger image, W, without increasing slit size
– Accomplished with zero padding
SPIE Optics + Photonics
August 29, 2007
Summary of MATLAB Code
(2. Fraunhofer Diffraction)
• Fairly simple MATLAB coding (9 lines of code)
A = imread('slit','gif');
[M,N] = size(A);
lambda = 600e-9;
f = 16.5e-3;
W = 4e-3;
I = (fftshift(fft2(A))).^2;
x = linspace(-lambda*f*N/(2*W), lambda*f*N/(2*W), N);
y = linspace(-lambda*f*M/(2*W), lambda*f*M/(2*W), M);
pcolor(x, y, I)
• Most work done using graphics program
SPIE Optics + Photonics
August 29, 2007
Aperture Diffraction
• Rectangular aperture
– Slit size
• Cassegrain telescope
– Obscuration size
– Struts
SPIE Optics + Photonics
August 29, 2007
Fourier Transform of a Letter
(2. Fraunhofer Diffraction)
SPIE Optics + Photonics
August 29, 2007
Fourier Transform of a Word
(2. Fraunhofer Diffraction)
SPIE Optics + Photonics
August 29, 2007
Pattern Recognition
(2. Fraunhofer Diffraction)
SPIE Optics + Photonics
August 29, 2007
Optical Image Processing
(2. Fraunhofer Diffraction)
1. Perform Fourier transform on an image
2. Filter the image (low pass or high pass filter)
3. Perform another Fourier transform
SPIE Optics + Photonics
August 29, 2007
Experimental Implementation
(3. Experimental)
• Helps solidify what is happening
• Complimentary to simulations
– No approximations but few aperture variations
– Easy to look at transition between regimes
• Students learn sensitivities of optical image processing
– Alignment
– Opaqueness
SPIE Optics + Photonics
August 29, 2007
Experimental Implementation
(3. Experimental)
• Requirement to make the implementation practical
– Long focal length lenses
• Easier focusing
• Larger features (fx=x/f)
– Opaque masks
• Transparencies transferred to chrome mask
• Put various patterns on same mask
– Spatial filtered red laser
– Object is a simple transparency
SPIE Optics + Photonics
August 29, 2007
Implementation of 4F project
(3. Experimental)
SPIE Optics + Photonics
August 29, 2007
Fourier Plane Mask
(3. Experimental)
• Chrome on glass
• Multiple patterns on the
same mask
• Sizes from 10-370 mm
• Patterns
– Rectangular slits
– Rectangular blocks
– Circular holes
– Circular blocks
SPIE Optics + Photonics
August 29, 2007
Grid Filtering
(3. Experimental)
• Grid transparency
• Slit image plane mask
• Switch filter pattern by small shifts in mask
2.7 mm Grid with 110mm Filter Slit
2.7 mm Grid with 30mm Filter Slit
SPIE Optics + Photonics
August 29, 2007
Image Filtering
(3. Experimental)
SPIE Optics + Photonics
August 29, 2007
Blurring of an Image
(3. Experimental)
Original Image
Blurred Image
SPIE Optics + Photonics
August 29, 2007
Transition
(3. Experimental)
• Transition from image to spatial frequency
Image off-focus
Image at focus
SPIE Optics + Photonics
August 29, 2007