First, what is depth of field? Here’s a quote from the Focal Encyclopedia of Photography:
When the camera lens is focussed to give a sharp image of a particular object, other objects closer or further away do not appear equally sharp. The decline of focus is gradual and there is a zone extending in front of and behind the focussed distance where the blur is too small to be noticeable and can be accepted as sharp. This zone is known as the depth of field of the lens.
Focal Press desk edition 1961
Why would you care?
Viewers like a mixture of sharpness in some parts and artistic fuzziness in others. In theory, a camera lens can focus at a single distance, which you select with manual focus, or let the camera do so with auto focus. Most of the time, you want more than a single plane of focus, and so understanding how your camera can capture a range of distances which are in focus (or close enough) while producing a nice blur in other parts is important for producing pleasing images.
Technicalities
I’m the kind that wants to see the math behind things, and go from there. My first draft of this post started with the formulae, but on second thought, I’m going to put that last for the minority who get that far.
However, the nice thing about looking at a formula is that if the formula uses four measurements to calculate Depth of Field (DOF), then we know that there are exactly four things that influence the DOF in a lens. Let’s take a look at them.
Aperture (f)
This is the factor that most photographers begin and end with when (or if) they think about DOF. The smaller apertures (bigger numbers) provide more DOF. Large apertures restrict the DOF. At f/2.8 you might find that in a portrait the eye closest to the camera is in focus and the far eye is not. Or, in a group photograph, the front row is in focus and rows behind are not. In the former, many photographers will still use a wide aperture to separate the subject from the background and to soften parts of the face, while for a group, a smaller aperture is called for because everyone in the group needs to be sharp.
Focal length (F)
Wide angle lenses (or the wide end of a zoom) provide a larger DOF and telephoto lenses less. This is why cell phone cameras typically get practically everything in focus, and this is also why they don’t give the nice out-of-focus backgrounds (aka bokeh) unless it is created artificially by blurring. It’s also why it’s not easy getting the eye of a flying bird in perfect focus when using a telephoto lens.
Subject distance (D)
The further away the subject, the larger the DOF. This wasn’t really obvious to me. I suppose I realised that in a landscape photo, everything in the distance was about equally sharp, and if I thought about it I probably would work out that I really only worried about DOF in fairly close quarters. In practical terms, for a given image size, if you increase the distance, you need to increase the magnification of the lens (Focal Length), which diminishes the DOF again, but as you’ll see a bit later, distance usually wins.
Circle of confusion (c)
I’m only including this because it’s in the equation. For all intents and purposes, regard it as a constant. It’s not something you can set on your camera, it’s a pre-determined value set by external considerations. However, if you want to calculate exactly what will be in acceptable focus, you need to decide what acceptable means, and that leads to selecting a value for this variable. Move along, nothing to see here.
Some other considerations
How is the DOF range distributed?
The DOF range begins in front of the focussing point and extends behind it. There is always more in focus behind the subject than in front, but this effect diminishes with smaller distances and larger apertures. A typical portrait set up with large apertures and typical subject distances will have the DOF fairly evenly distributed ahead and behind the focussing point.
I’m not going to cover this, but there is a specific distance for each lens/aperture called the hyperfocal distance, where everything behind that point is in focus. Worth a look-see if you’re into landscapes. Check out Wikipedia for a starting point.
Effect of Crop Factor
When you are using a camera with a sensor which is not full frame, the effective aperture for DOF purposes is the f-stop you set divided by the crop factor. So setting f/5.6 on the lens results in a f/3.7 for calculating DOF. This would imply the DOF would be reduced by the crop factor, but I’ve seen arguments that say that if you were using a FF camera you would use a longer lens to get the same image, in fact one with the initial focal length multiplied by the crop factor, so that would exactly cancel out. Looking at the formula, this makes sense because the actual focal length is used in the formula, not the effective focal length.
Distance vs. Focal length
For a given f-stop and circle of confusion, DOF is proportional to D2/F2. Now a typical range of lenses may be something like 24mm to 300mm, or possibly a bit wider, depending on budget and enthusiasm. A typical focussing distance might be 6’ (I still think in feet) or 2 metres, which is 2000mm. So the focal length is usually a much smaller number than focussing distance, possibly only 10% of it.
That means that focussing distance will win out over focal length, much of the time. I now know why my 105mm macro lens is so fussy about focussing when I get really close; it’s a longer focal length, and typically used at distances which are pretty close to the focal length, so the “D” part of the equation doesn’t get a chance to pull up the value.
The following tables are my attempt to illustrate how DOF varies with different values of aperture (rows) and focal length (columns). The values in each cell are the calculated DOF in cms. The red cells highlight choices which end up with a very restricted DOF (less than 3cm) and the green cells show choices which provide ample (more than 20cm) DOF. There is nothing magic about 3cm and 20cm, I just chose a small number and a bigger number for illustration. Each table shows a representative focussing distance, 100cm, 200cm and 800cm.
Conclusions
Let’s be clear, I have never needed to know the exact DOF in any situation. The formulae and the tables give numbers, but the only important things are what makes DOF bigger or smaller, and some feeling of how quickly each factor will change DOF.
Knowing what you can change (and in which direction!) is a good thing. However, in critical situations, where you don’t get a “do-over”, two tools are very useful. Firstly, most cameras have a button you can configure to momentarily stop down to your selected aperture, instead of seeing it through the lens’ maximum aperture. Use it to see what’s sharp and what isn’t! Secondly, with digital cameras, there is no cost to taking a test picture; do so, and view the result at high magnification to check the sharpness.
Finally, just about every setting on your camera is a compromise. In practice, setting the optimum aperture for DOF could well require a shutter speed that results in camera shake or an ISO that results in too much noise. Taking a photo from further away increases DOF, but then you need a longer lens, which decreases DOF and may induce camera shake. You pays your money and takes your chances!
The Formulae
The near point of focus, Dn = D / (1 + Dcf / F2) and the far point, Df = D / (1 – Dcf / F2)
So depth of field would be the difference, or distance, between those values, or Df minus Dn.
D is the focussed distance
c is the size of the circle of confusion which is a fancy way of saying how much blur is OK
f is the effective f-number of the chosen aperture on the lens
and F is the focal length of the lens (or the zoom setting for non-prime lenses)
That’s not a particularly simple formula to visualise, and Excel didn’t seem to want to work with it in any consistent way, so I found a nicer approximation in Wikipedia:
DOF is approximately equal to 2D2fc / F2 (using the notations I used above).
The same units must be used for all measurements, e.g. centimetres. In the Excel spreadsheet, I converted the focal lengths from mm to cm in the formula.