Friday, November 23, 2018

Focusing Update

 This is a revised post as DoF Bar had a minor program error that resulted in the DoFs being mis-reported. The link on the right has been updated.

If you have been following my recent posts you will be aware that I have been revisiting focusing; which has resulted in two ‘new’ tools.

First, the system-agnostic, ie it works for all cameras, ‘Rule of 10 (ROT)’, which I subsequently found to be an old idea from the 19th Century, but I believe I have given it a 21st Century life. The ROT allows you to calculate the hyperfocal distance, infinity focusing distance and focus stacking distances, all in your head.

Secondly, for EOS camera users only, the Magic Lantern based Depth of Field Bar (DoF Bar) that provides in-camera information to inform your infinity focusing, ie focusing between the hyperfocal distance and ‘infinity’, and focus bracketing.

Both these tools allow you to achieve optimum focus without reference to a single App or look-up table.

In this post, I’m updating the DoF Bar, to address a couple of weaknesses in the initial release and introduce additional functionality to help with bracketing from an infinity focused position, ie where your first image in a bracket sequence is focused at greater than the hyperfocal but less than four times the hyperfocal.

The DoF Bar script may be downloaded from the right hand link; which will always give you access to the latest version of DoF Bar.

For those that wish to read more about DoF Bar, here is the ‘User Guide’.

DOF Bar User Guide

DoF Bar is principally targeted at those that wish to obtain 'tack sharp' images from infinity to a near-field point of interest, eg landscape and cityscape photographers.

It can, however, also be useful to those who simply wish to know more about depth of field (DoF), especially when focusing beyond the hyperfocal, but short of 'infinity'.

It goes without saying that DoF Bar only works in a Canon EOS camera with Magic Lantern, in Live View and with lenses that report focus distance, focal length and aperture. DoF Bar checks for this and will only show itself if it is able to so do.

When bracketing, DoF Bar is best being used at the wider end, say 50mm or wider. However, it can be used with longer lenses, but be warned: focus bracketing can become tiresome at long focal lengths ;-)

For example, using the Rule of 10, a 100mm lens at F/10, using an infinity defocus blur of the FL in microns, will have a hyperfocal distance (H) of about 10m = FL/10. If we now bring this down from 100 microns to 10 microns, H corresponding moves to 100m, ie 10 x the H at 100 microns. 

Thus the number of focus brackets to cover from 10m, say, to infinity will be 5, using a 10 micron criterion as the overlap, ie H/2X = 100/(2*10).

Whereas, if we wished to cover from 1m to infinity, we would need 50 brackets (=100/(2*1)), that is an additional 45 to cover from 10m to 1m!!! This emphasises the non-linearity of focus around the hyperfocal.

As a further illustration of the above, let’s assume we relax things and use an ‘OK’ CoC of 30 microns with our 100m lens, ie H becomes one third of the H required to achieve a 10 micron CoC, ie 100m/3 = 33.3m. If we still wish to cover a focus range of 1m to infinity (at a CoC of 30 microns), the number of brackets is ‘reduced’ to about 17, ie  H/2X = 33.3/(2*1).

In other words, don’t try and focus bracket with long lenses ;-)

The current focus is always shown by ML on the ML bottom bar and DoF Bar assumes you have set metric units in ML. DoF Bar will switch off ML shown DoFs, as DoF Bar shows this info.

DoF Bar menu appears under the ML Focus menu. All DoF Bar menu states are remembered at camera close, so you don't have to keep entering your settings once you have arrived at your preferred configuration.

DoF Bar uses the ML set Circle of Confusion (CoC), ie the total (sic) blur criterion at the hyperfocal. The total_blur being calculated from SQRT(lens_defocus_blur^2 + diffraction_blur^2). With diffraction blur linearly varying with aperture alone, ie a lens at F/8 has twice the diffraction blur of one at F/4.

If ML diffraction aware is set to off, the ML (total) CoC is, obviously, only based on lens defocus blur. If ML diffraction aware is on, then the (lens defocus based) hyperfocal (H) is calculated by ML after diffraction is accounted for, ie lens_defocus_blur = SQRT(total_blur^2 - diffraction_blur^2).

If diffraction is too high, ie diffraction blur >= total blur, the near and far DoFs will collapse to the focus point.

