Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know or calculate depth of field of a photo from EXIF tags?

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!

like image 891
Andy Li Avatar asked Sep 18 '09 10:09

Andy Li


People also ask

How do I calculate depth of field?

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.

How do you capture depth of field in photography?

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.

What is aperture value in EXIF?

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.

How do I get depth of field on my DSLR?

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.


2 Answers

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.

like image 184
Phil Harvey Avatar answered Sep 27 '22 23:09

Phil Harvey


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.

like image 32
Colin Pickard Avatar answered Sep 27 '22 23:09

Colin Pickard