1
\$\begingroup\$

I just hope to learn the relationship between depth of field (DOF) with the distance on my mobile phone.

  • When I capture one cup with the distance about 20 cm from my phone, what 's the DoF?
  • When I capture one person with the distance about 100 cm from my phone, what 's the DoF?
  • When I capture one car with the distance about 200 cm from my phone, what 's the DoF?

From the paper Generalized autofocus, the equation is given

$$\begin{align} D_\text{near} &= \frac{sf^2}{f^2+Nc(s-f)} \\ D_\text{far} &= \frac{sf^2}{f^2-Nc(s-f)} \end{align}$$

with:

  • \$s\$: the distance from the camera to the object
  • \$f\$: focal length
  • \$N\$: lens f-number
  • \$c\$: minimum acceptable size for the circle of confusion

In my view, \$s\$ should be the focal plane in the equation. Mobile phones can perform autofocus to focus on a selected object. For one mobile phone, if \$f\$ is changed, \$s\$ varies immediately.

From the equation, I can't calculate DoF for different distances from the camera to the object.

\$\endgroup\$
8
  • 6
    \$\begingroup\$ Possible duplicate of Is there a formula to calculate DOF? \$\endgroup\$
    – 10 Replies
    Commented May 31, 2017 at 13:23
  • 2
    \$\begingroup\$ Auto focus should not really affect it. Phones are just like normal cameras but smaller \$\endgroup\$
    – 10 Replies
    Commented May 31, 2017 at 13:23
  • \$\begingroup\$ @10Replies Why does auto focus not affect DOF? In the formula, s and f always vary simultaneously. \$\endgroup\$ Commented May 31, 2017 at 14:51
  • 3
    \$\begingroup\$ f is a property of the lens, not the focus distance. For the same phone, f is constant. (Except for focus breathing, but that's a small effect and the numbers are generally not available unless you measure it yourself.) \$\endgroup\$ Commented May 31, 2017 at 15:06
  • 1
    \$\begingroup\$ See also How can a lens with a single focal length focus on more than one plane? \$\endgroup\$
    – mattdm
    Commented May 31, 2017 at 16:09

1 Answer 1

3
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ @j-g-faustus Thanks. In the formula, f is lens focal length. At first f is considered to be the distance of image plane by me. Can you provide more information about CoC? I hope to know how applications is related to CoC? \$\endgroup\$ Commented Jun 1, 2017 at 2:45
  • 1
    \$\begingroup\$ @JoggingSong Traditional CoC values are made for print, and phone pictures are rarely printed, so a CoC based on display resolution or sensor pixel size may be more relevant. The smallest meaningful CoC would be 2-3x the size of a sensor pixel, that's the smallest detail the sensor can capture. If you downscale the picture by say 3x in each direction to fit on the screen, a CoC of 6-9x the sensor pixel would probably be fine. Get the idea? See also the Wikipedia link in the answer. \$\endgroup\$ Commented Jun 1, 2017 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.