So, be warned: according to your ML set CoC, apertures much beyond, say, F/16, on a full frame (less than this on a crop sensor camera), mean you begin to lose DoF because of diffraction.

Thus, because of diffraction, many photographers try and capture images around F/8 to F/11, as pushing things towards F/16, whilst resulting in larger DoF, may also introduce loss of image quality, eg achievable lp/mm, because of other factors related to lens design. For example see:

You can switch DoF Bar on and off, ie hide it in LV, via the script's menu.

NOTE: If DoF Bar 'disappears', for whatever reason, then simply carry out a half-shutter press to return DoF Bar to the LV screen.

The bar is segregated into three sub-bars, each with different scaling; in order to maximise the info presented in the bar.

The left hand (white) sub-bar covers distances from zero (an estimate of the camera's sensor plane) to a minimum focus distance that you set (this does not have to be the actual lens minimum). This min focus is only a visualisation aid and is user set in the script’s menu, and it can be zero, ie no white bar to the left of the green bar.

Hint: one way to use this user controlled feature is to move your lens to the macro end until the near depth of field doesn't change. You may consider this to be your minimum focus and set this in the menu ;-)

The middle (green) sub-bar covers distances from your set minimum focus to the (diffraction aware) ML calculated hyperfocal distance (H). Thus, if the minimum focus is set to zero, the green bar will go from zero (the camera) to H.

The right hand sub-bar (with three zones, white/black/white) covers distances from [H to 2H] [2H to 3H] [3H to 4H]. This right hand zone is used when ‘infinity focusing’, ie beyond the ML calculated H.

Note that infinity blurs go in proportion to multiples of H. Thus if focused at 3H, your infinity blur will be that at H (the defocus blur as set/calculated by ML) divided by 3, ie a third of that at H.

As defocus blurs less than twice the sensor pitch are rather meaningless, as you need at least two pixels to resolve a line pair; DoF Blur uses H/4 as a pragmatic limit; knowing that we are using DoF Bar with Canon EOS sensors.

In Pro mode (see below) DoF Bar will only allow you to set infinity blurs between H and 4H. For example, on a 5D3 twice the sensor pitch is about 13 microns. Whereas most will set the ML set (full frame) blur to, say, 30 microns, as this is recognised as an OK criterion to use for 'normal' viewing of an image. The smallest (DoF Bar allowed) infinity blur in this case is thus 30/4, which is about 8 microns, ie slightly less than, but close to, the 'sensible' (two pixel) sensor limit.

Of course, for web-based digital viewing, blurs can be more than for close scrutiny print viewing. But, unless you know the final presentation mode and what blur you wish to achieve, it is best to seek infinity blurs between 30 to, say, 12 on a full frame, and, say, 20 to, say, 8 on a crop sensor. DoF Bar, of course, helps you by indicating the sweet spot, ie green and not red blurs.

The left hand of the bar will always be the lesser of the current near DoF and the near DoF of the last image taken.

If DoF mode is selected, the right hand will be at H if both the current and last far DoFs are greater than H; or at the greatest of last far DoF and current far DoF. If Hyperfocal mode selected, the right hand will always be at H if the current far DoF is less than H. 

These two dynamic modes become useful as you focus towards the macro end, so the advice is have the Dynamic Bar switched on. Just try it ;-)

There are three 'info areas’ above the bar.

The left hand one always shows the current near DoF distance, as reported by ML.

The right hand info area shows the current (ML reported) far DoF distance, if the focus distance is less than H. If the focus is greater than the ML reported H, this info area shows the infinity blur (in microns) at the current focus distance, which will be between the ML calculated hyperfocal (defocus) blur (ie ML CoC if diffraction aware is off) and zero if focused at infinity. Blurs of zero, of course, only occur at the point of focus.

The third info area only appears in Pro mode and shows the current ML calculated defocus blur (diffraction aware sensitive) and the infinity blur that is currently set. The infinity blur is set by taking an image between H and 4H.

This infinity blur will then remain in force UNTIL the lens state changes, ie aperture or focal length, or you change the ML set total CoC. If you change lens state, you will need to take another image between H and 4*H to reset the infinity blur that is ‘in play’.

Or, put another way, if you wish to reset the infinity blur at anytime, all you need do is change lens state and (sic) take an image between H and 4H.

