How do I keep both the background and foreground in the image in focus at the same time?

  • How do you have both the background and foreground in the image in focus at the same time?

    Last week I was attempting a shot where I had the back of a hat in focus and in the distance you could see a mountain. I wanted both in focus, but could either focus on the mountain or the hat. I ended up taking the in-focus shots of both and merging them in Photoshop. While that isn't difficult I would prefer to shoot the shot as accurate as possible. From what I have read aperture is important in the depth of field but what are the techniques for keeping both the background and foreground in focus?

    I am using a Nikon D5100 with a 18-55mm f/3.5-5.6 (standard kit lens) and a 55-200mm f/4.5-5.6.

    This question almost answers my question, but I am a bit confused. Can someone explain this a bit differently? Thanks!

    @Instantkamera - Thanks for those links, I missed them when searching. Those almost answer my question but I am a bit confused. See my edit to question.

    Small aperture - say around f/22. Smaller may work BUT diffraction plays an increasing part at smaller apertures. Point at which diffraction starts to offset effects of depth of increasing depth of field vary with lens and scene. Akram suggests standard focusing rule BUT try moving the centre point to and fro somewhat to suit your image. You can "cheat" with 1. a multiple image shot and careful post melding. 2. A panorama using a good stitching program where you use overlapping slices and move focus point somewhat per slice.

    Lynda, check out - choose your camera (the D5000 will be fine in your case), focal length and aperture, and it will tell you how big the depth of field (the area in focus) is. You will see that at 18mm and f16, everything from 2ft to infinity will be in focus. Change the aperture to f5.6 and that drops to just 10ft.

  • j-g-faustus

    j-g-faustus Correct answer

    9 years ago

    I think this is mostly answered, but I'll add some examples.

    When a lens is focused at a particular distance, the image will appear sharp from some distance in front of the focus point to some distance behind it. The range from "nearest sharp point" to "most distant sharp point" is called depth of field (DOF).

    Here's a Wikipedia example. The focus point is the "depth of field" text, and the DOF extends approximately from the line below to the line above:

    DOF example

    DOF depends on three factors. (That is, three factors you can easily change. DOF also depends on the size of the camera sensor, how large you want to print or display the picture, how closely you look and how critical you are, but I'll assume that these are constant.)

    The factors you can easily change are

    • Aperture: Smaller aperture gives more DOF.
      Example: (All examples for Nikon D5100 or other APS-C 1.5x crop camera.)
      55mm f/5.6, focus at 10 feet: DOF range from 9 to 11 feet (2 feet total)
      55mm f/22, focus at 10 feet: DOF range from 7 to 18 feet (11 feet total)

    • Distance: More distance from camera to focus point gives more DOF.
      55mm f/5.6, focus at 10 feet: DOF range 9 - 11 feet (2 feet total)
      55mm f/5.6, focus at 20 feet: DOF range 16 - 26 feet (10 feet total)

    • Focal length: Shorter focal length gives more DOF.
      55mm f/5.6, focus at 10 feet: DOF range 9 - 11 feet
      18mm f/5.6, focus at 10 feet: DOF range 5 feet to infinity

    So to maximize the depth of field, the basics are

    • Shortest possible focal length
    • Smallest possible aperture (although at very small apertures you run into diffraction blur instead)
    • If possible, increase distance between camera and foreground
    • Focus slightly behind the foreground subject, to exploit the fact that DOF extends some distance in front of the focus point.


    • 18mm f/22, focus at 2 feet: DOF range from 1 to 12 feet
    • 18mm f/22, focus at 10 feet: DOF range from 2 feet to infinity
    • 18mm f/22, focus at infinity (the mountains): DOF range from ~2.5 feet to infinity.

    So you could have everything from 2 feet to infinity in focus, by focusing at 10 feet.

    If you want to go advanced, you could improve DOF slightly by focusing at what's called the hyperfocal distance. (Although you would need a table or calculator to look it up.)

    Focusing at the hyperfocal distance gives the maximum possible depth of field, in this case that's

    • 18mm f/32, focus at 1.7 feet (hyperfocal distance): DOF range from 0.9 feet to infinity

    That's the best optics can give you. If you need more than that, you'll have to fake it by taking multiple shots and merging them.

    You can find these values from an online DOF calculator like the one ElendilTheTall linked to. Just select your camera (or another camera with the same size sensor, like D5000 in your case) and fill in focal length, f-stop and focus distance.

    Note that these DOF values are only approximate: The DOF range is calculated using a definition of "acceptable sharpness" - subjects at the edges of the DOF range will be slightly out of focus, but we might still call them "acceptably sharp" - and what you consider acceptable will probably differ from the standard definition.
    You will have to experiment to find your own limits, but a DOF calculator is a good starting point.

License under CC-BY-SA with attribution

Content dated before 7/24/2021 11:53 AM