Friday, May 5, 2017

Landscape Focusing Helper Script

In the last article I introduced the idea that focusing at the HFD is not the ideal strategy for landscape photographers, eg you will only achieve acceptable focus at infinity.

An alternative strategy is to focus at infinity and stop the lens down to the smallest detail you wish to see in the near field, ie foreground. For example, if I wished to resolve details down to 1mm, say, and I was using a 12mm lens, I would set the aperture to F/12 to achieve the 1mm goal, ie 12/12.

Also in the last post we discussed diffraction and optical blur. Diffraction blur impacts the whole scene, ie it is independent of focus point or focal length and only dependent on aperture. One handy rule to remember is that, at optical frequencies, ie it is different at IR frequencies, the diffraction blur, in microns, is approximately 4*N/3, where N is the aperture number, eg 8 or 16. Thus, at, say, F/16, the diffraction blur is about 21 microns.

The optical blur is zero only at one point, ie the plane of focus. Either side the blur increases, but not symmetrically (see the last post). For a given optical (acceptable) blur condition at infinity, say, 30 microns, we can calculate the focus point to achieve this, ie the hyperfocal distance. Also, even if we move the focus to infinity we only lose a small amount of depth of field in the foreground, ie the near field DoF, if focused at the HFD, is the HFD/2. At infinity focus the near (acceptable) DoF moves to the HFD, ie we only lose HFD/2 in focus.

To help Canon (sorry Nikon friends) Landscape photographers I have up issued my HFD script to provide Live View feedback on the blur diameters (in microns) at infinity. The on-screen numbers are (see screen shot below):

  • Diffraction blur (microns) at Infinity (also the same throughout the scene)
  • Optical blur (microns) at infinity (which approaches 0 at infinity focus)
  • Total blur (microns) at Infinity (which is the combination of the diffraction and optical blurs, taken in quadrature)

In the above screen shot (24mm at F/12) we see that the ML DoF info says we are at or beyond the HFD, as the far DoF is infinity. The near (acceptable) DoF is at 1.04m. We can also see that the diffraction blur is about 18 microns and that the optical blur at infinity is 21 microns, giving a total blur of 27 microns, ie less than the HFD criterion of 29 microns that was set, illustrating we are focused slightly beyond the HFD and towards infinity.

Knowing what we do about focus, HFD and infinity, all we need to do is to move the focus a little towards infinity until the optical blur is, say, just (sic) 1, which represents the farthest point away from infinity that gives the advantages of focusing at infinity.

This second screen shot shows that we have now optimised the focus, such that we achieve the benefits of optically being at infinity, although we are focusing well short of it, and protect the near depth of field, ie we have only reduced this from 1.04m to 1.95. The total blur at infinity reducing to 18 microns, ie from the 29 microns at the HFD.

Note that an optical blur lower than a certain criterion is meaningless, as one can not resolve things smaller than, say, two times the sensor pitch. Thus you should know your sensor blur limit. On my 5D3 the pitch is about 6.3 microns, so a sensible minimum total blur is twice this, say 13 microns.

Note the script 'rounds up' blurs and only shows integer values. 

Now we have access to the blur data in a dynamic sense, ie it varies as we vary aperture, focal length and focus point, we now have an additional focus tool, to augment the Magic Lantern Depth of Field data that is displayed dynamically in LV.

Using this new feature is easy. First load the script: note the script has help info so please read this first. The blur data is displayed as a default, but can be switched off in the script’s menu. You can also reverse the “On”,”Off” in the menu to default to Off.

The script is live (until switched off) and the lens move functionality is accessible via the selected buttons (which the user can change in the script, to account for different cameras). The default buttons are the MENU and the SET. Pressing MENU twice, ie in succession, gives you access to the normal MENU functionality.

Pressing MENU followed by SET moves the script into interactive mode and you will see an info box in the top right of the ML top info bar. You toggle through the options using the SET button and select a given choice by pressing the MENU button, which leaves interactive mode. On leaving interactive mode, if a lens move has been requested, then it will occur. The options being:

  • EXIT: leave interactive mode and do nothing
  • SET: moves to the HFD with the current aperture
  • OPT: moves to the HFD after adjusting the aperture to achieve the maximum DoF at the HFD (hint - use ML diffraction aware for optimum results)
  • WIDE: moves to the HFD after adjusting the aperture to achieve the lens's widest possible setting
  • +2: moves to the HFD after adjusting the aperture to the lens's 'sweet spot', assumed 2 stops from the widest' (but you can adjust this in the script if you wish)I
  • INF: moves to 'infinity' - assumed to be a distance of 655m (irrespective of the lens FL)
