5

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!

4 Answers 4

6

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.

6
  • You say "D = focus distance in mm", what is focus distance? You mean the subject distance (which is not in EXIF, right?)?
    – Andy Li
    Sep 22, 2009 at 15:22
  • 1
    D = the distance at which the lens is focused. Some maker notes report this is "Focus Distance". You can also use the EXIF "Subject Distance" tag assuming that the camera was focused on the subject. But note that this tag is in metres, and must be multiplied by 1000 to get D for use in this formula. - Phil Sep 22, 2009 at 15:36
  • I see. What about "Focus Distance Lower" and "Focus Distance Upper" in EXIF? Are they already the depth of field values?
    – Andy Li
    Sep 23, 2009 at 6:53
  • No. In fact, the FocusDistanceUpper/Lower values are fairly useless because they are so inaccurate. Sep 23, 2009 at 11:52
  • 1
    I can see how this could be confusing. For my EOS 300D, the only possible values for these tags are: 0.26, 0.27, 0.35, 0.46, 0.59, 0.77, 1, 1.19, 1.42, 1.72, 2.22, 3.14, 5.46, 81.91 and -0.01 (the last value representing infinity I think). As you can see, there is not much useful resolution beyond 2 metres or so. For example (and ignoring the accuracy of these values for now), if I had my lens focused at 4 metres then the lower/upper values would be 3.14/5.46 (the low/high values closest to the actual focus distance), regardless of the aperture I used. I hope this makes a bit of sense. Sep 23, 2009 at 15:24
2

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.

4
  • 1
    The camera can know this. With Canon this information is used with E-TTL 2 flash metering, for example. But the lens has to support this as well, which should be true for most recent Canon EF lenses, third-party ones usually don't or they claim they do and only yield zeroes. Some of my photos have "Focus Distance Lower" and "Focus Distance Upper" fields (at least exiftool reports them).
    – Joey
    Sep 18, 2009 at 11:14
  • Ah, interesting. So it would definitely be possible for some camera/lens combinations. Sep 18, 2009 at 11:25
  • 1
    I guess this is the reason why DOF is not in the EXIF data in the first place -- not too many cameras and lenses will have photometry technology that determines subject distance
    – Jon Limjap
    Sep 18, 2009 at 11:38
  • So, can I say that when "Focus Distance Lower" and "Focus Distance Upper" appear in the EXIF data, they are the depth of field of the photo? Say, for flickr.com/photos/lauws/3864286429/meta the focusing rocks are in the range of 1.54 - 1.82 (and the unit is metre, right?)?
    – Andy Li
    Sep 18, 2009 at 13:56
1

This web page http://www.dofmaster.com/dofjs.html has a straightforward explanation of what is involved in depth of field calculations:

1

I came across the above formulae while looking for dof calculations and found these.

Just a couple of points:

  1. The values of t need to be checked in the program. If t = 1, then the focal distances are D/2 and infinity in which case D is actually the hyperfocal distance (hfd). This is easily proved and gives the hfd as (f**2)/(coc*Fnumber) approximately.

  2. If t is greater than 1 your answers will be negative and this is a meaningless result

Your Answer

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

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