In the last article we saw that the intensity Point Spread Function and the Modulation Transfer Function of a lens could be easily approximated numerically by applying Discrete Fourier Transforms to its generalized exit pupil function twice in sequence.[1]
Obtaining the 2D DFTs is easy: simply feed MxN numbers representing the two dimensional complex image of the Exit Pupil function in its space to a Fast Fourier Transform routine and, presto, it produces MxN numbers representing the amplitude of the PSF on the sensing plane. Figure 1a shows a simple case where pupil function is a uniform disk representing the circular aperture of a perfect lens with MxN = 1024×1024. Figure 1b is the resulting intensity PSF.
Simple and fast. Wonderful. Below is a slice through the center, the 513th row, zoomed in. Hmm…. What are the physical units on the axes of displayed data produced by the DFT?
Less easy – and the subject of this article as seen from the point of view of a photographer.
A Numerical Perspective
For this discussion we take a numerical view of Fourier Optics and its black box model of lenses as fully described by their virtual terminal properties, the entrance and exit pupils.[2] Figure 3 below shows a simplified diagram representing the exit pupil and sensing plane separated by air (not to scale).
The exit pupil function in this article refers to an array of MxN numbers indexed by integers and , which range from 0 to M-1 and 0 to N-1 vertically and horizontally respectively. Similarly for the image of the relative Point Spread Function on the sensing plane and Modulation Transfer Function . The only physical parameters on the diagram are shown in red: exit pupil circular aperture diameter , focal length , number of horizontal samples and sampling pitch and (not shown and in the vertical direction which would however be the same size as and resp. in a square-pixel sensor).
The Physical Units of the Exit Pupil Function
To get the axes of the PSF we first have to determine the physical units of the exit pupil function , which fortunately we do have because the two domains are linked by a virtual physical window, the aperture. Using the same example as in the last article, with the diameter of the circular aperture at 5mm, we can easily put axes on Figure 1a above since I counted that exactly 9 diameters fit within a width and a height of the exit pupil image[3]. That means that in this case the effective MxN pupil space related to the MxN sensing space must represent a 45mmx45mm physical area.
If the planes are sampled evenly times in the horizontal direction, with = N = 1024 per Figure 1, that means that linear physical sample spacing is 45mm/1024 = 0.0439mm on the physical pupil plane.
Following that reasoning, and denoting the number of times the diameter of the aperture fits horizontally within the pupil plane as (a quantization/padding factor, as described in the appendix), the horizontal axis of the pupil function in Figure 1a at index position would then correspond to physical value
(1)
and the spacing between samples to , all in the same physical units as since and are dimensionless. in this case represents integers 0,1,2… to n-1.
That’s with the origin top left, as shown in Figure 1. The convention is however to put the origin of the pupil function in the center of the image as shown in Figure 3. To show an index of zero in the center of the image index must run from -512 to 511 in our example so in general it becomes
Index would then be equal to zero at the 513th column of Figure 1. Of course physical remains unaffected by a shifting of the index variable. Assuming square pixels, is the same as and physical values for can be obtained similarly.
From Pupil Function to PSF Units
To generate the image projected on the sensing plane we apply Equation (1) from the previous article to Generalized Exit Pupil Function , accounting for lens aberrations.
When such image intensity is the result of an on-axis unit impulse of monochromatic light at infinity it allows us to drop the averaging and light field terms. The result is then referred to as the system’s intensity Point Spread Function (PSF) and, after performing coordinate substitution
(2)
the apparently complex equation is in fact seen to just be the magnitude of the Fourier Transform of squared, with the wavelength of light and the distance in air between the parallel exit pupil and sensing planes in Figure 3 above, equal to nominal focal length when the lens has unity pupil magnification and is focused at infinity[iv].
Since in digital photography our unitless MxN data is digitized with samples at regular intervals we can use the Discrete Fourier Transform to approximate the transformation numerically. Here then is the PSF expressed as the DFT of with the variables at hand, fixed factors dropped because the PSF and subsequent MTF are otherwise typically normalized by convention depending on the application:[4]
(3)
in this case represents integers 0,1,2… to N-1 and M-1 for and , the coordinates of all the samples in the Pupil and Sensing planes respectively. Of course on the sensing plane each coordinate in the MxN grid corresponds to the center of a physical pixel.
The Discrete Fourier Transform produces an output data set of the same size as the input MxN data set, regardless of any known physical dimensions. Recall that in this case the units produced by the DFT are integers per input set – and the input set refers to the physical extent of the exit pupil function, of length on the side. Therefore the horizontal axis of the PSF in Figure 1b at integer index position would correspond to physical value
To convert to units of on the sensor we simply multiply by according to earlier substitution (2) so that, for instance, the fourth pixel on the sensing plane now represents 3 in physical units. Substituting effective f-number for in that fraction[iv] we obtain the following physical value at integer index position on the horizontal axis of the sensing plane
(4)
with sample pitch , all in the same physical units as because and are dimensionless. That’s with the origin top left. If we want the PSF to be centered we shift the origin half an image both ways by changing the index variable ( this time) as before[1]:
With the origin shifted to the middle of the image, the 513th sample in Figure 2 becomes the origin at index = 0. It is then easy to see from its central slice that the Airy pattern would hit a first null at = 11 (count the samples). With = 9 this would correspond in physical units to 11/9 = 1.22 , which is indeed the radius of the first ring predicted by theory.
PSF to MTF Units
To get Modulation Transfer Function from the Point Spread Function we take a second Discrete Fourier Transform of the unitless MxN data, as shown by the third line of code up top. This produces the unnormalized Optical Transfer Function, the normalized modulus of which is the MTF. This time there is no coordinate substitution so the physical units corresponding to the output of the DFT are the bona fide linear spatial frequencies present in the PSF. The physical length of the input set in this case is simply the number of samples on the axis times the distance between samples (). Therefore the physical spatial frequencies on the horizontal axis of the relative MTF are obtained by dividing integer index positions by that:
(5)
and , all in cycles per the same units as . Sometimes it is useful to shift the origin of the frequency spectrum to the center of the image. If so proceed as before to also shift index .
Bringing Them All Together
In Octave or Matlab, the three lines of code up top are therefore complemented by the three lines of code below to generate axes for the three planes discussed in this post:
Plots of the pupil, image and frequency spectrum can therefore now be shown with axes in physical units:
Units for and in the vertical direction can be obtained using the same procedure, this time starting from . In the case of Figure 1 they would be exactly the same because both pixel and image are assumed to be square.
Appendix
i) Relating the Physical Pupil and Sensing Planes
With an MxN pixel digital image at hand, and considering the one dimensional case as before for simplicity with N = , it is clear that since per (1) and per (4) sampling pitch in the pupil and sensor domains (hence their relative physical dimensions) are related as follows:
(6)
or equivalently in terms of magnification of the image plane vs the pupil plane
(7)
In practice as photographers we know and can typically estimate to a good approximation pixel pitch (), nominal focal length () and wavelength () so Equation (6) provides the easiest link between the two physical planes[iv].
ii) On Q
You may have noticed that for a given digital image the only variables required to determine the physical units of Exit Pupil, PSF and MTF are light wavelength , focal length , exit pupil aperture diameter – and factor , the ratio of the length of the relevant side of the working pupil plane to .
affects the sampling pitch in the image plane, with the effective f-number, in a way that can be intuitively related to the size of an Airy Disk. Ignoring rounding errors, there will be about
(8)
from peak intensity to the first zero ring, so in effect it determines how many samples the PSF in the figures will be made up of ( because of the sample at the origin, see Figure 5). The larger is, the more the PSF samples all else equal. We don’t want too small lest we get aliasing in the sensing plane.
Following similar thinking in the frequency domain, with and ignoring rounding errors, the MTF curve between zero and the diffraction extinction spatial frequency will be made up of about
(9)
so we don’t want too large lest we don’t get enough samples there (Figure 5b), though it’s typically less of an issue here.
Similarly in the pupil plane where , is again in the denominator, which means that the larger is the smaller the actual aperture relative to the whole plane and its elements, all else equal – if is too large we may get aliasing there.
A happy medium can usually be found for a given total linear number of samples , as shown in this case with = 9 for = 1024. In some contexts we can think of as a padding ratio in the pupil and frequency domains – and a sampling factor in the spatial domain.
iii) On
With = 1024, a value of about one order of magnitude is mainly necessary in order to obtain relatively unaliased data from the Discrete Fast Fourier Transform routines – but for continuous physics photographic thought experiments it can be considered to be equal to one. In that case the physical units of PSFs and MTFs are seen to depend only on a single figure, the product , as shown for example just above and in figures 2-6 here. This realization can provide some neat insights into the basic properties of light on the sensing plane after it has gone through a lens.
iv) On Working f-number and Macro
The preceding discussion assumes a lens with unity pupil magnification focused at infinity, which places the imaging plane a distance equal to nominal focal length () from the exit pupil. However it is also valid for most setups including macro if
- the size of the region of interest is no greater than about 1/4 the size of the aperture at the exit pupil[6]
- we account for the geometrical change in distance to the imaging plane caused by pupil magnification and/or the focusing plane being other than infinity.
Using Goodman’s notation, in such cases the new distance to the imaging plane replaces in all equations above (refer to Figure 3). With a little geometric manipulation it can be shown that
(10)
with lens magnification at the given focus distance and the ratio of exit () to entrance () pupil diameters.[7] is then the value that becomes the numerator in the calculation of working (or effective) f-number, with the denominator exit pupil aperture diameter . By definition we can express the latter as the product of pupil magnification and entrance pupil aperture diameter , to obtain working f-number [8]
(11)
where is the nominal published f-number for the lens focused at infinity. The modifying factor in parentheses preceding it is well known to macro photographers and referred to as the bellows factor. As focus distance increases beyond those of macro photography becomes increasingly small so tends to , the bellows factor tends to 1 and therefore tends to .
v) On Locality
What about off-axis PSFs? It works the same way as long as one remembers that all results are local to the position of the point source on the sensing plane predicted by geometrical optics.
Lenses perform a 3D transformation. Fourier optics gives us a simplified framework to model the approximate intensity on the sensing plane arising from a point source somewhere in object space – based on the field it produces in the Exit Pupil, represented by the generalized complex pupil function .
The position of the pupil within the Exit Pupil plane can be considered to be fixed in this context but the wavefront going through it changes depending on where the point source is located with respect to the lens, on or off axis, closer or further away – and of course so do the relative PSFs, as we all know.
The physical image formed is then the convolution of such a local PSF with the ideal geometric image of the scene projected onto the sensing plane, in the window over which that PSF is valid. Since aberrations vary relatively slowly throughout the field of view it is usually sufficient to produce PSFs at a few (dozen) representative spots for photographic equipment evaluation purposes.
How do we know what Exit Pupil field corresponds to what source position in the scene (hence, by geometrical projection, in the image)? It is up to us to define the wavefront in the Exit Pupil for the point source as set up so that Fourier Optics can perform its magic, as explained below.
vi) On Seidel and Zernike Polynomials
Recall from previous articles that the generalized pupil function can be expressed in polar coordinates:
(12)
is a map of the complex field in the Exit Pupil plane in polar coordinates, with radial distance of a point from the optical axis and the relative angle. We have already seen this notation in action in the past (for instance here), where the polynomial in the exponent was equal to , with the first term representing the amount of third order Spherical Aberrations present, the second defocus, both in Seidel notation. If coma were also present we would need to add a term – and so on for all additional aberrations.
There are two prevailing aggregations of possible polynomial terms: Seidel and Zernike. Seidel assumes rotational symmetry of the optical surface and concentrates on the more common aberrations, which it gives familiar names like Defocus, Tilt, Spherical Aberrations, Astigmatism, Coma etc., and treats them independently of each other. Zernike instead provides term combinations orthogonal to each other and it is more structured, rigid and complete (careful to be consistent because there are alternative notations in use). You can see a list of two such sets in Wyant[9], Seidel functionals in Table II and Zernike polynomials in Table III. Each functional/polynomial comes in a certain ‘strength’ represented by its coefficient, what we try to estimate.
vii) Implementation Notes
Practically, to generate a PSF from a lens with a standard circular aperture we could fill a square array with ones, representing a grid of samples of the unaberrated field at the Exit Pupil plane. We would then multiply element by element this pristine wavefront by another array of the same size, populated by values resulting from the complex pupil function , a result of the aberrations present. Then set all samples outside of the circular pupil to zero to account for the hard stop of the aperture – and let Fourier optics do its job[*]. Use the discussion on Q in Appendix ii) above as a guide to determine the correct proportions of array size vs aperture diameter (hint: Q needs to be substantially greater than 2). You can see sample code to generate the complex pupil wavefront in Function ‘pupil’ of the attached Matlab class[5].
Where do the estimated polynomial coefficients come from? Someone has to tell us, or we need to measure them ourselves. See for instance the Appendix in this article for how I estimated the aggregate defocus+SA3 Zernike Z8 coefficient for two of my lenses by using MTF Mapper. Of course those parameters are only valid where measured, in that case on axis, so the resulting PSF is correct just in the center of the sensing plane for a subject at the measured distance. If an estimate of the PSF of that lens in a corner were required, one would need to newly determine Z8 and coefficients for all other relevant aberrations likely present there (e.g. most likely coma, astigmatism, etc. too much work for a curious photographer:). Of course a PSF generated with those parameters would be valid only around there, for a subject at that measured distance.
Notes and References
1. The substance of the first line of code above is represented by the two dimensional fast Fourier transform of the Exit Pupil Function (fft2), producing the diffracted pattern on the image plane referred to as the Amplitude Point Spread Function. The shift (fftshift) is there just to make sure that the resulting PSF is centered. The second line is a better and faster way to compute the magnitude squared of the amplitude, which is the intensity PSF. The third line takes the magnitude of the Discrete Fourier Transform of the PSF, which is the MTF of the system. Values are not conventionally normalized.
2. Introduction to Fourier Optics, 3rd Edition. Joseph W Goodman.
3. Simplified Figure 3 is not drawn to scale.
4. The definition of the Discrete Fourier Transform can be found here.
5. If you would like the Matlab routine used to generate these plots let me know via the form available in the ‘About’ page top right. [Edit: I have received enough requests that I have reluctantly decided to make the relative class available. Reluctantly because it was designed to be used just by me (its precursor had contributions by Brandon Dube) so its use is clumsy and non intuitive. You can download it by clicking here.]
6. In Fourier Optics 3rd Edition, Joseph W. Goodman suggests in section 5.3.2 that, in order to drop a quadratic phase factor that depends on object coordinates, the size of the object should be no greater than about one quarter the size of the lens aperture.
7. “Depth of Field from Working F-number and Image magnification“, A Geometric Optics Calculation and comparison with alternative approaches, Alan Robinson (Unpublished, 2020)
8. For a definition of Working f-number see here.
9. Basic Wavefront Aberration Theory for Optical Metrology, James C. Wyant and Katherine Creath.
Thank you for this post. It has been very informative and helpful.
My pleasure Raffi.
Jack