Depth of Field and Hyperfocal Distance Equations and Approximations

Brian A. Barsky (c) 2007

Depth of field "... is the range of object distances within which objects are imaged with acceptable sharpness" (from "Basic Photographic Materials and Processes", Second Edition, Leslie Stroebel, et.al., 2000). That range is between the near and far distances, for acceptable sharpness.

In an optical system such as a camera lens, there is plane in the 3D scene, located at the focus distance, that is rendered at optimal sharpness. There is a swath of volume through the scene that is rendered in reasonable sharpness, within a permissible circle of confusion, to be exact. This region of acceptable focus is delineated by near and far planes. However, this region is not centered about the focus distance; rather, the near plane is closer to the plane of perfect focus than is the far plane.

The particular distance that is imaged in perfect focus can be selected by moving the lens towards or away from the film/image plane. Changing the focus distance will have a concomitant effect on the amount of depth of field, that is, the size of the swath. Specifically, for a given f/stop and focal length, focusing at a distance that is close to the camera provides only a narrow range of depths being in focus, with the amount of depth of field increasing in a nonlinear fashion as the focus distance is increased, and conversely.

The size of the aperture also affects the amount of depth of field. The infinitesimal aperture of a pinhole camera has infinite depth of field, and this decreases as the aperture increases, and conversely. An important subtlety overlooked by most photographers is that not only does focal length have a direct effect on depth of field, but if focal length is modified while holding the f/stop constant, then the aperture size must also be changed, which provides for an additional effect on the amount of depth of field. Of course, for a fixed focal length lens, this distinction does not matter.

Thus, for a fixed f/stop and fixed focus distance, changing the focal length of the lens (zooming in or out) will again affect the depth of field, since the aperture changes. In particular, increasing the focal length (zooming in) with a constant f/stop decreases the depth of field, because the aperture increases, and conversely.

The above dicussion first considered changing the focus distance for a fixed aperture and focal length (and hence a fixed f/stop) and then discussed changing the focal length for a fixed focus distance and a fixed f/stop (and hence a changing aperture). Note that these two situations have a somewhat opposite effect on depth of field, insofar as an increase in depth of field corresponds to an increase in the focus distance but to a decrease in focal length (and, of course, conversely, depth of field decreases as the focus distance decreases or as the focal length increases).

This leads to the question of which of these two parameters, the focus distance or the focal length, might dominate in the sense that if both are changed so as to have the opposite effect on depth of field, will the depth of field increase, decrease, or remain unchanged? In fact, it is of interest to consider the possibility that manipulating both the focus distance and the focal length appropriately could keep the depth of field constant. For example, consider simultaneously decreasing the focus distance (by moving the camera towards the subject) and decreasing the focal length. Doing so is interesting because these two simultaneous actions can be done carefully so that the magnification of the subject remains constant. This would be the case if both the focus distance and focal length are decreased by the same scale factor. Under these circumstances, the effects on depth of field of the competing factors of focus distance and focal length approximately (but not exactly) cancel each other out, resulting in depth of field that is virtually unchanged. This is the case when the focus dstance is not too large; specifically, only when the focus distance for the shortest lens is less than about 1/4 of what is known as the hyperfocal distance for that lens.

The hyperfocal distance is the focusing distance such that the far distance of acceptable focus is at infinity.

Denote the hyperfocal distance by h (in mm), the lens focal length by f (in mm), the focusing distance by d, the near distance for acceptable sharpness by d_n, the far distance for acceptable sharpness by d_f, the aperture, expressed as an f-number (f/1.4, f/2, f/2.8, ...), by a, and the circle of confusion diameter by c (in mm). A typical value of c for a 35mm film camera is 0.03 mm. Since sensors in consumer digital cameras are smaller, a value of 0.02 mm for that case would be more realistic.

The following equations and approximations (assuming relatively small focal lengths (f)) calculate the hyperfocal distance, the near distance of acceptable sharpness, and the far distance of acceptable sharpness:

Hyperfocal distance, h:
h = f2 / (a*c) + f
which can approximated as:
h= f2 / (a*c)

The near distance of acceptable sharpness, d_n:
d_n = d (h - f) / [h + d - 2f]
which can approximated as:
d_n = d * h / [h + (d - f)]
and which can be further approximated as:
d_n = d * h / [ h + d ]

Note the near distance of acceptable sharpness when focused at the hyperfocal distance can be determined by substituting d = h into the above equations yielding:
d_n = h / 2

That means that when a lens is focused at the hyperfocal distance everything from midway between the lens and the hyperfocal distance to infinity will be of acceptable sharpness.

Substituting the approximation for hyperfocal distance into the approximation for the near distance yields an expression in terms of the lens focal length f, the focusing distance d, the aperture a, and the circle of confusion diameter c:
d_n = d * f2 / [ f2 + a * c * d ]

The distance from the near distance of acceptable sharpness to the focusing distance:
d - d_n = a * c * d2 / [ f2 + a * c * d ] (*)

The far distance of acceptable sharpness, d_f:
d_f = d (h - f) / [h - (d - f)]
which can approximated as:
d_f = d * h / [h - (d - f)]
and which can be further approximated as:
d_f = d * h / [ h - d ]

Substituting the approximation for hyperfocal distance into the approximation for the far distance of acceptable sharpness yields an expression in terms of the lens focal length f, the focusing distance d, the aperture a, and the circle of confusion diameter c:
d_f = d * f2 / [ f2 - a * c * d ]

The distance from the focusing distance to the far distance of acceptable sharpness is:
d_f - d = a * c * d2 / [ f2 - a * c * d ] (**)

The total depth of field is d_f - d_n. Substituting the expressions from the above equations for d_f and d_n yields:
2 * a * c * d2 * f2 / [ f4 - a2 * c2 * d2 ]

It can be seen that the distance from the far distance of acceptable sharpness to the focusing distance is more than the distance from the focusing distance to the near distance of acceptable sharpness.

The ratio of the distance from the focusing distance to the far distance of acceptable sharpness to the distance from the near distance of acceptable sharpness to the focusing distance: can be found by dividing equation (**) by equation (*), yielding:
[ d_f - d ] / [ d - d_n ] = [ f2 + a * c * d ] / [ f2 - a * c * d ]

From this equation, it is easy to see that the rule of thumb that the acceptable sharpness extends from 1/3 in front of the focusing distance to 2/3 behind it can be quite erroneous. As an extreme case, consider the lens focused at the hyperfocal distance; then the image has acceptable sharpness from 1/2 the focusing distance to infinity.

In fact, we can determine where to focus, as a fraction of hyperfocal distance, to achieve any desirable ratio of distance behind the focusing distance to the distance in front of it. Let that ratio be r; that is, acceptable sharpness extends from 1/(1+r) in front of the focusing distance to r/(1+r) behind it (where r ³ 1). Denote the proportion of hyperfocal distance by p. Substituting d = p*h and h= f2 / (a*c) into the right hand side of the above equation, and setting the left hand side equal to r, yields
r = [ 1 + p ] / [ 1 - p ]

Solving for p yields:
p = [ r - 1 ] / [ r + 1 ]

Thus, for the case of the acceptable sharpness extends from 1/3 in front of the focusing distance to 2/3 behind it, r is 2, and hence p is 1/3. That means that the rule of thumb is only true when the lens is focused at 1/3 of the hyperfocal distance.

The total depth of field, that is the distance between the near and far distance of acceptable sharpness, can be found by adding equations (*) and (**):
d_f - d_n = 2 * a * c * d2 * f2 / [ f4 - a 2 * c 2* d 2 ]

Since focal length and circle of confusion diameter use units of millimeters, the calculated quantities will also have units of millimeters; to convert to feet, divide by 304.8 mm / foot.

 

References:
Allen R. Greenleaf, Photographic Optics, The MacMillan Company, New York, 1950.
Alfred A. Blaker, Applied Depth of Field, Focal Press, 1985.