Depth of field




circles of confusion, Sigma 105mm macro at f2.8

When considering the optics of focusing, it's helpful to think about the light that comes from just one point of the subject. In the image above, I have shot christmas tree lights with a macro lens wide open at f2.8. Each bulb is effectively a point source of light. From each point rays hit the lens all over the lens surface, and they are then directed onto the sensor. If the point is in focus, all the light rays from that point hit the sensor at the same place. If the point is not in focus, they don't, and the point is blurred. The amount of blur is the size of the circle made by the rays from that point.

A lens can't focus on everything at once. Most lenses are designed to focus all the points in one plane perpendicular to the axis of the lens. If you set the focus distance of the lens to 1 meter, then all points in the plane 1 meter from the lens should be in focus. So if a point is in the plane 99.99cm from the lens, it's not quite in focus. But would we notice ? Probably not because the size of the circle would be so small, it would fit within one pixel of the sensor; or the amount of focus blur would be less than the diffraction of light or the optical errors of the lens. To get a practical idea of what is in focus, we use the concept of circle of confusion, or CoC. This is the smallest circle of blur that is going to be noticeable for the purpose we have in mind. If we know the CoC we require, there is a formula to work out the range of distances over which objects are in focus - this is called the depth of field. We can also work out the minimum focusing distance which brings all objects beyond that distance in focus - this is called the hyperfocal distance.

Below is a depth-of-field calculator which will apply this formula for you. You set the CoC by entering the camera's pixel size, and the number of pixels of the CoC. The dropdown on the left contains a few example cameras including some DSLRs and a 8mp digicam with 1/1.8" sensor - if you select one of these the pixel size is set for you. Enter values for focal length, aperture and subject distance, then press Compute. Then the depth of field range, and hyperfocal distance are shown in meters.


 Camera Pixel size
(micro m)
Pixels CoC
(micro m)
Focal Length
Aperture Distance
Focus From
Focus To

Although there are a few depth-of-field calculators on the internet, they don't give much insight into the right value of CoC to use. There are 'accepted' values for CoC that suit moderate enlargements from 35mm film, but I don't think these are reliable for digital cameras where the sensor and pixel sizes vary. So I have tried to determine the value of CoC in terms of digital camera pixels. I set up a ruler angled at 30 degrees to the camera. The distance of the ruler from the camera in the direction the lens points, changes by 0.5 centimeter, for every centimeter along the ruler ( for the maths : sin(30 degrees)=0.5 ). My plan was to set up the camera, lens and ruler so that the size of  the CoC in pixels would be easy to see in a photograph of the ruler. I used a Canon 5D, 105mm macro at f4 at a distance of 0.8m. Well, here is the photo, a 100% crop, converted in Camera Raw with no sharpening. I see the sharp area between 16.9 and 18.5 on the ruler, which is a DoF of 0.8cm.

Put these numbers into the calculator ...

camera : 5D

CoC : 2.5 pixels

lens : 105mm macro

distance : 0.8m

aperture : 4

... and you get DoF=0.8cm, as required. What does that tell us ? It shows the CoC for a digital camera like the 5D should be set to about 2.5 pixels. Conventional wisdom puts the CoC at 30 micrometers for film - we are measuring it at 20 micrometers. The difference is probably because film users don't enlarge to the same degree as a 100% view on screen; or possibly because digital out-resolves film and a higher standard of focusing is needed.

Depth of field in practice

One thing is a bit surprising about the numbers coming out of the DoF calculator  : the hyperfocal distance for a 500mm f4 lens wide open is about 3000m ! Even at f22 it's 700m. Generally I like a 500mm shot to throw the background out of focus so this is not a problem. If you try to compose a landscape with a 500mm lens having foreground and background elements, then you are going to have difficulties. A more common scenario is to focus on foreground and background elements with a wide-angle lens. A 28mm lens at f8 has a hyperfocal distance of 5m. If you focus on a point 5m away, you will have depth of field from 2.5m to infinity. That is useful. Note there is no need to use extreme apertures like f22 if your foreground elements are a few paces away. By focusing at the hyperfocal distance, you maximise the depth of field, because you are focusing just far enough away to bring points at infinity into focus.

Macro photography brings a particular set of problems. A 105mm macro at 1:1 has a subject distance of about 0.31m. Using f22 you have a depth of field of 5mm - proportionally less for lower f numbers. It is inherently difficult to get all the subject in focus at these distances and a small aperture is often essential. for photography