Sunday, September 25, 2022

QDFS: now with more functionality

As readers of my blog know, my scripts are biased towards wide angle, deep focus and high dynamic range scenes. That is scenes that require complex image capture bracket sets that benefit from scripting.

Although I have several EOSMs, which run scripts under Magic Lantern, and an EOS R, which doesn't yet run ML, my current photography is directed towards the CHDK cameras I have, and in particular the M3 and EF-M lenses.

The latest release of Quasi Depth of Field Script (QDFS), which may be downloaded from the right, now includes several features that are directed at the landscape photographer. For instance, the script will:

  • Detect if you are using Canon's three image exposure bracketing and you can change Canon setting as the script is running (see below)
  • Allows you to capture an ETTR-based, two image ISO or Tv bracket at a defined Ev relative to the base exposure, to complement the Canon three bracket capability
  • If enabled, the CHDK console will now also display the current exposure's delta Ev, relative to a reference exposure
  • A reference exposure is established at start up and whenever the Canon shutter is pressed in ALT mode
  • Pressing the INFO button toggles through the Canon display settings you have set up (your choice), including showing the screen to change various Canon settings, like the AEB and showing the Canon histogram
  • Pressing MENU button hides the QDFS graphics, ie to create a clean screen as an aid to composing
  • If enabled (Get Mag = Dynamic in the script’s menu), you can recalibrate the DoF scale in realtime. This is best accomplished by setting the focus just short of, but close to, the hyperfocal and just when the Canon upper/lower distances change and pressing SET
  • Pressing the RIGHT button will ETTR the exposure, ie set exposure for the highlights, from where you can tweak the exposure further
  • Pressing the LEFT button will ETTL the exposure, ie set exposure for the shadows, from where you can tweak the exposure further
  • The script show additional information, such the delta exposure (Ev), relative to the reference exposure, thus allowing you to survey the scene by using the ETTR and ETTL buttons
  • Pressing the M-Fn button will capture the requested exposure brackets, after which you can use QDFS to set the next focus, if required.

The following screen captures illustrate the above.

In the above we see a typical script start up view. The focus has been set to the camera's minimum focus, in this case 150mm with the 11-22mm lens, We also see DoF scale shows us where the hyperfocal is (red line), and highlights fractions of the hyperfocal, ie H/2. H/4, ...H/32 and the minimum focus. We also see in the console area at the bottom that the total lens rotation count to (data) infinity is 613 and that we are at 0, ie minimum focus.. The display also shows the Canon reported focus, ie the lower and upper values that Canon is reporting at the current focus. As we are at minimum focus, we are well away from the hyperfocal, ie at H/14.1. Finally, as we haven't yet changed exposure, the delta Ev reading is 0Ev.

In this next screen grab we see focus has been moved to beyond the hyperfocal and that QDFS now displays the infinity defocus blur in microns, 11 microns in this case at about 1.3 x the hyperfocal, as opposed to the focus distance in mm. Although not shown here, toggling the INFO button will allow you to display the Canon histogram.

As we are overexposed, it is a simple matter to press the RIGHT button and let QDFS set an ETTR exposure for the highlights, as below:

Here we see that the exposure is 5Ev from the initial exposure and at this point we press the Canon shutter, to create a reference point:

In the above we see the delta Ev has been zeroed and that the current focus, and DoF, is shown above the QDFS central scale. This reference will remain in place as we refocus, thus allowing us to return to the last focus position, as shown below: 

In the above we see the DoF reporting is red, indicating our current focus position has a focus gap relative to the last image or, in this case, the last referenced focus. We also see that QDFS is reporting we are at 352mm from the sensor plane, whereas the Canon upper and lower reporting is 360 and 400mm. So who is right? Well neither. Canon is giving us a range, where as QDFS appears not to be inside the Canon range, although is very close. For non macro DoF setting we are good enough, remember we are using a thin lens model for a complex lens design that we don’t know; but if you wanted to recalibrate you could, by moving focus until the Canon value just changes and then press the SET button. You can also tell QDFS at what distance you wish use for calibration at start up. 

The final thing to show is that we can easily return to our referenced focus (yellow) and then press the LEFT button to set an ETTL exposure:

In the above we see the ETTL exposure is 5Ev away from the ETTR one. With this information we can decide how many exposure brackets we need for the scene, eg can we 'get away' with just two, the ETTR and the ETTL exposures, or do we need additional exposure brackets. 

I hope landscape photographers see the value/power of the script and in future posts I'll provide insight into the QDFS and LBS scripts with real information from the field.

As usual I welcome any feedback on this post or any of my posts.


Friday, August 26, 2022

QDFS: Now works with all EF-M lenses

