The PSF of a Pinhole Camera

After introducing the Airy pattern in The Perfect Camera, I will show in this article how the PSF of a pinhole camera looks. A camera with a classical lens focuses the image that would be at infinity on the detector, which means that you actually get (approximately) the Airy pattern as the image of a point source there. This is not true for a pinhole camera, so the Airy pattern is not a good approximation of the PSF in that case.

The figure below shows the geometry that is used in the formulas that follow. The pinhole (or aperture) is located in the plane \(z=0\). The equation in the next section then computes the electrical field \(E\) at a point \((x,y,z)\). In practice, this equation is used to compute the PSF in a plane \(z=d\), where \(d\) is the distance to the (planar) detector.

Diffraction geometry [Image: Alessio Damato]Diffraction geometry [Image: Alessio Damato]

As was already mentioned in The Perfect Camera, it is necessary to use (at least) Fresnel diffraction to compute the PSF of a pinhole camera. In this article, I’ll do better and use the full Rayleigh–Sommerfeld diffraction integral.

The Rayleigh–Sommerfeld Diffraction Integral

A general solution of the wave equations, which we need to solve to compute the PSF, is the Rayleigh–Sommerfeld diffraction integral. It is given by

\[E(x,y,z)=\frac{kz}{2\pi i}\iint_{-\infty}^{+\infty}\!E(x_0,y_0,0)\frac{e^{ikr}}{r^2}(1-\frac{1}{ikr})\,dx_0\,dy_0,\]

where \(k=2\pi/\lambda\) with \(\lambda\) the frequency of the wave, and \(r=\sqrt{(x-x_0)^2+(y-y_0)^2+z^2}\). \(E(x,y,z)\) is then the electrical field at the point \((x,y,z)\). This integral can be interpreted as a convolution. If we define

\[h(x,y,z)=\frac{kz}{2\pi i}\frac{e^{ik\rho}}{\rho^2}(1-\frac{1}{ik\rho}),\]

where I’ve set \(\rho=\sqrt{x^2+y^2+z^2}\) for convenience, we get that


where the integral is simply the definition of convolution. The result is exactly the Rayleigh–Sommerfeld diffraction integral again. However, this time a basic impulse response \(h(x,y,z)\) can be combined with an arbitrarily shaped pinhole through convolution, which can be done efficiently using the Fast Fourier Transform (FFT) algorithm. In the current article, I only use a circular pinhole, but I have another article with more crazily shaped pinholes.

Let’s see how this works out in practice.

In Practice

When the Rayleigh–Sommerfeld integral is used to compute the PSF of a circular pinhole, the result is as shown in the following figure.

PSF of a circular pinhole, far away (left) and close by (right)PSF of a circular pinhole, far away (left) and close by (right)

On the left, the PSF at a large distance from the aperture (490 mm, for a pinhole with a diameter of 0.3 mm and a wavelength of 550 nm) is shown. This PSF is very close to the Airy disk that was computed in The Perfect Camera, so it turns out that 490 mm is far enough to approximate the theoretical result. But, as I’ve mentioned in the introduction, the PSF is expected to look different at the actual distance of the detector for a (DSLR) pinhole camera, since that is much smaller. For my Nikon, that distance is 49 mm. The image on the right shows the PSF at that distance, and it indeed looks significantly different from the image on the left. It is clear that this difference cannot be ignored in practice.

In a follow-up article, I will use this PSF to compute some simulated pinhole photos. PSFs like this can be useful to determine a suitable pinhole size for a given camera geometry.

Sources: The following article gives a nice overview of several near-field diffraction models: G. D. Gillena and S. Guha, “Modeling and propagation of near-field diffraction patterns: A more complete approach”, Am. J. Phys., vol. 72, no. 9, pp. 1195–1201, 2004, doi: 10.1119/1.1767102. The geometry image is from Wikimedia Commons

Submitted by Tom Roelandts on 16 August 2013


Excellent article. I am trying to model diffraction effects in matlab using the Rayleigh-Sommerfeld impulse response. Specifically, I am trying to use the FFT to create filters as you suggest. I keep getting results which are not consistent with the Airy disk, and I was wondering if the circular convolution property of Fourier Filters was the problem.

Have you had any success using the FFT to get the same result?

Both PSFs in the above figure were computed using FFT convolution. The circular convolution should not be a problem, if you don’t use the border of the result. To create these images, I used a very large (in pixels) impulse image (h(x,y,z)), and a much smaller pinhole image (a disk in this case), so that I could crop the convolved image and still have a large enough result. You also have to be careful that you don’t get Moiré patterns in your impulse image. Have you checked the real and imaginary part of that separately?

That would make sense. My impulse image, h(x,y,z), was the same size as the image to be convolved. How do you suggest to check for Moire? Visual inspection?

My result is similar to yours, however there are many regularly spaced disks as opposed to a large central one.

Yes, I think that visual inspection will be sufficient to check this. The stucture of h(x,y,z) quickly becomes very fine when you go away from the center, and this can produce aliasing if your resolution is too low. You have to look at the real and imaginary parts separately to see this, however, since the magnitude image is very smooth. But if you say that you get many regularly spaced disks in your final result, then that clearly points to a problem in your impulse image for me.

Add new comment