7/29/2019 Artikel Fisika Bahasa Inggris Tentang Optik-1
1/10
Using MATLAB to help teach Fourier optics
S. M. Schultz*aaDept. of Electrical and Computer Engineering, Brigham Young University, Provo, UT USA 84602
ABSTRACT
This paper discusses the development of a graduate level course that covers diffraction theory and Fourier optics.
MATLABTM
is used as the basic numerical tool for these projects. In addition to providing functions for the calculation
of Fresnel diffraction, the FFT command enables the calculation of the diffraction pattern of an arbitrary aperture.
Relatively simple MATLABTM
scripts are constructed to calculate the diffraction patterns of arbitrary graphics created in
other programs such as text, pictures of faces, fingerprints, etc. Furthermore, the resulting diffraction patterns can be
filtered and the same FFT commands be used to perform an inverse Fourier transform. This paper also describes a few
demonstrations that can be used to reinforce what is covered on the projects. The demonstrations are based on a simple
4F system. The first half of the 4F system is used to show how an illuminated image changes from a reduced version of
the image into a spatial frequency mapping. A Fourier plane mask is also created with small features on a chrome plated
photomask. Since the features are relatively small various different types aperture can be placed on the mask.
Keywords: Fourier Optics, numerical methods, teaching methods
1. INTRODUCTION
Diffraction theory is often taught as a purely mathematical treatment or used to analyze very simplistic apertures such as
slits and holes. The goal of this paper is to describe how the scientific analysis tool MATLAB can be used to perform
complex mathematical calculations without bogging down the students with the details of the exact numerical methods.
MATLAB enables the students to investigate diffraction phenomena and application. The simplified numerical program
is applied to both the Fresnel and the Fraunhofer diffraction domains. This paper is divided into three main sections (1)
Fresnel diffraction, (2) Fraunhofer diffraction and (3) experimental implementation.
2. FRESNEL DIFFRACTION
2.1 Fresnel Diffraction using MATLAB
The basic Fresnel integral is given by [1]
( ) ( ) ( ) ( )
= '''
2exp'
2exp',',,
22dydxyy
z
jkxx
z
jkyxECzyxE io , (1)
where Ei is the electric field at the z=0 plane. This integral is often very difficult to solve and is usually solved
numerically. Even though modern computer are fast enough perform this type of numerical integration, the solutions
typically take too long on a common desktop computer for simple class projects. The computation time can be
dramatically reduced by casting the diffraction equation into built-in MATLAB function. By using built in functions
MATLAB will be using look-up tables rather than numerical integration resulting in the dramatic reduction in
computation time. The MATLAB functions are the Fresnel cosine integral given by
( )
=
x
dttxC0
2
2cos
(2)
and the Fresnel sine integral
Invited Paper
Optics and Photonics for Information Processingedited by Abdul A. S. Awwal, Khan M. Iftekharuddin, Bahram Javidi
Proc. of SPIE Vol. 6695, 66950I, (2007) 0277-786X/07/$18 doi: 10.1117/12.735889
Proc. of SPIE Vol. 6695 66950I-1
7/29/2019 Artikel Fisika Bahasa Inggris Tentang Optik-1
2/10
H
( )
=
x
dttxS0
2
2sin
. (3)
These functions are called in MATLAB by mfun(FresnelC, x) and mfun(FresnelS, x). These built-in functions
require the MATLAB Symbolic Toolbox.
If the incident electric fieldEi has discrete values over various Cartesian regions then Eq. 1 can be cast into the additionand multiplication of various Fresnel integral. This binary requirement is applicable to analyzing structures such as
apertures, binary amplitude and phase gratings, etc. The diffraction integral (Eq. 1) is put in term of the Fresnel integrals
(Eqs. 2-3) by (1) breaking the exp term up into sine and cosine terms, (2) doing a series of variable substitutions, and (3)
breaking the integral up into terms that go from 0 tox.
2.2 Amplitude Diffraction Grating
A binary amplitude grating is a good representative example. Figure 1 shows a finite binary grating of total width Wand
gratings period . In this example the grating period is =30m, the total width is W=300m, the free-space
wavelength is =600nm, and the grating fill factor is 50%. Three basic concepts that can be taught with this examplestructure is near field diffraction, transition into grating orders, and transitioning in the Fraunhofer approximation.
Figure 1.
2.2.1 Near Field Diffraction (Talbot Image Planes)One of the interesting near-field phenomena is Talbot image in which the intensity is a replica of the grating at distances
ofz=2L2/ [2]. When the distance from the grating is half of the Talbot image distance then the intensity is also a
replica of the grating but with a 180 spatial phase shift. Figure 2c shows that at the Talbot image distance (z=22/) the
Figure 2. Fresnel diffraction patterns at distances of (a) z=0.0015m=2/, (b) z=0.0023m=1.5
2/, and (c)
z=0.0023m=22/.
Proc. of SPIE Vol. 6695 66950I-2
7/29/2019 Artikel Fisika Bahasa Inggris Tentang Optik-1
3/10
z 0 . 0 1 ( 0 0 . 0 1 5 ) z 0 . 0 3 ( 0 0 . 0 7 5 ) 0 0 6 ( 0 0 . 0 7 5 ) a 0 . 1 ( 0 0 . 0 1 5 )
L 30 _ s -0 4 ,l I E o
intensity is very low in the region where the grating has zero transmission, while Figure 2a shows that at half the Talbot
image distance (z=2/) the intensity is at a minimum where the grating has 100% transmission. Figure 2b shows thetransition between these two regions. The computation is fast enough and the MATLAB programming is simple enough
for the students to create animations showing this transition with know much about numerical simulation coding.
2.2.2 Transition to Fraunhofer DiffractionAs the optical field propagates farther from the grating it transitions into diffraction orders. This transition is often
neglected because it cannot be analyzed with simple analytical expressions. However, the simple MATLAB programenables the students to create animation showing this transition. Figure 3 show the intensity at four planes equally
spaced in distance away from the grating. At the first plane the grating replication can still be seen and in the final plane
the two grating lobes can be seen forming.
Figure 3. Intensity as a function of distance away from the grating.
Figure 4. Comparison between the (solid) Fresnel diffraction and (dashed) Fraunhofer diffraction as a function of
distance from the grating.As the beam propagates farther away from the grating, Fraunhofer approximation becomes valid. The standard validity
range for the Fraunhofer approximation is given by [1] 22Wz > , where W is the half width of the grating. The
Proc. of SPIE Vol. 6695 66950I-3
7/29/2019 Artikel Fisika Bahasa Inggris Tentang Optik-1
4/10
MATLAB code can be used to show this calculation. Similar to the other transition regions, the students can program
MATLAB to make animations showing where the diffraction orders for into the sinc functions predicted by the
Fraunhofer diffraction calculations. Figure 4 shows the calculations at various distances away from the grating.
3. FRAUNHOFER DIFFRACTION
3.1 Fourier Transform using MATLAB
When the distance away from the grating is large or a lens is used to focus the diffraction pattern to the image plane,
then the diffraction pattern becomes a Fourier transform as given by [1]
( ) { }z
yf
z
xfo yx
ECzyxE
===,, . (4)
The Fourier transform of simple structures such as gratings, rectangular apertures, circular apertures, etc. have analytic
solutions. However, the students need to be able to take Fourier transforms of arbitrary 2D structures.
In order to perform 2D Fourier transforms in a computationally efficient method, MATLAB has a built-in Fast Fourier
Transform (FFT) function. The FFT function in MATLAB uses the Cooley-Tukey algorithm [3] to performs a Discrete
Fourier Transform (DFT) as given by
( ) ( ) 1,,1,0
1,,1,0,,
0 0
22
=
== = =
Nq
MpeenmfqpF
M
m
N
n
qn
N
jpm
M
j
K
K
. (5)
The steps required to compute the Fourier transform are (1) discretize the aperture, (2) compute the DFT using FFT
algorithm, and (3) relate the integer parameters back to spatial coordinates.
Discretized Aperture
The 2D amplitude aperture is analyzed in MATLAB by simply creating a black and white image of the aperture in a
standard graphics program and saving the image as a gif file with 2 color levels. When the image is read into MATLAB
the aperture will be discretized by the pixilation of the image with white being complete transmission and black being
complete block. A gray-scale image can also be used to create different amounts of transmission. Any phase terms
would need to be added in MATLAB.
Computing the DFT
The 2-dimensional DFT is commuted using the fft2 command in MATLAB. However, the fft2 command places the
center index in the corners. Figure 5a shows the slit image that is read into MATLAB using the following code
A = imread('slit','gif')
Figure 5. (a) The image read into matlab using the imread command in MATLAB. (b) The DFT computed using
the fft2 command in MATLAB, which places the center index in the corners. (b) The fftshift command that shifts
the corners back into the center.
Proc. of SPIE Vol. 6695 66950I-4
7/29/2019 Artikel Fisika Bahasa Inggris Tentang Optik-1
5/10
x ( w w )0
>EE
>EE
x ( w w )0
Figure 5b shows that the FFT of the rectangular aperture (Figure 5a) using the MATLAB code
E=fft2(A)
which places the maximum intensity into the corners rather than the center. Figure 5b illustrates how the fftshift
command fixes this problem and put the maximum intensity back into the desired location. The MATLAB code for the
shift is
E=fftshift(fft2(A))
Scaling
The last part of computing the 2D Fourier transform is converting the discrete index into physical spatial coordinates.
The discrete frequency is given by
kM
1= , (6)
which is then related to the continuous spatial frequency by
kMpp
fx
111
=
= , (7)
where p is the pixel size, which is essentially MWp = , where W is the total width of the aperture and M is thenumber of pixels. The last step is then performing the substitution dictated by the Fraunhofer approximation as given by
fxfx = resulting in
=
=
2,,
2
111 MM
MW
Mfk
Mpfx L . (8)
The total spatial extent of the diffraction pattern is
2
Mf . Notice that the spatial coordinates is related to the
number of pixels. Figure 6 show calculations with both 256 and 64 pixels.
(a) (b)
Figure 6. Diffraction pattern of a slit with (a) 256 pixels and (b) 64 pixels. The parameters of the calculation are
wavelength =600nm, slit width W=100m, lens focal length f=16.5mm.
Proc. of SPIE Vol. 6695 66950I-5
7/29/2019 Artikel Fisika Bahasa Inggris Tentang Optik-1
6/10
x ( w w )0 2 0
The number of pixels in the diffraction pattern is equal to the number of pixels in the initial image. However, since the
extent of the diffraction pattern also increases with the number of pixels the spatial resolution does not increase with the
number of pixels and is given by
=
Wfx
1 . Thus, the spatial resolution is deceased by increasing the total
extent of the image. The total extent of the image is increased without changing the slit width by adding space around
the image, which is called zero padding. Figure 7 show the diffraction pattern calculated with FFT method with
different amount of zero padding.
(a) (b)
slit slitdiffraction
patterndiffraction
pattern
Figure 7. Diffraction pattern of a 100m wide slit with (a) too little zero padding and (b) with enough zeropadding.
The problem associated with adding a lot of zero padding is that if too few pixels cover the actual aperture then the
calculated diffraction pattern will not be as accurate.
Summary of MATLAB Code
By using MATLAB code the programming is fairly straight forward enabling the students to concentrate on exploring
complex aperture structures rather than programming numerical integration. Listed below is the MATLAB code to
perform a diffraction calculation. Notice how a complex diffraction pattern can be analyzed with only 11 lines of code.
A = (imread('slit','gif'));
sz = size(A);
N = sz(1);
M = sz(2);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)
3.2 Examples of Diffraction Patterns
Figure 8 - Figure 12 show various diffraction patterns computed using the MATLAB code described in this paper.
Proc. of SPIE Vol. 6695 66950I-6
7/29/2019 Artikel Fisika Bahasa Inggris Tentang Optik-1
7/10
(a) (b)
Figure 8. Diffraction patterns of letter made with (a) arial and (b) times new roman fornts.
Figure 9. Diffraction pattern of an aperture constructed with multiple letters.
Figure 10. Diffraction pattern of a Cassegrain telescope aperture.
Figure 11. Image recognition for matching images.
Proc. of SPIE Vol. 6695 66950I-7
7/29/2019 Artikel Fisika Bahasa Inggris Tentang Optik-1
8/10
Figure 12. Image recognition for mismatched patterns.
4. EXPERIMENTAL DEMONSTRATION
4.1 Experimental 4-F System Implementation
Experimental implementation of a Fourier optics system is very complimentary to numerical simulations discussed
earlier. For example, with an experimental system it is more difficult to change various filter and image parameters that
would be varied in a numerical simulation exercise. With an experimental implementation it is easy to look at thetransition of an arbitrary image between the Fourier and the Fraunhofer domain.
10x objective
f=16.5mmlens
f=1000mm
lens
f=500mm
lens
f=500mm
laser
object imageFourier
plane
mask
Figure 13. Experimental implementation of a 4F optical image processing set-up.Figure 13 shows the experimental implementation. There are a variety of factors that can make a simple experimental
implementation not work well. The Fourier-plane mask needs to have very opaque blocking. A transparency does not
block enough light to be effective. Therefore, the Fourier-plane mask was constructed with a photolithography chrome
contact mask. Another difficulty is the need for very small mask features to work in the visible region of the optical
spectrum. The feature size is kept larger by using lenses with large focal lengths. In addition to being easier to fabricate
the mask, the larger features also make the alignment easier. Since the features on the mask are small, main different
mask types and sizes can be fabricated onto the same mask.
Proc. of SPIE Vol. 6695 66950I-8
7/29/2019 Artikel Fisika Bahasa Inggris Tentang Optik-1
9/10
4.2 Experimental Results
One of the most obvious experiments is to perform a high-pass and a low-pass optical signal processing. In Figure 14 the
red laser light is transmitted through a transparency of the word BYU. The hole is used to create a low pass filter
resulting in the blurring of the word. Various sizes of holes are placed in adjacent locations on the Fourier-plane mask to
change the amount of blurring. Similarly, an opaque dot is used to perform high-pass filtering, which results in edge
detection.
Figure 14. Experimental implementation of high-pass and low-pass optical image processing.Another very instructive exercise involves looking at an image as a function of distance away from the focusing lens. As
the students expect the image gets smaller with distance. However, when the Fraunhofer approximation becomes valid
the image transforms into its spatial frequency components. Figure 15 shows the distinct difference between the image
slight off of the focal plane and at the focal plane. The ability to easily look at the transition is one of the powers of an
experimental implementation.
Figure 15. The diffraction pattern at a position just before the focal plane and at the focal plane.
5. SUMMARY
This paper has described the potential of using MATLAB to perform Fourier optics calculations. MATLAB is a fairly
simple programming language, which enables engineers and physicist to perform precise numerical calculations without
needing to get bogged down into the specifics of the numerical calculations.
Proc. of SPIE Vol. 6695 66950I-9
7/29/2019 Artikel Fisika Bahasa Inggris Tentang Optik-1
10/10
The methods to analyze diffraction in both the Fresnel domain and the Fraunhofer domain have been covered. Some of
the specific of both the derivations and the MATLAB code have been provided in order to facilitate their implementation
in other classroom settings. In addition to the numerical calculations using MATLAB, a simple experimental
implementation of 4f system has also been provided.
6. REFERENCES
1 Introduction to Fourier Optics, J. Goodman (1996)
2 H. F. Talbot, Philos. Mag. Vol. 9, p. 401 (1836)
3 http://www.fftw.org/
Proc. of SPIE Vol. 6695 66950I-10
Top Related