I had a bit of a brainwave and realised I don't need to preregister lenses. Thus the latest version of QDFS, download from the right hand link, now works with all EF-M lenses: no lens registering required.

I personally find it best to put the 'Get Mag' menu to Dynamic, which means I can always fine tune the depth of field scale if required, eg near,but short of the hyperfocal.

When switched on or after, say, a focal length change, the script will carry out a lens calibration step, at a distance of a fraction of the hyperfocal, as defined in the menu. 

I recommend you always do an additional dynamic calibration yourself, at the start of each shooting session.

As usual I welcome any comments on this post or any of my posts.

Thursday, August 25, 2022

QDFS: a further refinement

After playing with the 'get magnification' option that QDFS now contains, I realised I could take the idea further and turn the feature into a more dynamic tool.

Thus the latest version of QDFS now has the following menu:

#lensmag = 0 "Get Mag" {Off On Dynamic}

If you select Off, QDFS uses the registered magnification(s) of the lens.

If you select ON and, at your focus reference, press SET, you will get on screen feedback on the magnification (make sure the console is switched on in the QDFS menu). This magnification can then be to used in the QDFS script, meaning that the Canon distance reporting, from the sensor, comes into alignment with QDFS distance reporting. Note, that with this option the magnification doesn't change until you change the value in the script.

The new, Dynamic, option gives you full control over QDFS in real time, such that you can dynamically decide to align QDFS and Canon at any distance, and the magnification that is needed will get used instantly, ie you will see the change.

This feature is of value when, say, you focus on a subject and wish to know the focus distances either side of the point of focus. Having dynamically set the magnification in the QDFS model, the distance feedback will be the 'best you can get'.

Anytime you use the feature, make sure you stop focusing just as the Canon lower (L) reporting in the console changes.

If you are doing deep focus stacking, I recommend you calibrate at or just short of the hyperfocal.

So, like a stopped watch, that is always right twice a day, QDFS focus distance reporting from the sensor and Canon's reporting from the sensor are always the same at two focus distances: the minimum focus distance and at the calibration distance. In between QDFS uses a thin lens model to estimate the focus distances from the sensor: noting that lens extension is not modeled ;-)

As usual I welcome and feedback on this post or any of my posts.

Wednesday, August 24, 2022

Addendum to Fine Tuning QDFS

A quick post to say I've added in a menu option that helps you find the magnification value you need to bring Canon and QDFS reporting into alignment at your reference distance, ie around the hyperfocal.

Simply enable this in the QDFS menu and focus at the required distance, ie near/at the hyperfocal. 

To ensure you are correctly set, slowly move focus until the Canon lower reported distance (in the console) just changes.

Press SET.

You will then see the magnification to use in the lens registration function.

Repeat the above at the two focal length extremes if you have a zoom.

Once you have the magnifications you need, switch off the magnification option and adjust the script.

The QDFS download on the right has the tweak for the 11-22mm lens.

Tuesday, August 23, 2022

Fine Tuning QDFS

In this short post I'll say a few words on how to 'fine tune' the Canon M3 depth of field scale script, so that the Canon and QDFS reporting of focus distance, from the sensor, is better matched.

To be clear, we're not seeking perfection, afterall the QDFS is 'just' a simple thin lens model of an optically complex lens.

The 'trick' to fine tuning is to simply adjust the minimum focus magnitude, at the two extremes if the lens is a zoom, untill the Canon reporting and QDFS reporting come into closer alignment at a reference distance.

You can only achieve this after downloading the latest version of QDFS, as this now contains the option to display the number of brackets to the hyperfocal, as before; or an estimate of the focus distance from the sensor (lens extension is ignored in this model as it is small relative to the focus distances we are interested in):

As we can see, the focus option under Display has been selected, thus whenever focus is less than the hyperfocal, QDFS will display the focus distance in mm: noting this is an estimate of the distance from the sensor, using the QDFS model, ie not the Canon reporting, which is shown in the bottom console window.

With the above setup, the screen will look something like this at start up:

Here we see that QDFS is reporting (top right) that we are positioned at 150mm from the sensor, which Canon reporting is confirming in the console. Note that Canon lower (L) and upper (U) reporting reflects the granuality of the Canon data. That is Canon is telling us we are focused somewhere between the L and U values (reported in cm, but converted to mm in QDFS). If you focus towards infinity, say, these will change when the new lower value equals the old upper value.

Note: it seems strange that Canon tracks the lens rotation in very fine steps, eg on the 11-22mm lens the resolution is over 600 steps. But the distance reporting resolution is much lower than this.

