Time to be with your loved ones

Time to be with loved ones

by sat

submit your photo


Hall of Fame
View past winners from this year

Please participate in Meta
and help us grow.

Take the 2-minute tour ×
Photography Stack Exchange is a question and answer site for professional, enthusiast and amateur photographers. It's 100% free, no registration required.

There are several questions here about the definition of depth of field, about focal length, and about subject distance. And of course there's the basic how does aperture affect my photographs. And plenty of how do I get super-shallow d.o.f questions. There's related questions like this one. But there's no be-all-end-all question asking:

What exactly determines depth of field in a photograph?

Is it just a property of the lens? Can lenses be designed to give more depth of field for the same aperture and focal length? Does it change with camera sensor size? Does it change with print size? How do those last two relate?

share|improve this question
    
See also this related question: How can I maximise that "blurry background, sharp subject" (bokeh) effect? –  mattdm May 12 '12 at 13:23
add comment

4 Answers

up vote 36 down vote accepted

Ok for a change I'm going to dispense with the formulas, photos of rulers and definitions of "magnification" and go with what you actually experience in practice. The major factors that actually matter to shooting are:

  • Aperture. Wide aperture lenses give you a shallower depth of field. This is probably the least controversial factor! This is important as some lenses have much larger apertures e.g. 18-55 f/3.5-5.6 vs. 50 f/1.8

  • Subject distance. This is a really important consideration. Depth of field gets drastically shallower when you start to get really close. This is important as at macro focussing distances DoF is a major problem. It also means you can get shallow DoF regardless of aperture if you get close enough, and that if you want deep DoF in low light compose to focus further away.

  • Focal length. This does affect depth of field, but only in certain ranges, when maintaining subject size. Wide lenses have very deep depth of field at most subject distances. Once you get past a certain point, DoF changes very little with focal length. This is important again because if you want to increase / decrease DoF you can use focal length to do this whilst still filling the frame with your subject.

  • Sensor size. This affects DoF when you maintain the same subject distance and field of view between sensor sizes. The bigger the sensor the shallower the depth of field. DSLRs have much bigger sensors than compacts, and so for the same FoV and f-ratio they have shallower DoF. This is important because by the same token cropping images increases DoF when maintaining the same final output size, as it's akin to using a smaller sensor.

share|improve this answer
1  
Can't you sum that all up in two factors: the aperture and the size of the subject on the sensor? –  Kristof Claes Mar 10 '11 at 7:29
2  
+1 for throwing out the numbers and making it practical -- I've always wondered how anybody can judge something to be in or out of focus to three decimal places with a straight face. –  user2719 Mar 10 '11 at 10:42
5  
@Kristof you can, but I find that winds up confusing people, instead I wanted to concentrate on how four common inputs can be used to manipulate DoF in normal shooting conditions. –  Matt Grum Mar 10 '11 at 11:05
    
Great answer, Matt: clear and practical. –  Mark Whitaker Aug 31 '11 at 23:02
    
@Kristof it can be summarized in a single concept: the hiperfocal distance. But it's far more intuitive to use the factors given by Matt –  pau.estalella Sep 1 '11 at 9:23
show 3 more comments

