# Depth Of Field

How can objects at different distances be in focus at the same time in your camera? Why does the lens aperture size determine the depth of field of your photograph? Does it depend on anything else? Click through to learn about the physics behind it.

In this post I will explain the relationship between aperture and depth of field of a lens. I hope that the diagrams and examples will make it easy to understand for everyone :)

Let’s start with the basics (see diagram below). A camera registers the image of an object produced by a lens onto a CCD (or film if you’re going old school). The position of the object (z) and the position of the image (z’) are related to the focal length of the lens as follows:

$z \cdot z' = -f^2$

Anything left of the lens is considered the object space and the variables are designated by letters like a, z or f (without apostrophe). Anything right of the lens is considered the image space and variables are designated by letters with apostrophes like a’, z’ or f’.

It easily follows from this that objects which are at different distances from the lens will have their images formed at different distances too.

Objects that are in the object plane and focus on the CCD will turn up as small points. And objects that are out of focus will turn up as larger circles on the CCD, which will increase in size as the element moves further away from the object plane (see diagram below).

Let’s perform a simple calculation to find out the size of this circle. If you do not like maths feel free to skip ahead to the highlighted orange formulas, they are the most important (I won’t tell anyone hehe).

As you can see below, the yellow and green triangles are the same triangle but in different sizes. We can use this fact to compare their bases and heights like this:

$\dfrac{D/2}{a'} = \dfrac{d_1/2}{\Delta z'_1}$

Where D is the diameter of the lens aperture, a’ is the distance between the lens and the image plane, d1 is the diameter of the circle formed from the out of focus object, and DeltaZ1′ is the distance between the imaging plane (CCD) and the position of the object’s image (as seen in the figure below).

In photography, lenses have focal lengths are of the order of millimitres, and the objects are usually meters away from the lens. This means we can make the approximation that a is almost infinity and a’ is almost f’. Rewriting the above formula we obtain:

$\dfrac{D/2}{f'} \approx \dfrac{d_1/2}{\Delta z'_1} \rightarrow$

$\Delta z' \approx d \cdot \dfrac{f'}{D}$

In order to express this formula in a nicer way let’s use the f/stop number (photographers see this on their lenses all the time), which is defined as:

$f/stop = \dfrac{f}{D}$

Where f/stop should be interpreted as a single variable,  f is the focal length of the lens (f = -f’), and D is the diameter of the aperture.

Hence the displacement of the image by an object out of focus is the diameter of the circle on the CCD times the lens f/stop:

$\Delta z' \approx d \cdot f/stop$

When the circle on the CCD is smaller than the pixel size of your CCD (or the grain size of your film) then the camera doesn’t care if the image is a tiny dot or a small circle. This means that all elements that result in a circle size (d) smaller than the pixel size (dpixel) will be seen in focus by the CCD.

“So what does all this have to do with depth of field” you might ask. Well, let’s start by defining two very important terms, which are often confused:

DEPTH OF FIELD: is the range of object distance within which objects are in satisfactory sharp focus.

DEPTH OF FOCUS: is the range through with the image plane (the CCD or film) can be moved backward and forward with respect to the camera lens and the object still be in satisfactory sharp focus.

Based on these definitions and our diagrams, the depth of focus (DoFocus) will be all the z’ points for which the circle size (d) is equal to or less than the pixel size (dpixel):

$DoFocus = 2 \cdot \Delta z' \rightarrow$

$DoFocus \approx 2 \cdot d_{pixel} \cdot f/stop$

The 2 comes from the fact that elements can be on both side of the object plane, both closer or further away from the camera than where you’re focusing.

In photography we are more interested in the depth of field (DoField). It is related to the depth of focus by the magnification of the lens:

$DoField \approx \dfrac{DoFocus}{\beta'^2}$

Where the squiggly lines indicate that we have made an approximation (that the depth of field is much smaller than the position of the imaging plane), and Beta is the magnification of the lens:

$\beta' = -\dfrac{f}{z}$

Combining these last two equations we obtain:

$DoField \approx \dfrac{DoFocus}{\left( \dfrac{f}{z} \right)^2} = DoFocus \left(\dfrac{z}{f}\right)^2$

Introducing our previous formula for depth of focus (highlighted in orange) we obtain THE FORMULA, the reason I wrote this whole post! :)