To fine tune all we need to do is set the lens to each zoom extreme in turn (assuming it is a zoom) and position the focus at a reasonable distance, ie around, say, H/3. Then adjust the focus until the Canon lower distance just changes, eg (note the screen below shows the tuned state at 11mm, ie with the tweaked magnification):

In the above we see that the QDFS focus distance is stated as 631mm and the Canon lower value (which just changed) is 630mm. To achieve that, at the 11mm focal length, I needed to adjust the magnification to 0.17. Repeating the exercise at 22mm resulted in a magnification tweak to 0.32:

if lens_name() == "EF-M11-22mm f/4-5.6 IS STM" then -- calculate lens thickness from manufacturer's data
        f1 = 11
        f2 = 22
        m1 =,100) -- adjust the magnitudes as required, ie to fine tune Canon and QDFS focus distance reporting
        m2 =,100)
        return true

If you have an 11-22mm lens, the above is an irrelevance, as the tuned model is built into QDFS. However, if you wish to refine things or add a new lens, the above explans how to tweak the measured or manufacturer’s magnification to achieve a better (but not perfect) alignment between the Canon and QDFS focus distance reporting. It may appear a messy process, but you only need do it once.

Finally, here's a short video showing the focus reporting in action. Note that focus reporting is only shown up to the hyperfocal (red line). Beyond the hyperfocal QDFS reports an estimate of the infinity defocus blur, in microns (as before); which is a more useful piece of data for setting the infinity focus:

As usual I welcome any fedback on this post or any of my posts.

Saturday, August 20, 2022

QDFS: The best focus script for a Canon M3...probably ;-)

I'm pleased to announce that my Quasi Depth of Field Scale (QDFS) script is now fully operational, but is restricted to run on the Canon M3 only. The script can be download from the right.

QDFS was written as a focus and exposure bracketing tool for manual deep focus photogrpahy. It is not a macro focus bracketing tool.

QDFS now has exposure bracketing integrated into its workflow. Exposure bracketing can be achieved in the following ways:

  • With the Canon three exposure based AEB; note if set, the Canon AEB will override the CHDK exposure settings
  • With a QDFS zero-noise bracketing, ie an additional exposure for the shadows, from an ETTR base exposure: with a Tv or ISO value. Typically, a 4Ev value issued, but any value from 1 to 6 Ev can be used 
  • Wind bracketing, where the exposure remains the same, but ISO and/or aperture or shutter speed are adjusted. Wind bracketing can be achieved if you are in AV, Tv or P mode.

The QDFS UI has been tweaked and is now based on a 'dark theme'.

QDFS requires the lens to be registered in the script, eg:

if lens_name() == "EF-M11-22mm f/4-5.6 IS STM" then -- calculate lens thickness from manufacturer's data
        f1 = 11
        f2 = 22
        m1 =,100)
        m2 =,10)
        return true
    elseif lens_name() == "EF-M28mm f/3.5 MACRO IS STM" then
        f1 = 28
        f2 = 28
        m1 =,1)
        m2 =,1)
        return true
    elseif lens_name() == "EF-M55-200mm f/4.5-6.3 IS STM" then
        return false

Here we see that the 11-22mm zoom lens has its focal length extremes registered, and the magnification at those extremes. In the above the magnification at 22mm is 0.3 and 0.13 at 11mm. Magnification can be easily measured or taken from the manufacrururer's datasheet.

Prime lenses are registered in a similar fashion.

The menu now looks like this:

Here we see you can: set the CoC, ie the defocus blur for focus bracketing, 15 microns in this case; select the zero-noise exposure bracketing logic, ie Tv or ISO; the bracket offset, ie 1 to 5 Ev, or with Canon selected, you can bracket using the Canon three AEB functionality; select a delay in seconds, 3s is shown above; and select if you wish to see the console or not, which shows a single line of additional information.

Once running, you can cycle through the various Canon screens by pressing the INFO button, where, for instance, you can change the Canon AEB values. Pressing the MENU button will switch the depth of field bar off, ie during composing.

With CHDK switched on and the QDFS script selected, QDFS is run by pressing the  Canon shutter, when you will see the following screen:

Here we see QDFS telling us it is calibrating, ie working out the lens throw from the minimum focus distance to the 'extended infinity', ie with many lenses you can focus beyond the 'optical infinity'.

Once running the QDFS UI looks like this (note the screen HDMI captures aren’t fully representative of what you see on the M3 screen or EVF):

Here we see that the console option has been switched on, showing the lens count, the Canon lower and upper focus reporting (from the sensor plane) and the focus distance from the front principlal, in terms of the hyperfocal distance.

