Depth Of Field

IMG_4623-1_1How 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’.

dof-1

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

dof-2

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).

dof-3

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.

dof-4

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:

My friend Kim. She is an astrophysicist :) (shot at f/1.8, note the shallow depth of field)
My friend Kim. She is an astrophysicist :) (shot at f/1.8, note the shallow depth of field)

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:

Lake Matheson in New Zealand (shot at f/10).
Lake Matheson in New Zealand (shot at f/10).

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!

Thank you for reading!!

xx Ana :)

10 thoughts on “Depth Of Field

    • 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

  1. Wow…

    When I first found your article, I was like “oh…so longgg.”

    Then I scrolled down and saw the illustrations and I was like “interesting!”

    So, I scrolled up and read from the beginning to the end, now I was like “Wowwww, an extremely good explanation.”

    I’m glad I found your article.

    By the way, what program did you use to draw the illustration? Adobe Illustrator?

    Thanks…

    Like

  2. Thank you for making this. I’m an engineer and I’m trying to connect the dots between my current knowledge and this new photography hobby of mine. This fits the bill perfectly.

    What I’m getting from this is if you want a shallower depth of field it’s hard to justify squeezing the last drops of a smaller fstop because of the squared on the distance to subject factor. For example from a 50mm f1.8, going to an f1.2 would not only be quite expansive but also only reduce by 0.6 as getting just 10cm closer would reduce by a factor 4. Quite the difference.

    Like

  3. Wow awesome post!!! There’s much misinformation online about what determines depth of field. I got very curious about it since my own experience doesn’t match a lot of what people say. A big common misunderstanding is that reducing or increasing the focal length and f/ number by the same factor will not change the depth of field since the changes “cancel out”, but that’s not true because depth of field is inversely related to the square of focal length and only linearly related to the f/ number. This means that using focal length extenders or reducers indeed changes the depth of field even though they don’t change the physical aperture size. They multipy DoField by 1/magnification when the subject distance is constant and the f/ number changes by the same factor as the magnification. Also, an image from a 50mm f/1.4 lens has twice the depth of field than that of an image from a 100mm f2.8 lens when the pixel size and the subject distance are constant, so having a longer focal length even with the same physical aperture size helps with obtaining a shallower depth of field. (If I’m understanding those formulas correctly)
    I wonder when the assumptions used in the formulas for approximation wouldn’t hold up? For example, in the last example you gave, the DoField is approximately 200+km, but the subject is only 1000m away, which means the DoField extends into the imaging plane and doesn’t make too much sense, as we know when a subject is too close to the camera it will become very blurry. Or, for example, if a subject is close to the lens, then the depth of field behind and in front of the subject might differ to a noticeable degree. Will we get a much more complicated formula if we want to account for these situations?

    Like

  4. Thank you for going into the details and actually discussing the scientific part of the physics behind it. I have looked up many articles and youtube videos but nobody addressed the fundamentals such as pixels, depth of field, and many other parameters and their mutual relationships. overall a great article that will cater to both science nerds and photographers alike.

    Like

Leave a comment