A library to compute diffraction patterns in 2D, and to undistort diffraction patterns in presence of defects in diffraction gratings.
In the special case when the grating grooves/lines are perpendicular to the plane of incidence,
the diffraction grating equation is expressed as
Intuitive as these are, the equations still make use of trigonometrical functions, which introduce numerical instability, and furthermore are not conducive to vectorization. This library avoids altogether the use of trigonometric functions in computing diffraction patterns.
In a lab we captured diffraction patterns induced by monochromatic lasers using the wide-angle lens of an Android camera that had diffraction gratings affixed. The goals were to determine the wavelength of the lasers, and undistort(rectilinearize) the captured images.
Assumptions:
- The camera behaves like a perfect pin-hole camera (in particular images present no distortions apart from the diffraction distortion)
- The camera's sensor is perfectly symmetric
In the figure above, red, green, and blue arrows represent the
The figure shows 9 points (red)
In theory, if
It is no coincidence that the math involved resembles that of camera matrix computations using homogeneous coordinates.
In practice there are imperfections. The captured diffraction patterns exhibited characteristics that were
results of rotation, shearing, and translation. My initial attempts in finding the right transformation
was sequential - for instance finding the rotation first and then the remaining transformations. It turned out
that errors from each step accumulated. Thus in the end
the correct method was to find a single projective transformation that modeled all the deformations in
Modules in this package can be used to undistort (convert) the first image below to the second.
For details of the procedure, see application2 live script. (live script is matlab's equivalent to jupyter notebook)
To generate basic diffraction patterns, see basic_usage.m.
Description of Diffraction Grating Behavior in Direction Cosine Space:
@article{Harvey1998,
doi = {10.1364/ao.37.008158},
url = {https://doi.org/10.1364/ao.37.008158},
year = {1998},
publisher = {Optica Publishing Group},
volume = {37},
number = {34},
pages = {8158-8159},
author = {James E Harvey and Cynthia L Vernold},
title = {Description of Diffraction Grating Behavior in Direction Cosine Space},
journal = {Applied Optics}
}