I want to know the depth of field of a photo, preferably in cm or m.
I know that we can know the camera setting by reading the EXIF tags, but is there a tag directly telling us the depth of field? Or how can we calculate it from some EXIF tags?
Examples would be appreciated. Thanks!
We can approximate DoF using: DoF = u² × 2 × N × C / f² or by following these steps: Square u : 1,200 × 1,200 = 1,440,000. Multiply it by 2, N , and c : 1,440,000 × 2 × 4 × 0.029 = 334,080. Divide that by the square of the focal length: 334,080 / 50² = 133.632 mm ≈ 0.13 m.
The aperture is the setting that beginners typically use to control depth of field. The wider the aperture (smaller f-number f/1.4 to f/4), the shallower the depth of field. On the contrary, the smaller the aperture (large f-number: f/11 to f/22), the deeper the depth of field.
Aperture Value is given in "APEX" units ("Additive system of Photographic EXposure). Using APEX units, Exposure value = Aperture value + Shutterspeed value (Ev = Av + Tv). Av = 2 x log2 (f-number), so f/1 = 0, f/1.4 = 1, f/2 = 2, etc.
Depth of field is determined by aperture, lens focal length, and the distance to the subject: Aperture: Wider apertures (lower f-numbers) reduce depth of field, smaller apertures (higher f-numbers) increase depth of field.
Calculating depth of field:
t = A * (S/1440) * (D - F) / F^2
The near focus distance = D/(1+t)
The far focus distance = D/(1-t)
And the full depth of field is the difference between these.
The variables are:
A = lens aperture (F Number)
S = camera sensor or film plane diagonal size in mm
D = focus distance in mm
F = lens focal length in mm
Of course, the sharpness of focus is subjective, and is adjusted by changing the constant in the calculation of the circle of confusion (CoC). Here, I have used CoC = S/1440 which is a value that is commonly used.
I'm guessing here, so I'd appreciate if anyone else can confirm this:
I believe you cannot programatically determine the depth of field from the available EXIF data - you must know the f-stop, focal length, and this is crucial: the subject distance.
The fields FNumber
and Focal Length
will give you the first two. The third would not normally be possible to determine with the camera. You would need some mechanism for ranging - some extra equipment for the camera or some known values for triangulation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With