$DoField \approx 2 \cdot d_{pixel} \cdot f/stop \left(\dfrac{z}{f}\right)^2$

Thus the DOF of a photograph increases with:

• increasing f/stop (i.e decreasing aperture diameter)
• increasing CCD pixel size (dpixel)
• increasing distance of the object from the lens (z)
• decreasing focal length of the lens (f)

And vice versa: the DOF of a photograph decreases with decreasing f/stop (i.e. increasing aperture diameter), decreasing CCD pixel size, decreasing distance of the object, and increasing focal length of the lens.

Let’s crunch in some numbers, shall we? Before we get into it I want to make an important remark: We have made several approximations in the derivation of the expression for the depth of field. This means that the number we obtain from our calculations will only be reasonable if all the approximations are valid. So take these results with a grain of salt, looking more at their order of magnitude (tiny/small/big/huge) than at their exact value.

Let’s say I’m going to use my Canon 550 D, where the CCD pixel size is 4.3 microns (list of Canon cameras pixel sizes here). I’ll chuck on my 50mm f/1.8 lens and want to shoot a portrait of my friend Kim, who is standing about 5 metres away from me. Portraits look nice with shallow depth of field to isolate the subject from the background so I will use my lens at f/1.8.

$d_{pixel} = 4.3 \mu m = 4.3 \cdot 10^{-6} m$

$f/stop = 1.8$

$f = 50 mm = 0.05 m$

$z \approx 5 m$

What is my depth of field?

$DoField\approx 2 \cdot d_{pixel} \cdot f/stop \left(\dfrac{z}{f}\right)^2 \rightarrow$

$DoField \approx 2 \cdot 4.3 \cdot 10^{-6} m \cdot 1.8 \left(\dfrac{5 m}{0.05 m}\right)^2 \approx 16cm$

This dept of field is super small! So I’ll have to be really careful with the focus to make sure the subject is not blurry :) Here is an example of a photograph taken with these settings:

Say I now want to shoot a landscape. I will use my Canon 550D again, this time with my 18-55mm lens. I want to go wider angle now so I’ll use my lens at about 18mm and an f/stop of f/10. The mountains I’m trying to shoot are 1km away, for example.

$d_{pixel} = 4.3 \mu m = 4.3 \cdot 10^{-6} m$

$f/stop = 10$

$f = 18 mm = 0.018 m$

$z \approx 1k m = 1000 m$

What is my depth of field?

$DoField \approx 2 \cdot d_{pixel} \cdot f/stop \left(\dfrac{z}{f}\right)^2 \rightarrow$

$DoField \approx 2 \cdot 4.3 \cdot 10^{-6} m \cdot 10 \left(\dfrac{1000 m}{0.018 m}\right)^2 \approx 265 km$

This depth of field is ginormous! So my whole photograph will be in focus :) Here is an example of a photograph taken with these settings:

In conclusion, the depth of field of a photograph depends on several factors, which we can use to our advantage when out shooting. It also plays a major role in the creation of images with nice bokeh (check out my “Bokehliciousness” blog post).

Last, but not least, I would like to acknowledge my university lecturer Prof. Miguel Angel Rebolledo Sanz for fuelling my love of optics in his 3rd year course and providing amazing good lecture notes, which I still look at when I want to refresh my memory (like I did to write this post). Also, I have the best mom in the world (Prof. Pilar Arroyo), who also happens to be a physicist (very super awesomely smart) and is helping me a lot with the physics behind this blog, proofing my equations and programs, as well as providing insightful feedback :)

Don’t forget to subscribe to this blog and like my Facebook page to be the first to hear about my next post!

xx Ana :)

## 5 thoughts on “Depth Of Field”

1. Osvaldas says:

Nice. But how all this relates to the hyperfocal distance?

Like

• Ana says:

That is a really good question Osvaldas :) From what I understand about hyperfocal distance it means that when focusing at this distance, the furthest edge of your depth of field will be at infinity, hence you are maximising the region that will be in focus. It is hard to explain in a short comment, but I’ll add it to the list of potential topics for future posts! Thanks for reading :)

Like

2. […] many a post in which the main theme is a physics concept. Like when I calculated a formula for the “Depth of Field” of a photograph, wrote about “Gravity” and “Lunar Eclipse & Moon […]

Like