How do I calculate the depth of field of cameras on mobile phones with auto focus?

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 20cm from my phone, what 's the DOF?

When I capture one person with the distance about 100cm from my phone, what 's the DOF?

When I capture one car with the distance about 200cm from my phone, what 's the DOF?

From the paper Generalized autofocus, the equation is given 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 one an 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. Any help are appreciated.

Edit: On the internet, there are a lot of resources on DoF of DSLR and DC. I hope to learn the property of DOF of cameras on mobile phones.

• Possible duplicate of Is there a formula to calculate DOF? – 10 Replies May 31 '17 at 13:23
• Auto focus should not really affect it. Phones are just like normal cameras but smaller – 10 Replies May 31 '17 at 13:23
• @10Replies Why does auto focus not affect DOF? In the formula, s and f always vary simultaneously. – Jogging Song May 31 '17 at 14:51
• 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.) – j-g-faustus May 31 '17 at 15:06
• – mattdm May 31 '17 at 16:09

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 um

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:

Dnear = s*f^2 / (f^2 + N*c*(s - f))
Dnear = 0.2*0.004^2 / (0.004^2 + 1.8*4e-6*(0.2-0.004)) = 0.18 m = 18 cm
Dfar = 22 cm

So at 0.2 m focus distancee, the DoF goes from 0.18 to 0.22 m.

While at 2 m focus distance, the DoF goes from 1 m to 20 m.

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 appromxiately the same as s, so you can simplify the formula a bit.

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.

• +1 great answer. I was creating a similar answer, but you covered the relevant issues (misunderstanding of focal length, CoC, etc.) concisely. – scottbb May 31 '17 at 19:48
• @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? – Jogging Song Jun 1 '17 at 2:45
• in photography f can mean many things - such as aperture value (as in f1.8/50mm lens). Go figure... :) Very nice answer thought, my respect to @j-g-faustus! – Jindra Lacko Jun 1 '17 at 10:38
• @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. – j-g-faustus Jun 1 '17 at 15:45

Informal formula depth of field:

P = point focused upon

Pd = distant point with acceptable sharpness

Pn = near point with acceptable sharpness

F = focal length (F^2 = F squared)

D = diameter of acceptable circle of confusion (advise using circle size F/1000)

f = f-number

Pn (near) P/1+PDf/F^2

Pd (distant) P/1-PDf/F^2

All distance values in millimeters then convert to feet or meters for use.

• Alan, this is a bad answer to the question. All you did was restate the OP's equations (factoring out ƒ² from numerator and denominator, and ignoring the -Ncƒ final term in the OP's denominator). Why change every symbol from what the OP's equations were (for instance, lowercase-f is f-number? In most contexts, people see "f" in photography and it refers to focal length). But at a more basic level, this does nothing to clarify the OP's basic misunderstanding of the concept of focal length (that for a fixed lens, it doesn't change when focusing at different distances). – scottbb May 31 '17 at 23:41