Technology

Useful knowledge of optics -
Depth of field, hyperfocal distance, and hyperfocal sequence

Introduction

Many of the readers of this white paper might have had questions before about the depth of field (DoF) not only when using machine vision systems but also when taking photographs with ordinary cameras.
The depth of field is the distance between the nearest and the farthest objects in an image that appear acceptably sharp. You can find information about the depth of field on the Internet, in off-the-shelf books, and in trade journals. White papers about the depth of field are also available on our website under the headings Basics of camera lenses: Guidelines for lens selection and Consideration for depth of field in machine vision. These white papers discuss the depth of field from a different perspective than the commonly adopted one in the photography industry.
This white paper describes, in an easy-to-understand way, the depth of field in relation to the hyperfocal distance and the hyperfocal sequence. Although these lens properties are closely related to each other, it is difficult to find such information on the Internet. Therefore, you will find this white paper useful.

  1. 1.Depth of field
  2. 2.Hyperfocal distance
  3. 3.Hyperfocal sequence

1. Depth of field

For a detailed description of the depth of field, see Basics of camera lenses: Guidelines for lens selection and Consideration for depth of field in machine vision on our website. This section provides an overview of the depth of field and some added information about it.

1.1. What is the depth of field?

he depth of field is the distance between the nearest and the farthest objects in an image that appear acceptably sharp.
When you shoot images, you focus a camera on objects at arbitrary distances. The distance to the nearest point in acceptably sharp focus in front of the best-focused point is called the front depth of field whereas the distance to the farthest point in acceptably sharp focus behind the best-focused point is called the rear depth of field. The distance between these points is the total depth of field.
The depth of field can be calculated as described in the following subsection. However, objects appear differently, depending on their size and surface characteristics as well as the optical aberrations of the lens used. Therefore, cameras do not always come into sharp focus precisely at the calculated threshold; rather, they gradually come into and out of focus around a threshold.

1.2. Permissible circle of confusion versus depth of focus

The depth of focus refers to the tolerance of placement of an image sensor in relation to the lens. The depth of focus is the conjugate of the depth of field. Since both the depth of field and the depth of focus are abbreviated as DoF, they are hereinafter referred to as DoFi and DoFo respectively for the sake of clarity.
The depth of focus (DoFo) is the distance over which a sensor can be displaced along the optical axis while an object remains in acceptably sharp focus. DoFo can be calculated from the permissible circle of confusion (δ) and the effective f-number (Fe).

