This thread is superseded by https://www.magiclantern.fm/forum/index.php?topic=25286.msg230159#msg230159***DOWNLOAD SCRIPT FROM HERE ***
https://gist.github.com/pigeonhill/72dcef944db7bf1b11307dedeb2dc2f0I’m starting 2020 with a new version of my focus bracketing helper script, called Depth of Field Info (DOFI). This version has had a UI overhaul and now integrates well into the overall ML UI.
The script provides the user with three key pieces of focus information:
- The optical blur (in microns) at infinity
- The diffraction blur through the scene
- The total blur at infinity, which is the optical and diffraction taken in quadrature
Plus an estimate of the number of focus brackets required to go from the current position to infinity and whether the current image overlaps with the last image taken:
- Yellow means the current image is at the same focus as the last one taken
- Green means a positive overlap
- Red means a negative overlap, ie a focus gap
- White means that an image hasn’t been taken yet, or that the focus length or aperture has changed
The script will only run with a lens that reports focus length, focus position and aperture. DOFI resets if aperture or focal length are changed.
All the above info is shown in ML’s top info bar, ie in the right hand corner of the screen. DOFI is positioned under ML’s Focus bar and can be switched off.
At start up the screen will look like this:

In this screen capture we see we are shooting at 24mm and at an aperture of f/8. I set the ML CoC (blur) to 30 microns, which defines the overlap blur to DOFI, and switched on diffraction aware, although using DOFI we do not need the ML DoF distances, as we will use DOFI to inform our focusing.
In the above we see we are focused at 91cm. We also see (top right) the DOFI information, ie #2:82/10/82, which tells us that we will need two focus brackets to cover from this position to infinity, and that the optical blur, at infinity, at this location, is 82 microns. Finally DOFI tells us that the diffraction blur is 10 microns and that the total blur at infinity is 92 microns, ie sqrt(82*82 + 10*10).
As an example of DOFI's use, lets assume we wish to focus stack from the macro end to infinity. At the macro end we would see the following:

Here we see that DOFI is saying that we will need four focus brackets, so let's get going and take our first image:

The only thing that changed was the DOFI field turned yellow, indicating that the current focus is the same as the last image captured. Thus if we refocus we can always come back to the last focus position by ensuring that the DOFI area is yellow.
As we refocus towards (or away from) infinity DOFI will turn green or red according to whether we have a focus gap. So all you need to do is refocus until you see red, then backoff slightly to green.
The following gif is illustrative:

Here we see I took the final image when the defocus blur at infinity was 9 microns, giving a total blur at infinity of 14 microns. As a point of reference, remember that the defocus blur at infinity, if you focus at the hyperfocal, is simply the circle of confusion, which needs to then be convolved with the diffraction. Thus, using DOFI, you can decide infinity blur quality, ie based on defocus or total blur.
I wrote DOFI for those that wish to control focus and want to have the flexibility to focus stack at any time, ie landscape photographers on a tripod.
As usual I welcome feedback, including ideas to improve DOFI.