A typical (ML-based) work flow would look like this (assuming you are on a tripod):
  • Set a suitable exposure to use LV and compose the scene;
  • Press MENU followed by SET to access interactive mode and keep pressing SET until your option is reached, let’s assume it is the +2 option, ie 2 stops down from the widest aperture;
  • Press MENU, following which the aperture will be changed (if required) and the lens will move to the HFD (this can be confirmed by looking at the ML DoF feedback on the LV;
  • You can now look at the on-screen blur data and tune the focus, as at the HFD the infinity blur is only just acceptable;
  • Simply focus away from the HFD, ie towards infinity, until your reach your required infinity blur criterion, either optically or total blur;
  • Check that the near DoF, as reported by ML, is OK, and if not, tweak the focus to achieve an acceptable near field and infinity conditions;
  • Now you are composed and focused, set the shutter/ISO as required and/or use ML-ETTR.

The script can be accessed from the script list on the right, ie Auto HFD2 or at

As usual, I welcome feedback on this post and please don’t hesitate to suggest improvements to the script.


  1. So what CoC setting should i put on my 5D mark 3 ? 0.13 instead of 0.29?

    1. This is not a B&W question :-)

      It is said a 20/20 eye can resolve 5 lp/mm. The Canon 5D III is 22.3 megapixels, ie 5760×3840 over 36mm x 24mm. That is a sensor pitch of about 6.3 microns.

      A line pair (lp) is a black line and a white line, ie 2x6.3, which rounded up is about 13 microns on the sensor (sic).

      It is usual to talk about a 'normal' print size and viewing distance, ie a 8"x10" print views at 10".

      A 10” print is 245 mm. The longest side of the sensor is 36mm. 245/36 = a 6.8 ratio.

      Back to the 10” print and our normal eye sight at a ‘normal’ viewing distance of 10”, ie 5 lp/mm or a ‘CoC’ of 1mm/5 = 200 microns.

      On the sensor, using simple ratios, this is equivalent to 200/6.8 = 29.4 microns, ie the normal CoC that most websites quote for a FF camera, ie 29 or 30 microns.

      But, this ignores other effects, such as diffraction. It is reasonable to look at blur in quadrature, ie root square. Thus sensor blur (above) and diffraction blur (say 4*N/3 in microns) need to be root squared together.

      But, ignoring all the maths, and there is more [;-)], simply remember that, without any post processing to attempt to ‘remove’ blur, which will introduce artefacts, normal eye sight looking at a 10” print at 10” needs a total (sic) blur of around 30 microns. But this total blur accounts for all the blurs, eg including diffraction.

      As we saw above, it is not sensible to consider total blurs below the sensor limit (ie about 13 microns on a 5D3).

      Thus we end up with the following guidance:
      1.For normal use, eg not viewing a 10” print closer than, say, 10”, or, say, a 20” print closer that 20”, a total CoC or blur of about 30 is OK. This will also be OK for on-screen viewing as well.
      2.For on-screen viewing alone (or bill boards), you can relax the total blur criterion, ie giving you more depth of field: here your monitor is controlling the limits: note that an HD monitor is 1280 × 720 and (warning) an 8K monitor is 7680 × 4320! In other words, a 5D3 image on an 8K screen will not fill the screen at 1to1!
      3.For competition or close up scrutiny, where the viewer may be ‘zooming in’ with their feet, you need to think about more exacting total blur criterion than 30 microns, say, down to 13-15 microns on a 5D3 (note this changes as you change crop of your sensor). As things are linear here, a total blur of say, 15 microns, equates to 10 lp/mm, ie double the ‘normal’ 5 lp/mm.

      But be warned, unless using Magic Lantern (which handles the blurs, eg diffraction) and my script, which also handles diffraction blur, you need to ensure your DoF App is handling diffraction. I recommend TotalDoF App: