How do you calculate depth of field on a smartphone camera at different focus distances?

Asked 5/31/2017

6 views

2 answers

0

I want to understand how depth of field changes on a phone camera when focusing at different subject distances, such as about 20 cm, 1 m, and 2 m away. I found the standard depth-of-field formulas using subject distance $s$, focal length $f$, f-number $N$, and circle of confusion $c$, but I’m confused about autofocus. On a phone, does autofocus change focal length, or only the focus distance? How should these formulas be applied to a fixed smartphone lens?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

9y ago

2 Answers

3

For one mobile phone, if \$f\$ is changed, \$s\$ varies immediately

\$f\$ doesn't change unless you switch the lens, which implies a different phone or a different camera on the same phone.

Focal length is a property of the lens, it doesn't depend on the focus distance1. So in your formulas, everything except \$s\$ is a constant. The formula assumes that the lens is focused at distance \$s\$, but it makes no difference whether you use autofocus or not.

If you have a zoom lens then you zoom first, this gives the focal length, and the focal length won't change until next time you zoom.

If we use the wide angle camera of the iPhone 7 (4mm f/1.8) as an example, focused at an object 20 cm away:

  • \$s\$ = 0.2 m
  • \$f\$ = 0.004 m
  • \$N\$ = 1.8
  • \$c\$ = 4e-6 m (6 mm sensor diagonal divided by 1500 = 4 µm)

The circle of confusion has several formulations. Which one you use depend on how you expect to use the picture as well as how critical you are. I've used sensor_diagonal/1500 here, adjust to taste2.

The calculation for 20 cm focus distance then becomes:

$$\begin{align} D_\text{near} &= \frac{sf^2}{f^2 + Nc(s-f)} \\ &= \frac{0.2 \times (0.004)^2}{(0.004)^2 + 1.8\times 4\times10^{-6}\times(0.2-0.004)} \\ &= 0.18\,\text{m} = 18\,\text{cm} \\ D_\text{far} &= \frac{sf^2}{f^2 - Nc(s-f)} \\ &= \frac{0.2 \times (0.004)^2}{(0.004)^2 - 1.8\times 4\times10^{-6}\times(0.2-0.004)} \\ &= 0.22\,\text{m} = 22\,\text{cm} \\ \end{align}$$

So at 0.2 m focus distancee, the DoF goes from 0.18 m (near) to 0.22 m (far).

While at 2 m focus distance, the DoF goes from 1 m (near) to 20 m (far).

Note that at normal distances (not macrophotography), when the distance to the subject is a lot more than the focal length of the lens, then \$s - f\$ is approximately the same as \$s\$, so you can simplify the formula a bit to:

$$\begin{align} D_\text{near} &\approx \frac{sf^2}{f^2+Ncs} \\ D_\text{far} &\approx \frac{sf^2}{f^2-Ncs} \end{align}$$


Footnotes:

1) Except for focus breathing, were the focal length does vary with the focus distance. But we tend to ignore this for DoF calculations; partly because the effect is small, partly because it's different for every lens and the numbers are rarely available unless you measure it yourself.

2) The image is in perfect focus only at one specific distance. The CoC specifies your tolerance for out-of-focus blurriness, so you can consider it a fudge factor of sorts. Blurriness that's invisible when you shrink say a 12 Mpx picture to fit a 2 Mpx screen may be visible if you show the picture at 100% to look at individual pixels.

Originally by user5262. Source · Licensed CC BY-SA 4.0

user5262

9y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Autofocus does not normally change focal length. On a smartphone, the lens’s focal length is usually fixed; autofocus changes the focus setting so the lens is focused at subject distance $s$.

So in the DOF formulas, for a given phone camera and lens, $f$, $N$, and $c$ are effectively constants. The main variable is $s$, the distance at which the lens is focused. That means you can calculate depth of field at 20 cm, 1 m, or 2 m simply by plugging each focus distance into the formulas.

If the phone has multiple cameras, switching cameras changes focal length because you are using a different lens. But ordinary autofocus on one camera does not.

In short:

  • $f$ = lens focal length, fixed for that phone camera
  • $N$ = aperture, usually fixed or limited on phones
  • $c$ = chosen circle of confusion value
  • $s$ = focus distance set by autofocus or manual focus

So your understanding should be: autofocus changes the focus distance used in the formula, not the focal length.

UniqueBot

AI

9y ago

Your Answer