In its non-bracketing mode, the Focus Bar shows the three main focusing fiducial markers/semi-dots below the bar. Red is the focus point and the left and right white semi-dots show the near and far DoFs as calculated by ML.

As soon as you take your first image (anywhere), if bracketing mode is set to off (script’s menu), all you will see are these dots mirrored on top of the bar and these will remain mirrored as you refocus.

However, if you are in bracketing mode, once an image has been captured, the upper dots will now be (and remain) positioned at the last captured image’s points of interest, ie near-DoF, focus point and far DoF.

The current focus white, near or far, DoF semi-dots will turn blue when you have opened a 'focus gap' between your last image taken and the current focus.

You can now use these top and bottom dots to inform your focus bracketing, ie refocus until the lower far DoF is just greater that the upper near DoF (of the last image), ie white and not blue. Thus, in (non Pro) bracketing mode, you can focus bracket from anywhere at anytime; thus ensuring your current focus is focus bracketed to you last image.

If you are focusing at the Canon/ML indicated infinity, the lower dots will turn black as you are in a potential over focusing state, according to the lens you are using.

Note: the (non-Pro) DoF dots work in any focusing direction, from near to far as well as far to near.

Due to the coarseness of the Canon distance reporting, you may not always be able to position your focus to exactly where you want: so do the best you can.

If you are in Pro Mode (set in the script’s menu) two additional upper and lower (magenta) semi-dots will appear. The upper magenta semi-dot shows the near DoF of the first captured image you took between H and 4H after camera switch or after a lens state change. The infinity blur at that point is used to calculate the (infinity blur based) near DoF. The lower magenta semi-dot shows the (infinity blur based) far DoF at the current focus, once again using the infinity blur criterion established when you captured your image between H and 4H.

As you refocus, to achieve the perfect focus bracket, the lower magenta semi-dot will change from magenta to blue when you have opened up a focus gap.

Note: in Pro mode you should only focus bracket from far to near.

The infinity blur criterion will remain fixed until you change the focal length, aperture or the ML set hyperfocal by changing the CoC in ML; and take a new image between H and 4H.

Thus you can focus bracket at, say, image sequences less than H, BUT, in Pro mode you must have taken your first image (after camera switch on or after a lens state change) between H and less than 4H, and, of course, focus stack from far to near.

Having established your infinity blur, all you need to do on subsequent focus brackets is to ensure the two magenta dots (top = last near DoF and bottom = current far DoF based on infinity blur) are as close together as possible (that is as close as the Canon focus reporting allows); and both are magenta, ie if the lower turns blue you need to refocus or accept where you are if the current far (white) DoF marker is still white, meaning that you are between the ML set/calculated blur and the infinity blur DoFs.

If both magenta and white far DoFs of the current focus are blue, you will have a (real) focus gap that needs fixing.

You can keep using the magenta dots for images captured below H, but as soon as you do a lens state change and take an image between H and 4H, you will establish a new infinity blur criterion.

In Pro mode the middle Info area reminds you of the blurs that are being used to calculate the white and magenta DoF dots, ie ML set (at the OK focus quality level) and your currently active infinity blur (high quality)

If you change the focal length, the aperture or the ML set CoC; the DoF Bar will reset to its ‘camera on’ state, eg the upper dots will disappear, until you take another image. Plus, in Pro mode, the infinity blur based info will be reset and you will need to take an image between H and 4H to establish a new (Pro mode) infinity blur.

Finally, you can use DoF Bar as an armchair visualization tool. For instance, to inform you how DoF changes as you adjust aperture, eg by looking at the changing DoFs until they are at their maximum and suit your needs.

Caveat emptor: remember that the equations that ML and DoF Bar use are good approximations away from the macro end, based on mathematically simplifying the lens. In other words, don't use DoF Bar with a macro lens!

Finally, here is a screen capture showing the full richness of DoF Bar.

As usual I welcome feedback on this post, especially related to making DoF Bar even better.


  1. Hi Garry,
    found you through a friend of yours when i recently purchased a canon eos m from him named Bob.
    I was wondering if you could give me some advice on some queries i have regarding the canon eos m.

    1. Unknown

      Sorry, rather late reply, I think I’ve only just seen this. Please email direct with any questions. I have three EoSMs, and two converted, ie IR and Full Spectrum.