There are only two factors that actually affect DOF - aperture and magnification - yes switching distance, sensor size, focal length appear to have an effect but they are all just changes in the size of the image (the subject/part-you're-looking at) on the sensor - the magnification. Kristof Claes summarized it a few posts earlier.

See the Focal Guide book 'Lenses' as a reference if you don't believe it.

Every amateur magazine (and ezine now) loves to say 'switch to a wide angle lens for more depth of field'... but if you keep the subject the same size in the frame (by moving in closer) then the sharp bits have the same limits. Walking backwards with the lens you've got on will give more DOF too, but maybe you like the shot the way it is already set up?

What you will see are more gradual cut-offs in sharpness so that the background & foreground appear sharper (not sharp as if within the DOF!) hence the lovely out of focus backgrounds with long lenses and the nearly sharp ones with wide angles.

share|improve this answer
    
Hi Derek! Welcome to Stack Exchange and thanks for the answer. Is this the book you are referring to? –  mattdm Jul 3 '11 at 14:23
add comment

This is an excellent question, and one that has different answers depending on context. You mentioned several specific questions each of which might warrant their own answers. I'll try to address them more as a unified whole here.


Q. Is it just a property of the lens?
A. Simply put, no, although if you ignore CoC, one could (given the math) make the argument that it is. Depth of field is a "fuzzy" thing, and depends a lot on viewing context. By that, I mean it depends on how large the final image being viewed is in relation to the native resolution of the sensor; the visual acuity of the viewer; the aperture used when taking the shot; the distance to subject when taking the shot.

Q. Can lenses be designed to give more depth of field for the same aperture and focal length? A. Given the math, I would have to say no. I am not an optical engineer, so take what I say here with the necessary grain of salt. I tend to follow the math, though, which is pretty clear about depth of field.

Q. Does it change with camera sensor size?
A. Ultimately, it depends here. More important than the size of the sensor would be the minimum Circle of Confusion (CoC) of the imaging medium. Curiously, the Circle of Confusion of an imaging medium is not necessarily an intrinsic trait, as the minimum acceptable CoC is often determined by the maximum size you intend to print at. Digital sensors do have a fixed minimum size for CoC, as the size of a single sensel is as small as any single point of light can get (in a Bayer sensor, the size of a quartet of sensels is actually the smallest resolution.)

Q. Does it change with print size?
A. Given the answer to the previous question, possibly. Scaling an image above, or even below, its "native" print size can affect what value you use for the minimum acceptable CoC. Therefor, yes, the size(es) you intend to print at do play a role, however I would say the role is generally minor unless you print at very large sizes.


Mathematically, it is clear why DoF is not simply a function of the lens, and involves either the imaging medium or print size from a CoS perspective. To clearly specify the factors of DoF:

Depth of Field is a function of Focal Length, Effective Aperture, Distance to Subject and Minimum Circle of Confusion. Minimum Circle of Confusion is where things get fuzzy, as that can either be viewed as a function of the imaging medium, or a function of print size.

There are several mathematical formulas that can be used to calculate the depth of field. Sadly, there does not seem to be a single formula that accurately produces a depth of field at any distance to subject. Hyperfocal Distance, or the distance where you effectively get maximum DoF, can be calculated as so:

H = f2 / (N * c)

Where:

H = hyperfocal distance
f = focal length
N = f-number (relative aperture)
c = circle of confusion

The circle of confusion is a quirky value here, so we'll discuss that later. A useful average CoC for digital sensors can be assumed at 0.021mm. This formula gives you the hyperfocal distance, which isn't exactly telling you what your depth of field is, rather it tells you the subject distance you should focus at to get maximum depth of field. To calculate the actual Depth of Field, you need an additional calculation. The formula below will provide DoF for moderate to large subject distances, which more specifically means when the distance to subject is larger than the focal length (i.e. non-macro shots):

Dn = (H * s) / (H + s)
Df = (H * s) / (H - s) { for s < H

DOF = Df - Dn
DOF = (2 * H * s) / (H2 - s2) { for s < H

Where:

Dn = Near limit of DoF
Df = Far limit of DoF
H = Hyperfocal distance (previous formula)
s = Subject distance (distance at which the lens is focused, may not actually be "the subject")

When the subject distance is the hyperfocal distance:

Df = 'infinity' Dn = H / 2

When the subject distance is greater than the hyperfocal distance:

Df = infinite Dn = 'infinity'

The term 'infinity' here is not used in its classical sense, rather it is more of an optical engineering term meaning a focal point beyond the hyperfocal distance. The full formula for calculating DOF directly, without first calculating hyperfocal distance, as as follows (substitute for H):

DOF = 2Ncf2s2 / (f4 - N2c2s2)

If we ignore print size and film, for a given digital sensor with a specific pixel density, DoF is a function of focal length, relative aperture, and subject distance. From that, one could make the argument that DoF is purely a function of the lens, as "subject distance" refers to the distance at which the lens is focused, which would also be a function of the lens.

In the average case, one can assume that CoC is always the minimum achievable with a digital sensor, which these days rolls in at an average of 0.021mm, although a realistic range covering APS-C, APS-H, and Full Frame sensors covers anywhere from 0.015mm - 0.029mm. For most common print sizes, around 13x19" or lower, an acceptable CoC is about 0.05mm, or about twice the average for digital sensors. If you are the type who likes to print at very large sizes, CoC could be a factor (requiring less than 0.01mm), and your apparent DoF in a big enlargement will be smaller than you calculate mathematically.


The above formulas only apply when the distance s appreciably is larger than the focal length of the lens. As such, it breaks down for macro photography. When it comes to macro photography, it is much easier to express DoF in terms of focal length, relative aperture, and subject magnification (i.e. 1.0x):

DOF = 2Nc * (((m/P) + 1)/m2)

Where:

N = f-number (relative aperture)
c = Minimum CoC
m = magnification
P = pupil magnification

The formula is fairly simple, outside of the pupil magnification aspect. A true, properly built macro lens will have largely equivalent entrance and exit pupils (the size of the aperture as viewed through the front of the lens (entrance) and the size of the aperture as viewed from the back of the lens (exit)), although they may not be exactly identical. In such cases, one can assume a value of 1 for P, unless you have reasonable doubt.

Unlike DoF for moderate to large subject distances, with 1:1 (or better) macro photography, you are ALWAYS enlarging for print, even if you print at 2x3". At common print sizes such as 8x10, 13x19, etc., the factor of enlargement can be considerable. One should assume CoC is at the minimum resolvable for your imaging medium, which is still likely not small enough to compensate for apparent DoF shrink due to enlargement.


Complex mathematics aside, DoF can be intuitively visualized with a basic understanding of light, how optics bend light, and what effect the aperture has on light.

How does aperture affect depth of field? It ultimately boils down to the angles of the rays of light that actually reach the image plane. At a wider aperture, all rays, including those from the outer edge of the lens, reach the image plane. The diaphragm does not block any incoming rays of light, so the maximum angle of light that can reach the sensor is high (more oblique). This allows the maximum CoC to be large, and progression from a focused point of light to maximum CoC is rapid:

enter image description here

At a narrower aperture, the diaphragm DOES block some light from the periphery of the light cone, while light from the center is allowed through. The maximum angle of light rays reaching the sensor is low (less oblique). This causes the maximum CoC to be smaller, and progression from a focused point of light to maximum CoC is slower. (In an effort to keep the diagram as simple as possible, the effect of spherical aberration was ignored, so the diagram is not 100% accurate, but should still demonstrate the point):

enter image description here

Aperture changes the rate of CoC growth. Wider apertures increase the rate at which out of focus blur circles grow, therefor DoF is shallower. Narrower apertures reduce the rate at which out of focus blur circles grow, therefor DoF is deeper.


Proofs

As with everything, one should always prove the concept by actually running the math. Here are some intriguing results when running the formulas above with F# code in the F# Interactive command line utility (easy for anyone to download and double check):

(* The basic formula for depth of field *)
let dof (N:float) (f:float) (c:float) (s:float) = (2.0 * N * c * f**2. * s**2.)/(f**4. - N**2. * c**2. * s**2.);;

(* The distance to subject. 20 feet / 12 inches / 2.54 cm per in / 10 mm per cm *)
let distance = 20. / 12. / 2.54 / 10.;;

(* A decent average minimum CoC for modern digital sensors *)
let coc = 0.021;;

(* DoF formula that returns depth in feet rather than millimeters *)
let dof_feet (N:float) (f:float) (c:float) (s:float) =
  let dof_mm = dof N f c s
  let dof_f = dof_mm / 10. / 2.54 / 12.
  dof_f;;

dof_feet 1.4 50. coc distance
> val it : float = 2.882371793
dof_feet 2.8 100. coc distance
> val it : float = 1.435623728

The output of the above program is intriguing, as it indicates that depth of field is indeed directly influenced by focal length as an independent factor from relative aperture, assuming only focal length changes and everything else remains equal. The two DoF's converge at f/1.4 and f/5.6, as demonstrated by the above program:

 dof_feet 1.4 50. coc distance
 > val it : float = 2.882371793
 dof_feet 5.6 100. coc distance
 > val it : float = 2.882371793

Intriguing results, if a little non-intuitive. Another convergence occurs when the distances are adjusted, which provides a more intuitive correlation:

let d1 = 20. * 12. * 2.54 * 10.;;
let d2 = 40. * 12. * 2.54 * 10.;;

dof_feet 2.8 50. coc d1;;
> val it : float = 5.855489431
dof_feed 2.8 100. coc d2;;
> val it : float = 5.764743587
share|improve this answer
    
Apologies. I was trying to keep the concepts separate so I could keep the diagrams simpler, however they are indeed inexorably linked in real life. My attempts to exclude aperture from the focal length diagram seems to have had the opposite effect, so I've removed them. The real point I was trying to make was simply that DoF is ultimately determined by the divergence in the angle of light between in and out of focus point light sources, or the "rate of change in CoC". The faster the rate of change, the thinner the DoF. –  jrista Mar 10 '11 at 4:17
    
@jrista: I certainly agree with that. Although it does add some complexity, it might be worth mentioning why a change in focal length does not affect DoF (as things are usually measured). It took me a while to figure that out. –  Jerry Coffin Mar 10 '11 at 4:41
    
I've attempted to add a short/simple explanation of how focal length affects DoF at the end of the answer I posted. I'm not sure if it's really adequate though -- I'd welcome any comments... –  Jerry Coffin Mar 10 '11 at 5:03
2  
@jrista: I don't know -- the only thing I can think of is that some people automatically consider "math" and "art" total opposites, so addressing anything artistic via math bothers them. IMO, that's pretty sad though: there's a lot of math behind most art (e.g., music theory is also almost entirely mathematical). and for that matter, I'd say math itself should be considered an art. –  Jerry Coffin Mar 10 '11 at 16:55
1  
This is a really gret answer, and I appreciate the math and the diagrams. I switched the "accepted" answer over to the shorter "just the practicals" one so that newer photographers interested in the question see that first. –  mattdm Jul 3 '11 at 20:33
show 2 more comments

@Matt Grum's comment is quite good: you do have to be really careful to specify conditions, or you can end up with three people saying things that seem to conflict, but are really just talking about different conditions.

First, to define DoF meaningfully, you need to specify the amount of "blur" you're willing to accept as sufficiently sharp. Depth of field is basically just measuring when something that started as a point in the original will be blurred enough to become larger than whatever size you've picked out.

This typically changes with the size at which you print a picture -- bigger pictures are normally viewed from a greater distance, so more blur is acceptable. Most lens markings, etc., are defined based on a print around 8x10 being viewed at roughly arm's length distance (a couple of feet or so). The math for this works out fairly simple: start with an estimate of visual acuity, which will be measured as an angle. Then you just figure out what size that angle works out to at a specified distance.

Assuming we pick one number for that and stick to it, depth of field only depends on two factors: the aperture and the reproduction ratio. The larger the reproduction ratio (i.e., the larger an item appears on the sensor/film compared to its size in real life) the less depth of field you get. Likewise, the larger the aperture (larger diameter opening -- smaller f/stop number) the less depth of field you get.

All the other factors (sensor size and focal length being the two more obvious) only affect depth of field to the extent that they affect the reproduction ratio or the aperture.

For example, even a really fast (large aperture) lens that has a short focal length makes it fairly difficult to high reproduction ratio. For example, if you take a picture of a person with a 20mm f/2 lens, the lens has to practically touch them before you get a very large reproduction ratio. At the opposite extreme, longer lenses often appear to have less depth of field because they make it relatively easy to achieve a large reproduction ratio.

However, if you really do hold the reproduction ratio constant, the depth of field really is constant. For example, if you have a 20mm lens and a 200 mm lens and take a picture with each at (say) f/4, but take the picture with the 200 mm from 10 times as far away so the subject really is the same size, the two theoretically have the same depth of field. That happens so rarely, however, that it's mostly theoretical.

The same is true with sensor size: in theory, if the reproduction ratio is held constant, the sensor size is completely irrelevant. From a practical viewpoint, however sensor size matters for a very simple reason: regardless of the sensor size, we generally want the same framing. That means that as the sensor size increases, we nearly always use large reproduction ratios. For example, a typical head and shoulders shot of a person might cover a height of, say, 50 cm (I'll use metric, to match how sensor sizes are usually quoted). On an 8x10 view camera, that works out to about a 1:2 reproduction ratio, giving very little depth of field. On a full 35mm size sensor, the reproduction ratio works out to about 1:14, giving a lot more depth of field. On a compact camera with, say, an 6.6x8.8 mm sensor, it works out to about 1:57.

If we used the compact camera at the same 1:2 reproduction ratio as the 8x10, we'd get the same depth of field -- but instead of head and shoulders, we'd be taking a picture of part of one eyeball.

There is one more factor to consider though: with a shorter lens, objects in the background get smaller a lot "faster" than with a longer lens. For example, consider a person with a fence 20 feet behind them. If you take a picture from 5 feet away with a 50 mm lens, the fence is 5 times as far away as the person, so it looks comparatively small. If you use a 200 mm lens instead, you have to back away 20 feet for the person to be the same size -- but now the fence is only twice as far away instead of 5 times as far away, so it looks comparatively large, making the fence (and degree to which it's blurred) much more apparent in a picture.

Edit2: Since I (sort of) persuaded @jrista to remove his diagram relating focal length to depth of field, I should probably try to explain why there's not a relationship between focal length and depth of field -- at least when you look at things the way they're normally measured in photography.

Specifically, a photographic aperture (nowadays) is universally measured as a fraction of the focal length -- it's written like a fraction (f/number) because that's what it is.

For example, it's pretty well known that at f/1.4 you'll get less depth of field than at f/2.8. What may not immediately be so obvious is that (for example) a 50 mm f/1.4 lens and a 100 mm f/2.8 lens have the same effective diameter. It's the wider angle at which light rays enter the 50 mm lens that gives it less depth of field than the 100 mm lens, even though the two have exactly the same physical diameter.

On the other hand, if you change the focal length but maintain the same photographic aperture (f/stop), the depth of field also remains constant because as the focal length increases the diameter increases proportionally so the rays of light are getting focused on the film/sensor from the same angles.

It's probably also worth pointing out that this (I believe, anyway) why catadioptric lenses are noted for their lack of depth of field. In a normal lens, even when you're using a large aperture some of the light still enters through the central part of the lens, so a small percentage of the light is focused as if you were shooting at a smaller aperture. With a catadioptric lens, however, you have a central obstruction, which blocks light from entering toward the center, so all of the light enters from the outer parts of the lens. This means all of the light has to be focused at a relatively shallow angle, so as the image goes out of focus, essentially all of it goes out of focus together (or a much higher percentage anyway) instead of having at least a little that's still in focus.

As an aside, I think it's worth considering what an incredible stroke of brilliance it was to start measuring the diameters of lenses as a fraction of the focal length. In a single stroke of genius it makes two separate (and seemingly unrelated) issues: exposure and depth of field controllable and predictable. Trying to predict (much less control) exposure or depth of field (not to mention both) before that innovation must have been tremendously difficult by comparison...

share|improve this answer
    
While I do agree with you, from a real world perspective, that my last diagram required an f/0.7 aperture, the point of the second set of diagrams was to demonstrate how focal length affected DoF without factoring in a specific aperture (or, maintaining a constant absolute maximum aperture and only varying the focal length). I do agree it ended up confusing in the end, so I've removed those two diagrams. Hopefully the answer is clearer now. –  jrista Mar 10 '11 at 4:31
    
Well, now the math is starting to bite. I ran your numbers, 50/1.4 and 100/2.8. Given the formula for DOF from my answer, at a distance of 20 feet and a CoC of 0.021mm, the results are as so: 50mm @ f/1.4 = DOF 2.88 feet; 100mm @ f/2.8 = DOF 1.43 feet. The depths of field only converged with 100mm @ f/5.6, where both lenses had a DOF of 2.88 feet. I've updated my answer with some F# code that can be used with the F# Interactive command line tool from Microsoft, if you wish to double check my math. (In all honesty, I'm surprised myself that a 100mm lens required f/5.6 aperture.) –  jrista Mar 10 '11 at 5:31
    
@jrista: That doesn't surprise me at all. At the same distance, the 100 mm lens will have twice the reproduction ratio, so we expect less DoF. The same f/stop and same reproduction ratio will give the same DoF, so with both at f/2.8, we expect the same DoF when the 100mm is twice as far away. –  Jerry Coffin Mar 10 '11 at 5:38
    
@Jerry: All things being equal, I guess (based on your updated answer) that I would have expected a 50/1.4 and 100/2.8 to have the same DoF for a common CoC and Subject Distance. However, given the math, you not only need to halve the aperture at 100mm, but also double the distance, to achieve the same exact DoF. As such, your earlier explanation about focal length and aperture is...I guess not inaccurate, just lacking specificity. The statement is only true if we assume that another variable, distance, also changes. If CoC and distance are fixed, then your statement is inaccurate. –  jrista Mar 10 '11 at 6:08
    
@jrista: Hmm...I thought I'd emphasized reproduction ratio throughout the early part of my answer, but perhaps I should rewrite it a bit to make it even more prominent. –  Jerry Coffin Mar 10 '11 at 6:11
show 8 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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