Shenzhen Kai Mo Rui Electronic Technology Co. LTDShenzhen Kai Mo Rui Electronic Technology Co. LTD

News

How to Calculate Depth of Field

Source:Shenzhen Kai Mo Rui Electronic Technology Co. LTD2026-08-26

1.1 What is Depth of Field?

Depth of Field (DoF) is the distance between the nearest and farthest objects that appear acceptably sharp in an image. When capturing an image, the camera is focused on an object at a given distance. The distance from the optimal focus point to the nearest plane of acceptable sharp focus is known as the front depth‑of‑field. The distance from the optimal focus point to the farthest plane of acceptable sharp focus is the rear depth‑of‑field. The distance spanning these two planes is the total depth of field. Depth of field can be calculated as described in the following sections.

Nevertheless, object appearance varies depending on object size, surface characteristics and optical aberrations of the lens. Therefore, sharp focus does not stop precisely at the calculated threshold; instead, objects gradually go in and out of focus around that threshold.

1.2 Depth of Focus vs Depth of Field (Easily Confused Terms)

Depth of Focus refers to the positional tolerance of the image sensor relative to the lens. It is the optical conjugate of depth of field. Since both depth of field and depth of focus are commonly abbreviated as DoF, they are denoted below as DoFi (Depth of Field, object‑side) and DoFo (Depth of Focus, image‑side) for clarity.

Depth of Focus (DoFo) is the allowable distance the sensor can move along the optical axis while the object remains in acceptably sharp focus. DoFo can be calculated from the permissible Circle of Confusion (δ) and the effective f‑number (Fe).

640.webp.png

 

Where: DoFo = Depth of Focus Fe = Effective f‑number δ = Circle of Confusion (CoC)

 640.webp (1).png

An out‑of‑focus point‑source forms a blurred spot called the Circle of Confusion (CoC). The maximum size of a spot that the image sensor still perceives as sharp (not blurred) defines the permissible circle of confusion.

For digital cameras processing each sensor pixel at high brightness levels, the permissible Circle of Confusion (δ) is determined by either the pixel pitch (\(P_{pix}\)) or the diameter of the Airy disk (\(D_{Airy}\)), which represents the theoretical optical resolution limit of the lens. For monochrome cameras, the larger of these two values is adopted as δ. For colour cameras equipped with on‑chip Bayer colour filter arrays, δ is typically set to 2‑3 times this base value.

 640.webp (3).png

Where: \(D_{Airy}\) = Diameter of the Airy disk λ = Wavelength of light

To compute accurate Depth of Focus (DoFo), lens optical aberrations such as field curvature should be considered. Such high precision is rarely required in practice, so depth‑of‑focus calculations are generally performed using only axial optical parameters.

The DoFo value derived from these formulas represents the strictest accuracy boundary. For practical deployment, more relaxed thresholds may be applied as needed.

1.3 Calculating Depth of Field

Three approaches for depth‑of‑field calculation are presented below.

Equation Using Optical Magnification

Many machine‑vision applications image targets at close working distances (e.g., 300 mm). For close‑range imaging, depth‑of‑field can be calculated using optical magnification. The previous subsection described the relationship between depth‑of‑field and longitudinal magnification (α). Since optical magnification usually refers to lateral magnification β (transverse magnification), the formulas below use β. The relation between longitudinal and lateral magnification is: \(\alpha=\beta^2\).

 640.webp (4).png

640.webp (5).png

Where: DoFo = Depth of Focus DoFi = Depth of Field f = Focal length Fe = Effective f‑number α = Longitudinal optical magnification β = Lateral (transverse) optical magnification δ = Circle of Confusion (CoC, Airy‑disk diameter)

Equations Based on Newton’s Lens Formula

The following formulas compute depth‑of‑field using object distance x measured from the front focal point. In Newton’s lens formula, distances are referenced to the front focal point. Points on the image side for ordinary imaging scenarios take negative values.

Front depth‑of‑field (\(DoF_N\)) yields positive values; rear depth‑of‑field (\(DoF_R\)) yields negative values. Total depth‑of‑field is reported as an absolute magnitude because it represents a physical distance.

Effective f‑numbers at the front and rear focus limits (\(F_{eN}\) and \(F_{eF}\)) are derived from the respective optical magnifications. For general‑purpose calculations, \(F_{eN}\) and \(F_{eF}\) may be approximated by \(F_e\) calculated from the object distance x.

640.webp (6).png

640.webp (7).png

Where: DoFo = Depth of Focus DoFi = Total Depth of Field (absolute value) \(DoF_N\) = Front depth‑of‑field (positive) \(DoF_R\) = Rear depth‑of‑field (negative) f = Focal length \(F_e\) = Effective f‑number at object distance x \(F_{eN}\) = Effective f‑number at near focus limit \(F_{eR}\) = Effective f‑number at far focus limit δ = Circle of Confusion (Airy‑disk diameter, CoC) x = Object distance measured from front focal point

Calculation of \(F_{eN}\) and \(F_{eF}\): Per Newton’s lens formula, lens extension \(x'\) is expressed as a function of object distance x.

640.webp (8).png 

Given \(F_{ex}\) (denoted \(F_e\) above, effective f‑number at distance x), the lens extensions at the near‑focus plane \(x_N'\) and far‑focus plane \(x_F'\) can be solved.

微信截图_20250122103651.png

From \(x_N'\) and \(x_F'\), lateral magnifications \(\beta_N\), \(\beta_F\) and corresponding effective f‑numbers \(F_{eN}\), \(F_{eF}\) are obtained.

 微信截图_20250122103727.png

Where: f = Focal length \(F_e\) = Effective f‑number \(F_{ex}\) = Effective f‑number at object distance x (= \(F_e\)) \(F_{eF}\) = Effective f‑number at near focus limit \(F_{eR}\) = Effective f‑number at far focus limit \(\beta_x\) = Lateral magnification at distance x \(\beta_F\) = Lateral magnification at near focus limit \(\beta_R\) = Lateral magnification at far focus limit δ = Circle of Confusion (Airy‑disk diameter, CoC) x = Object distance from front focal point \(x_F\) = Object distance of near‑focus plane (from front focal point) \(x_R\) = Object distance of far‑focus plane (from front focal point) \(x'\) = Lens extension \(x_F'\) = Lens extension for near‑focus plane \(x_R'\) = Lens extension for far‑focus plane

Equations Based on Gaussian Lens Formula

The Gaussian lens formula \(\frac{1}{-a}+\frac{1}{b}=\frac{1}{f}\) computes depth‑of‑field using object distance referenced to the principal points.

Object distances in the Gaussian system differ from Newton’s system by one focal‑length f. Depth‑of‑field results from Newton’s formulas can be converted simply by substituting x with \(a+f\). The coordinate origin for object distance a lies at the front principal point. Points on the image side for normal imaging are assigned negative values.

640.webp (11).png 

640.webp (12).png

 

 

Where: DoFo = Depth of Focus DoFi = Total Depth of Field (absolute value) \(DoF_N\) = Front depth‑of‑field (positive) \(DoF_R\) = Rear depth‑of‑field (negative) f = Focal length \(F_e\) = Effective f‑number δ = Circle of Confusion (Airy‑disk diameter, CoC) a = Object distance measured from front principal point


Related News

Professional Engineer

24-hour online serviceSubmit requirements and quickly customize solutions for you

+8613798538021