A Simple Model for Sharpness in Digital Cameras – Defocus

This series of articles has dealt with modeling an ideal imaging system’s ‘sharpness’ in the frequency domain.  We looked at the effects of the hardware on spatial resolution: diffraction, sampling interval, sampling aperture (e.g. a squarish pixel), anti-aliasing OLPAF filters.  The next two posts will deal with modeling typical simple imperfections related to the lens: defocus and spherical aberrations.

Defocus = OOF

Defocus means that the sensing plane is not exactly where it needs to be for image formation in our ideal imaging system: the image is therefore out of focus (OOF).  Said another way, light from a point source would go through the lens but converge either behind or in front of the sensing plane, as shown in the following diagram, for a lens with a circular aperture:

Figure 1. Back Focus, In Focus, Front Focus.
Figure 1. Top to bottom: Back Focus, In Focus, Front Focus.  To the right is how the relative PSF would look like on the sensing plane.  Image under license courtesy of Brion.

The image on the sensing plane appears at first glance to be a uniform disk of light, representing the lens intensity Point Spread Function (PSF)  – and that’s indeed what geometrical optics predicts.  It would therefore be tempting to assume that the Modulation Transfer Function (MTF) of defocus is just the normalized modulus of the Fourier Transform of a uniform disk, which we know from past articles to look like the square root of an Airy function, this time in the frequency domain[1]. That is a correct assumption for large focus errors, where the relative peak optical path error is of the order of a couple of wavelengths of the incident light or more.

A couple of wavelengths of defocus optical path difference (OPD, phase error compared to the Gaussian reference sphere, better defined in reference 2 below) is a very large error if a photographer is after decent IQ.   In fact Lord Rayleigh suggested that a lens system should achieve peak OPD of less than \frac{1}{4} wavelength for performance insignificantly degraded from the ideal.  However, as optical path differences dip below two wavelengths, diffraction plays an increasingly large role in determining the final shape of the PSF and consequent MTF.

The PSF of Defocus with a Circular Aperture

The intensity PSF of a distant, incoherent point source is directly related to what we typically call bokeh in photography.  Wyant and Creath[2] suggest that the irradiance on the sensing plane resulting from the out of focus diffraction pattern of a lens with a circular aperture in such conditions in air can be written as

(1)   \begin{equation*} PSF(r) = \frac{P\pi}{(\lambda N)^2}\left|\int_{0}^{1}e^{i\frac{2\pi}{\lambda}W_{020}\rho^2}\cdot J_0 \left[\frac{\pi r}{\lambda N}\rho\right]\cdot \rho \cdot d\rho\right| ^2 \end{equation*}

where:

  • r, the radial distance from the center of the circularly symmetric PSF on the sensing plane
  • P, the power of light contained within the pupil
  • \lambda, the wavelength of light
  • N, the effective f-number
  • \rho, the radial distance on the Exit Pupil plane, from the optical axis, normalized to one at maximum aperture
  • W_{020}, the peak Optical Path Difference  due to defocus at the Exit Pupil, in the same units as light wavelength
  • J_0, the zeroth order Bessel function of the first kind.

This looks complicated but it is just the Fourier-Bessel transform of the exponential term representing an unaberrated wavefront at the exit pupil, with defocus controlled by peak OPD coefficient W_{020}.  It is also referred to as its Hankel transform of zero order.  The resulting PSF is rotationally symmetric.  A slice through the center of the PSF looks as follows when varying defocus OPD coefficient W_{020} assuming no other aberrations

Figure 2. Center slice of PSF of ideal unaberrated lens with circular aperture and varying amounts of defocus.

When the image is in focus (zero error) the unaberrated PSF has the shape of an Airy disk, as expected for a circular aperture.  On the other hand note that with one wavelength of OPD the intensity PSF has a null in the center, quite different from what ray optics suggests and a fact that is sometimes exploited for calibration during testing (see Figure 5 below).

The MTF of Defocus with a Circular Aperture

H.H. Hopkins derived an analytical formula for the MTF of sub-wavelength defocus for an unaberrated lens of circular aperture as a function of OPD coefficient W_{020}, as outlined in his 1955 paper[3]  .    Equation 1 below is Jeff Conrad’s adaptation of it[4] :

(2)   \begin{equation*} MTF(s) = \frac{4}{\pi a}\displaystyle\int_{0}^{\sqrt{1-s^2}}sin\bigg[a\cdot\bigg(\sqrt{1-y^2}-s\bigg)\bigg]dy \end{equation*}

with

  • a = W_{020} \cdot |s| \cdot \frac{8\pi}{\lambda}
  • W_{020} the maximum Optical Path Difference in microns at the edge of the Exit Pupil aperture
  • s the linear spatial frequency f normalized for diffraction extinction: s =f\cdot\lambda N
  • \lambda the wavelength of light
  • N the effective f-number of the lens
  • The MTF is 1 at zero frequency and zero when s is greater than 1 (that is beyond diffraction extinction).

The equation yields a 1D radial slice of the 2D MTF of defocus.  Since the function is circularly symmetric the 2D MTF can be obtained by simply rotating the linear result around the origin.

Or one could take a numerical approach, as described in this article.

The Effect of Defocus on MTF

We are now ready to show the effects of different amounts of defocus on an ideal diffraction limited imaging system with a circular aperture by applying Equation 2, which fortunately is easy to solve numerically[5].  It produces the following MTF curves for different amounts of the optical path difference coefficient W_{020}, with effective f-number N = 5 and wavelength \lambda = 0.5 microns, chosen to be consistent with Hopkins’ paper:

effect-of-defocus-on-mtf
Figure 3. Radial slice of two dimensional Modulation Transfer Function of unaberrated lens with a circular aperture in the presence of defocus.  Since MTF is a modulus the negative portions of the curves should be rectified but I left them unrectified in this case for effect.

The topmost blue line corresponds to no defocus therefore it represents pure diffraction, and it looks as expected for an Airy function PSF.  The others show increasing amounts of defocus, starting from Lord Rayleigh’s criterion for in-focus at 0.25\lambda or less.

Also note that beyond about \frac{2}{3}\lambda OPD the relative response curve goes negative.  This indicates phase reversal, an example of which is seen in the cutout of the Siemens star on the cover of Boreman’s book.  Since MTF is a modulus  these negative values should in fact be rectified but I left them there in this case to emphasize the point.

Focus Error and Geometric Defocus Disk

Incidentally, from Hopkins’ paper we also gather that in air d_z, the error in the position of the sensing plane with respect to the ideal image plane, is approximately given by

(3)   \begin{equation*} d_z = - 8N^2\cdot W_{020} \end{equation*}

in the same units as the optical path difference coefficient W_{020}, with d_z positive beyond the in-focus image plane.  This follows from simple geometry.

cirles_of_confusion_lens_diagram-labeled
Figure 4. Sensor plane focusing error (dz) and geometric defocus disk diameter (k).  Annotated extract from Figure 1, under license.

And, with paraxial approximation, the diameter k of the geometric defocus disk on the sensing plane is

(4)   \begin{equation*} k = \frac{|d_z|}{N} =  8N\cdot W_{020} \end{equation*}

with k in the same units as d_z and W_{020}.  This relates the softer physical PSF of defocus in the presence of diffraction to the ideal hard edge of a geometric disk.  For instance, with one wavelength of defocus OPD and the same parameters as above we can compare diffraction limited versus geometric PSF intensity predictions.  The scale in the figure below is given by the diameter of the disk at 20 microns with k  = 8*5*0.5um.

Figure 5. Comparison of the intensity predicted for one wavelength of defocus OPD by diffraction limited (left) and geometric optics (right) for a perfect lens of circular aperture, f-number 5, wavelength 0.5um, same total energy.

Contrary to the well defined geometric disk, the diffracted PSF has infinite support, per the Bessel function in Equation (1).  Its maximum radius in the figure is limited to 35um for ease of display here, click on it to better see the ‘rings’ on a dark background.

Focus Tolerance and Depth of Focus

We now have all the information needed to calculate depth of focus related tolerances.  As an example, applying Lord Rayleigh’s quarter wave criterion for  insignificant performance degradation to Equations (3) and (4), an unaberrated circular aperture lens with W_{020}<\frac{1}{4}\lambda and \lambda=0.5 microns, in air the sensing plane would have to be positioned within \pm N^2 microns of the ideal imaging plane, in which case the geometric defocus disk diameter would be less than N microns.  This line of thinking is the starting point for depth of field investigations, as better discussed in this article series.[6]

Third Order Spherical Aberration Next.

Notes and References

1. See this Berkeley paper for the FT of a uniform disk.
2. Basic Wavefront Aberration Theory for Optical Metrology, James C. Wyant and Katherine Creath.
3. The Frequency Response of a Defocused Optical System, H.H. Hopkins, Proceedings of the Royal Society, 19 July 1955.
4. The spatial frequency (s) used in Hopkins’ original paper is twice that used in this adapted version of the formula, which was obtained from an excellent Jeff Conrad paper, Equation 117.  Results are the same.
5. The Matlab/Octave scripts used to generate these plots can be downloaded from here.  The one for the PSF can be found in the next article on SA3.
6.   We also touched on implications of depth of focus on cameras of different formats in this and this article.

 

10 thoughts on “A Simple Model for Sharpness in Digital Cameras – Defocus”

  1. I am interested in running the Matlab code to produce the psf
    of figure 2 in “A Simple Model for Sharpness in Digital Cameras.” I did successfully download and run modelMTF1.m and runDefocusModel.m that produces the MTF in figure 3. You state that, “The one for the PSF can be found in the next article on SA3,” but the download for that contains only a function diffSAdef.m. There appears to be possibly a second “run…” script to compute the psf that is absent.

    Separately, great stuff and most appreciated.

    1. Hi Paul, good work and thanks for your kind words. To reproduce slices through the center of an otherwise unaberrated circular aperture PSF at varying amounts of defocus, as in Figure 2 above, you can run diffSAdef.m as follows:

      Figure 2 PSF Matlab Code

      The negative side of the PSF x-axis is not shown but it is simply the mirror image of the positive side, shown. The curves can be normalized by a common factor to set the peak of the in-focus case to one. r can be divided by lambda*N to match the horizontal units in the Figure.

      To check everything is working, the example above with W020 = 0 yields a first null at distance r = 1.826um from the optical axis, per theory (1.22*lambda*N).

      1. That worked fine. Thx

        For your amusement, we actually need to introduce defocus (in contrast to minimizing it) to optimize the ratio of the psf/pixel dimension. The challenge is there are two simultaneous components: an incoherent polychromatic psf and a coherent one of considerably differing F#.

          1. The application has to do with a combination of centroiding and pointing which are overlayed on a FPA. Incoherent light from a star field is used to establish a global coordinate system. A fast lens is required because the detected fluxes are on the order of 10-12 – 10-15 watts. The system must be purposefully defocused to optimize the psf/pixel size ratio. To point an emitted beam, it is sampled, and overlayed on the same FPA (thus appearing as a synthetic star). However, it is coherent and monochromatic and has a significantly higher F# (smaller diameter at the entrance pupil). The total error budget for establishing a coordinate reference and pointing is on the order of a microradian.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.