As mentioned above the lens counter linearly maps to the lens focus ring rotation. In the above we see that the maximum lens rotation occurs at 613 counts, and that we are currently focused at 0, ie we are at the minimum focus distance. The depth of field bar is only showing the far depth of field, ie the near depth of field is less than the minimum focus distance.

We also see on the right a 'data window' that changes according to where we are focused. If we are focused less than H/3, as above, QDFS will provide you an estimate of the number of focus brackets required to cover from the current focus to the hyperfocal.

In the next image we see how the data window changes when we are focused beyond the hyperfocal, ie when we are infinity focusing. Now we see an estimate of the defocus blur at infinity, in this case about 3 microns. We also see in the console area, that QDFS is reporing we are focused at 4x the hyperfocal.

We also see that we are focused at 521 of the 613 potential counts. If we now continue 'focusing', ie rotating the lens, we will soon go 'beyond infinity', which in this case means we have gone beyond the data, ie the Canon reported distances are no longer changing. The UI will now look like this:

The data window now expands and shows additional information: what CoC has been set in microns; the minimum focus distance (mm) from the front principal; the hyperfocal distance from the front principal (mm); and the number of focus brackets required to cover from the minimum focus to the hyperfocal. In the above example the focus is at the maximum rotation of the lens, ie 613 counts.

As an aside, knowing the MFD reported by Canon, ie 150mm in this case, and the QDFS MFD, 95mm in this case, gives us an estimate of the position of the front principal from the sensor plane, ie 150-95 = 55mm.

When an image is taken, QDFS captures the focus position of the last bracket, ie the current bracket until you refocus, and shows you are at the same focus position by turning the depth of field (lower) bar yellow:

If we move focus, the depth of field bar will change colour to indicate if there is a focus gap or not:

To illustrate the  value of QDFS, here is a handheld test image, although there was a bit of wind, that I took at f/8. I set bracketing to ISO +4Ev, focused on the nearest flowers of interest and focus stacked at two locations using QDFS.

I hope the above has been clear and that the lucky owners of a Canon M3, running CHDK, see the value of the QDFS script.

As usual I welcome any feedback on this post or any of my posts.

Friday, August 5, 2022

Quasi Depth of Field Scale in Action

FURTHER UPDATE: QDFS now works ‘perfectly’, but is restricted to the M3. See subsequent posts.

UPDATE:  although the QDFS script works, unfortunately I recommend you not use it for now. The reason is related to how some of the calls interact with the Canon side. The problem has been recognised by the CHDK developers and I’m hopeful a fix will be implemented soon.

In the last post I introduced the Quasi Depth of Field Scale (QDFS) script (latest version on the right) that I wrote to aid manual focus bracketing. The script has been written mainly to cover focus bracketing for wide angle lenses, and has been tested on the EF-M 11-22mm.

The reason for the WA warning is that, once you go move away from the WA zone, the number of focus brackets you need to take gets large for deep focus scenes. In such cases it is better to use an automatic approach, for example my Landscape Bracketing Script.

In this post I’m demonstrating QDFS’s functionality in three short videos.

This first video shows QDFS starting up and how the in-bar information is handled:

If you are focused short of the hyperfocal, then QDFS shows (on the right) an estimate of the number of focus brackets to get from your current focus position to the hyperfocal; where you can add in an infinity bracket.

If you are focused beyond the hyperfocal and short of infinity, QDFS shows (on the left) an estimate of the infinity blur in microns.

If you are focused at infinity, QDFS shows four pieces of information: the circle of confusion in microns; the minimum focus distance (MFD) in mm (from the front principal);  the hyperfocal distance in mm (from the front principal); and the total number of brackets required from the MFD to the hyperfocal.

BTW because QDFS shows the Canon reported distances in the console area, if switched on, we now have an estimate of where the front principal is located, relative to the sensor. Namely, at the MFD reported by Canon, minus the MFD reported by QDFS. In the video above, the MFD, relative to the front principal is reported as 93mm. In the above, knowing the Canon reported MFD, relative to the sensor, is 150mm, means an estimate of the front principal, relative to the sensor, is 150-93 = 57mm. A better estimate than using the thin lens position; in this case, at F(1+m), ie 11(1+0.3) = 14.3mm.

In this next video we see how QDFS handles changes in focal length and aperture. Focal length changes result in a recalibration, whereas changes in aperture are handled dynamically in real-time:

Finally, in the last video we see focus bracketing taking place in QDFS:

Finally, pressing the INFO button will toggle the depth of field scale on and off, ie to support composing.

Bottom line: if you are lucky enough to have a Canon M3 (M10 or M100) that is running CHDK, you may wish to give my QDFS script a try out.

As usual I welcome any feedback on this post or any of my posts.