[𝐷𝑜𝐹_𝑜=±𝛿∙𝐹_𝑒=2∙𝛿∙𝐹_𝑒
  • DoFo:Depth of focus
  • Fe:Effective f-number
  • δ:Permissible circle of confusion
    (abbreviated as CoC)
Image-side focus

An image of a point source that is not in perfect focus appears as a blur spot called a circle of confusion (CoC). The size of the smallest spot that an image sensor cannot recognize as a blur is called the permissible circle of confusion or simply a circle of confusion.
Even today when digital cameras are the mainstream cameras, the CoC diameters (δ) commonly referenced on the Internet (e.g., 0.033 mm, or 1/1300th of the image diagonal) are for images on silver halide films. These values are specified for images that are printed on a photographic paper of a certain size and viewed at a certain distance. In machine vision, which processes each pixel of an image sensor at high brightness levels, the permissible circle of confusion (δ) is calculated based on the pixel pitch (Ppix) or the diameter of the Airy disk (DAiry) that represents a limit to the optical resolution of an image created by a lens. In the case of monochrome cameras, the larger of these values is used as δ. (For color cameras with an on-chip color Bayer array filter, a value equal to two to three times δ is generally used.)

𝐷_𝐴𝑖𝑟𝑦=2.44∙𝜆∙𝐹_𝑒 ≈1.34∙𝐹_𝑒 ("at"  𝜆=0.55 "μm" )
  • DAiry:Diameter of the Airy disk
  • λ:Wavelength

In order to determine the depth of focus (DoFo) accurately, it is necessary to consider the optical aberrations of a lens such as an image plane curvature. However, since such accuracy is generally unnecessary, the depth of focus is calculated based only on parameters along the optical axis.
The DoFo value obtained by the above equation represents the most stringent case in terms of accuracy. For actual applications, a more relaxed value can be used as necessary. (For details, see the white paper Consideration for depth of field in machine vision from Toshiba Teli.)

1.3. Depth of field and optical magnification

The information available on the Internet states that the depth of field has the following characteristics:

  • The greater the f-number (i.e., the more the aperture is reduced), the greater the depth of field.
  • The shorter the focal length (i.e., the wider angle a lens is), the greater the depth of field.
  • The farther away a subject is, the greater the depth of field.
  • The rear depth of field is greater than the front depth of field.

These are all true, but this information does not help you determine which lens provides a greater depth of field because cameras with different sensor sizes require lenses with different focal lengths to obtain the same angle of view.
Note that the depth of field is related to optical magnification. In the case of machine vision applications requiring close focusing at relatively high magnification, it would be safe to consider as follows:

Two optical systems provide the same depth of field when their lenses have the same optical magnification and f-number and their image sensors have the same pixel pitch.

Remember that the previous subsection mentioned that the depth of focus is the conjugate of the depth of field. A change in the object-side depth of focus caused by a displacement of the image plane by half the depth of focus is equal to half the depth of field. A slight displacement of an image plane causes the object-side focal point to shift by as much as a change in the image-side depth of focus divided by the longitudinal magnification of the lens. Because the depth of focus is symmetrical around the image plane, the depth of field is also symmetrical around the image plane.

However, if the optical magnification of a lens differs greatly at both ends of the depth of focus, the front and rear depths of field are not equal as described in 3 and 4 above. Equations for the depth of field are presented in the following subsections. In the case of machine vision and other applications requiring relatively close focusing, we recommend using an equation with an optical magnification term. Otherwise, we recommend using an equation with a subject distance term.

1.4. Calculating the depth of field

This section presents three ways of calculating the depth of field.

Equation using optical magnification

Many machine vision applications shoot subjects at close distances (for example, at a distance of 300 mm). For close-up shooting, the depth of field can be calculated using optical magnification. The previous subsection explained the depth of field in relation to longitudinal magnification (α). The following shows an equation for calculating the depth of field using linear magnification, β (also called lateral or transverse magnification) since optical magnification generally means linear magnification. α and β have the following relationship: α=β2.

Equation using optical magnification
𝐷𝑜𝐹_𝑜=±𝛿∙𝐹_𝑒 [𝐷𝑜𝐹]_𝑖=±[𝐷𝑜𝐹]_𝑜/𝛼=±(𝛿∙𝐹_𝑒)/𝛼  =±(𝛿∙𝐹_𝑒)/𝛽^2
  • DoFo:Depth of focus
  • DoFi:Depth of field
  • f:Focal length
  • Fe:Effective f-number
  • α:Longitudinal optical magnification
  • β:Linear optical magnification
  • δ:Diameter of the Airy disk
    (abbreviated as CoC)

Equation using Newton’s lens formula

The following shows an equation for calculating the depth of field using the distance to a subject (x) from the focal point.
Newton’s lens formula uses the front focal point as an origin to measure the distance to a subject (x). For typical shooting, a point on the opposite side of an image takes a negative value.
The front depth of field (DoFN) is positive whereas the rear depth of field (DoFF) is negative. Since the total depth of field represents a distance, it is expressed as an absolute value.
As effective f-numbers, the values calculated from the optical magnification at the front and rear depths of focus (FeN and FeF) are used. For general applications, FeN and FeF can be replaced with the Fe value that is calculated from optical magnification at a distance to the subject (x).

Equation using Newton’s lens formula
[DoF]_i=[DoF]_N-[DoF]_F [DoF]_F=(δ∙F_eF [∙x]^2)/(f^2-δ∙F_eF∙x)≈(δ∙F_e [∙x]^2)/(f^2-δ∙F_e∙x) [DoF]_R=-(δ∙F_eR [∙x]^2)/(f^2+δ∙F_eR∙x)≈-(δ∙F_e [∙x]^2)/(f^2+δ∙F_e∙x)
  • DoFo:Depth of focus
  • DoFi:Depth of field (absolute value)
  • DoFF:Front depth of field (positive)
  • DoFR:Rear depth of field (negative)
  • f:Focal length
  • Fe:Effective f-number at x
  • FeF:Effective f-number at the front depth of focus
  • FeR:Effective f-number at the rear depth of focus
  • δ:Diameter of the Airy disk
    (abbreviated as CoC)
  • x:Distance to a subject
    (from the front focal point)

FeN and FeF are calculated as described below.

From Newton’s lens formula, the lens extension (x’) is expressed as follows using the camera-to-subject distance (x):
x'=-f^2/x
The lens extensions (xN’ and xF’) at the nearest point of the front rear depth of field (DoFN) and the farthest point of the rear depth of field (DoFF) are calculated as follows using the effective f-number at x, Fex (denoted as Fe in the above paragraph):
F_ex=F(1-β_x)
x_F'=x^'+δ∙F_ex=-f^2/x+δ∙F_ex
x_R'=x^'-δ∙F_ex=-f^2/x-δ∙F_ex
The linear magnification factors (βN and βF) and the effective f-numbers (FeN and FeF) at xN’ and xF’ are calculated as follows:
β_F=x_F'/f
β_R=x_R'/f
F_eF=F(1-β_F )
F_eR=F(1-β_R )

  • f:Focal length
  • Fe:Effective f-number
  • Fex:Effective f-number at x (=Fe)
  • FeF:Effective f-number at the front depth of focus
  • FeR:Effective f-number at the rear depth of focus
  • βx:Linear magnification factors at x
  • βF:Linear magnification factors at the front depth of focus
  • βR:Linear magnification factors at the rear depth of focus
  • δ:Diameter of the Airy disk (abbreviated as CoC)
  • x:Distance to a subject (from the front focal point)
  • xF:Distance to a subject at the front depth of focus
    (from the front focal point)
  • xR:Distance to a subject at the rear depth of focus
    (from the front focal point)
  • x’:Lens extension
  • xF’:Lens extension at the front depth of focus
  • xR’:Lens extension at the rear depth of focus

Equation using Gauss' lens formula

Gauss’ lens formula (1/(-a)+1/b=1/f) expresses the depth of field using the distance to a subject from the principal point.
The subject distance used in Gauss’ lens formula is greater than the one used in Newton’s lens formula by the focal length of a lens (f). Therefore, the depth of field can be easily obtained simply by replacing x in Newton’s lens formula with a+f.
The origin of the coordinate system for the subject distance (a) is the front principal point. For typical shooting, a point on the opposite side of an image takes a negative value.

x=a+f [DoF]_i=[DoF]_F-[DoF]_R [DoF]_F=(δ∙F_eF [∙(a+f)]^2)/(f^2-δ∙F_eF∙(a+f))≈(δ∙F_e [∙(a+f)]^2)/(f^2-δ∙F_e∙(a+f)) [DoF]_N=-(δ∙F_eR [∙(a+f)]^2)/(f^2+δ∙F_eR∙(a+f))≈-(δ∙F_e [∙(a+f)]^2)/(f^2+δ∙F_e∙(a+f))
  • DoFo:Depth of focus
  • DoFi:Depth of field (absolute value)
  • DoFF:Front depth of field (positive)
  • DoFR:Rear depth of field (negative)
  • f:Focal length
  • Fe:Effective f-number
  • δ:Diameter of the Airy disk
    (abbreviated as CoC)
  • a:Subject distance
    (from the front principal point)

2.Hyperfocal distance

2.1. What is a hyperfocal distance?

When a lens is focused on an object at a distance of H, a depth of field extends from infinity to H/2. In this case, H is called a hyperfocal distance.

H=-f^2/(δ∙F)

2.2. Calculating a hyperfocal distance

Whens a lens is focused at infinity (x=∞, x’=0), the hyperfocal distance is equal to the front depth of field as given by the following equation. (Here, we use Newton’s lens formula since our attention is on the lens extension, x’.)
Optical magnification has not been determined yet when you calculate a hyperfocal distance. Therefore, we use the f-number (F) at infinity (that is not modified by optical magnification) instead of the effective f-number (Fe).

x=∞ x^'=0 x_R^'=x^'-δ∙F=-δ∙F(over infinity) x_F'=x^'+δ∙F=δ∙F x_F=-f^2/x_F'=-f^2/(δ∙F)=H
  • H:Hyperfocal sequence
  • f:Focal length
  • F:f-number
  • δ:Diameter of the Airy disk
    (abbreviated as CoC)
  • x:Distance to a subject
    (from the front focal point)
  • xF:Distance to a subject at the front depth of focus
    (from the front focal point)
  • xR:Distance to a subject at the rear depth of focus
    (from the front focal point)
  • x':Lens extension
  • xF':Lens extension at the front depth of focus
  • xR':Lens extension at the rear depth of focus

3. Hyperfocal sequence

3.1. What is a hyperfocal sequence?

Depths of focus are arranged as a sequence to show the ranges over which an object remains in acceptably sharp focus. This sequence is called a hyperfocal sequence (HS) or consecutive depths of focus.

3.2. Obtaining a hyperfocal sequence

Focusing at H/n (where n is an integer) causes the depth of field to extend from N/(n+1) to H/(n-1). A hyperfocal sequence is a sequence of N/n:

HS=(∞),H,H/2,H/3,H/4,H/5,…,H/n,…

When a lens is focused at H/n, H/(n-1) and H/(n+1) are the rear and front depths of field respectively.
For example, a lens focused at H holds a depth of field from H/2 to infinity.
As shown in the previous subsection, when a lens is focused at infinity, the rear depth of field is infinite, going slightly “over infinity,” while the front depth of field is H.
Dividing a hyperfocal distance (H) by an integer (n) means that the focal point shifts along the optical axis by half the depth of focus (δ*Fe) times n in relation to the lens extension (x’) at infinity.

x^'=x_∞^'+n∙δ∙F_e x_F'=x_∞^'+(n+1)∙δ∙F_e x_R'=x_∞^'+(n-1)∙δ∙F_e

  • x’:Lens extension
  • xF’:Lens extension at the front depth of focus
  • xR’:Lens extension at the rear depth of focus
  • n:Integer

3.3. Example of shooting at infinity

Nowadays, surveillance cameras in distant-view shooting mode employ image shooting and processing techniques for machine vision cameras, for example, to synchronize trigger control with lighting.
Suppose, for example, a wavelength of 550 nm, a camera with a pixel pitch of 3.45 μm, and an F2 lens with a focal length (f) of 50 mm. Let us calculate consecutive depths of field under these conditions.
The specifications for the camera and the lens are:

  1. Wavelength: λ=550 nm=0.55 μm
  2. Pixel pitch, PPix=3.45 μm
  3. Focal length, f=50 mm
  4. f-number, F=2

The permissible circle of confusion (δ) is the larger of the pixel pitch (Ppix) and the diameter of the Airy disk (DAiry). So, let us calculate DAiry to determine δ:

Hence, the hyperfocal distance (H) is calculated as:

The hyperfocal sequence is a sequence of successive H/n values, where n is an integer. The following table shows the values of H to H/5.
(The unit of measure is mm. The negative sign that represents a direction is omitted.)

When a lens is focused at a hyperfocal distance (H) of about 362.3 m, the depth of field extends from infinity to H/2. So, the farthest point is infinity, and the nearest point is roughly 181.2 m. When the lens is focused at H/3 (≈120.8 m), the depth of field extends from about 181.2 m to about 90.6 m.

3.4. Example of close-up shooting

Most machine vision applications provide close focusing. The following table shows the consecutive depths of field for relatively close focusing under the same conditions as above.

In this case also, focusing at H/n causes the depth of field to extend from H/(n+1) to H/(n-1). As you see, close focusing causes the depths of field to become considerably shallower than infinity focusing.
In the case of close focusing with large optical magnification, the depth-of-field values differ considerably from the results of the calculation shown in Section 2.4. It is therefore recommended to consider the above depth-of-field values as rough estimates at an early stage of system design.

(Reference: Shotaro Yoshida (1997) Lens Science for Photographers. Chijinshokan Co. Ltd.)