# Depth of Field and Bokeh of an Ideal Lens – Mathematics

I have never written about the optical computations that apply to an „ideal lens“ in the blog, although there is a notebook for Euler Math Toolbox and an Euler file („dof.e“) that can be loaded into the program. The topic, however, is quite interesting from a mathematical point of view. It involves modelling of the lens in a though experiment („Gedankenexperiment“), and determining formulas from the geometry of the model. So it makes a good application of simple Algebra and Geometry for higher school classes.

An ideal lens is able to focus light rays that emerge from a point of the scene (the object) into another point behind the lens (the image of the object). As you see in the figure above, the lens should ideally focus all objects on a plane with distance d (object distance) onto a plane with distance f(d) (focussed image distance) behind the lens. We denote it by f(d) because it depends on d. The line through the object and its image goes through the midpoint of the lens. The figure shows the situation (green and blue) for two objects.

If the object is at infinity, its emitted rays of light are parallel. Then the image is on a plane with distance f from the lens. This distance is called the focal length of the lens. Again, the figure shows two situations (green and blue). Actually, we could write

$$f = f(\infty)$$

In the first figure, the object is not at infinity, but closer. The lens will not be able to focus the object at distance f, but at the larger distance d_f. In a camera, the lens will have to be moved further away from the sensor or film to get a sharp image.

Our first aim is to prove the relation

$$\dfrac{1}{f} = \dfrac{1}{f(d)} + \dfrac{1}{d}$$

For this, we only want to use geometric properties of our „ideal lens“.

Our first observation is that we can find the focal length f in the figure above if we select a ray that goes from an object perpendicular to the lens at distance d and is then focussed to an image at distance f(d). The intersection with the central axis of the lens will have distance f in that case. This is so, because we assumed that parallel rays focus at distance f as in the second figure above.

At that point, we draw the situation in another way, emphasizing the things we need for our geometric argument.

Looking at the blue and the tray rectangle, we easily see

$$\dfrac{f(d)}{f} = \dfrac{d+f(d)}{d} = 1 + \dfrac{f(d)}{d}$$

Dividing by f(d) we get our simple and easy to remember formula.

There are some interesting special cases. One is the case when the object is at infinity. Then the image distance is just f as in the figure above.

$$d = \infty \quad \to \quad f(d)=f$$

Another one is

$$f(d) = d = \dfrac{f}{2}$$

That is a macro lens with 1:1 magnification. The size of an object is then identical to the size of the image of the object.

We can also see, that it is impossible to focus on objects that are closer than the focal length f.

Now, we can start to proceed towards the concept of „depth of field“ (DOF). The first step is to observe that an object will not be focussed correctly if the lens has the wrong distance from the sensor (or film).

So assume the object distance is d_o, but we have focussed on objects at a distance d. The objects at distance d_o will not be in focus. Instead, the rays emitted by the center object will form a small circle on the sensor.

The diameter c of this circle is, by another geometrical observation,

$$c = l \, \dfrac{d-f(d)}{f(d)}$$

Here, l is the diameter of the lens. To see this, consider the stretching factor between the two green triangles behind the lens (i.e., left of the lens in the figure).

For a realistic measure, we use the „aperture“ of a lens. That is usually measured by F-stops which we denote by A_F to minimize the confusion to the focal length f.

$$A_F = \dfrac{f}{l}$$

The aperture measure the amount of light that reaches the sensor per area. For different lenses, this amount will be the same for the same aperture, since f and l both affect the amount of light proportional to f^2 and l^2. Thus, the aperture can be used to get the correct exposure independent of the lens. Unfortunately, it is inverted in an unintuitive way. So larger a will yield less light on the sensor.

Now we are going to use EMT and Maxima to compute a formula for c which depends on the object distance, the focussed distance, the focal length and the aperture.

>equ1 &= 1/F = 1/DF+1/D

1   1    1
- = -- + -
F   DF   D

>function f(F,D) &= DF with solve(equ1,DF)

D F
- -----
F - D

>function c(F,D0,D,AF) &= factor(F / AF * (f(F,D)-f(F,DO))/f(F,DO))

2
(D - DO) F
-------------
AF DO (F - D)


Thus

$$c = \dfrac{|d-d_o| \, f^2}{A_F d_o (d-f)}$$

That sound terribly complicated. So, let us study special cases and find some simple relations which we can use for photography.

Assume, we focus on an object at distance d_o. We are interested in the Bokeh of the photographic image. This is the blurriness of objects at infinity, or at a far distance. We need to study the behavior of c for large d. Mathematically, this is the limit as d goes to infinity. We get

$$c_\infty = \dfrac{f^2}{A_F \, d_o}$$

That’s much easier. But for practical purposes we have to consider that we need to double our focal length if we move the object away from us to double the distance. Thus, a more practical rule of thumb is

$$c_\infty \sim \dfrac{f}{A_F}$$

It applies to photographing the same object at the same size on the picture. This is a very natural formula if you think of the focal length as a magnification. The circles of diffusion are simply magnified with a higher focal length.

We also learn that for the same object at the same size on the image, the Bokeh gets twice better with twice the focal length and with half an F-stop. Or, you get the same Bokeh for a 50mm lens at F2 as for a 100mm lens at F4. For the Bokeh effect, it is usually cheaper to use a longer lens than an expensive and fast medium lens.

For depth of field (DOF), we want to know what objects are at a distance where the circle of confusion does not exceed a maximal value. In the old film days, this value was

$$c_\text{max} = 0.03 \text{mm}$$

It is possible to solve this exactly, but we are only interested in rules of thumb.

First, let us assume we take an image of the same object with different focal length such that the object has the same size on the picture. We need to change our distance accordingly. In fact f/d is almost constant. Moreover, we can assume that d is much larger than f, and thus d-f approximately equal to d_o. Then we get simply for object distances d_o which yield the maximal circle of confusion

$$|d-d_o| \sim A_F$$

I.e., the DOF does not change for the same subject at the same size with different lenses unless we change the aperture.

There is also the topic of the „hyperfocal“ distance. We want to determine the shortest distance d_o to focus on such that infinity is reasonably sharp. By our formula above for the radius of diffusion, we get

$$d_o = \dfrac{f^2}{c_\text{max} \, A_F}$$

Can we derive a practical rule of thumb from this? Not really. We can provide some examples, like focussing 3m for F8 and 24mm. The usual advice to „focus 1/3 into the scene“ is obviously only vague advice. Maybe, it yields the most pleasing unsharp regions. But I tend to check the image on the camera.

It is interesting how a „crop factor“ (aka. form factor) changes the mathematics. For an example, let us assume we take a micro four thirds (MFT) instead of a „full frame“ camera. Then we have a crop factor f_c of 2. That means, we need to use a 25mm instead of a 50mm to get the same image. The formula yields 1/4 of the circle of diffusion. But since our sensor is also 1/2 the size, we get a full frame equivalent

$$c_\text{equiv} = \dfrac{|d-d_o| \, f^2}{f_c A_F d_o (d-f)}$$

Effectively, the DOF multiplies by f_c, and the blurriness in the Bokeh at infinity divides by f_c. For the Bokeh, we now get under the condition that we take the same object at the same size in the picture,

$$c_{\infty,\text{equiv}} \sim \dfrac{f}{f_c \, A_F}.$$

To get the same Bokeh for MFT, we need twice the aperture. So you need to replace a 85mm lens on a full frame camera at F2.8 with a 42,5mm lens on MFT at 1.4. The best cheap lens is at 1.7, which is equivalent to F3.5 on the full frame camera.

But there is also an interesting effect which puts MFT into a better light. Assume, you need enough DOF to capture a bird in flight and get it safely into focus. In this case, you might use F5 on a 70mm lens (140mm equivalent) on MFT at 1/250 seconds exposure. On the full frame equivalent, you will have to use F10 (F11 actually) and thus crank up ISO two stops to keep 1/250 still. This loses the advantage of the larger sensor in terms of noise. Note that the Bokeh at infinity remains the same if you do so, since you doubled the F-stop in change of a factor f_c=2. So, MFT is working just as well here. You just use more compact and cheaper equipment.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.