Friday, July 14, 2017

Focusing by Colour

Hopefully the title of this post is intriguing enough that even a few random surfers may have dropped in. So to make things self contained, here is a recap of where we are:
  • Magic Lantern is a fantastic piece of (software) technology, let down by the (Canon) hardware and users :-) 
  • For photographers we have ML Auto ETTR, Auto (RAW) Bracketing and Dual-ISO to help us control/optimise dynamic range, ie we can record the photons we need; 
  • For focus we now have my Focus Bar (FOCUS on the right), but it does have a couple of weaknesses. First, because the feedback is via the LCD, you may suffer from external light pollution, ie solar glare making the screen difficult/impossible to read. Second, not every photographer has perfect eyesight, ie reading small text! 
  • When focusing for landscapes or any image capture where you need full depth of field cover from a near field object to infinity, up until now, we have had three basic strategies we could use: 
    • Use the hyperfocal distance (HFD) approach and live with the fact that at infinity the focus will only just be acceptable; 
    • Use the Harold Merklinger approach of focusing at infinity - 
    • Try to focus stack as best we can by guessing the various focus points into the scene.
Of course, Canon ML users have my Focus Bar which allows you to use/adopt all three approaches in a fully controlled way, including perfect focus bracketing.

This post is all about the one weakness that ML can’t help us address, namely: the Canon hardware we use, ie the LCD screen, and our own eyesight shortfalls!

Let’s take the LCD screen first. One way to address the weakness here is to hope your camera has an articulating screen, and that you can angle it such that the screen is not occluded by sun glare. Another approach, and the one I use with my 5D3, is to shield the LCD. For example I use the Varavon Multifinder on my 5D3, but sadly this is not made any more.

As for eyesight problems. Well I can’t really say much here. Yes, ML may help a little, ie try and use bigger fonts for screen feedback, however, assuming sun glare is still there, and recognising that font size is not ‘infinity’ variable in ML, this approach won’t help that much.

We need another approach: which is what I am releasing in the latest version of FOCUS (download from the right). That is focusing by colour. Or for my American friends, who haven’t been corrupted by the French, because their founding fathers left English shores before the French language influenced my Mother Tongue, we will look at focusing by color :-)

The purpose of this approach is to ensure we can use the focus bar without needing to look at any distances or blur diameters, ie no text. All we will do is respond to colour cues on the screen, that should be readable in bright sunlight and with ‘old eyesight’, like mine!

First, let’s remind ourselves what the basic focus bar looks like. All the images in this post were taken from my EOSM (with the lens cap on), ie an APS-C cropped sensor, where I used the ‘normal’ (minimal quality) total blur (CoC) criterion setting of 19 microns. I have also chosen to use an 11mm focal length lens at F/5.6.

This first screen capture shows a typical focus bar at start up, telling me I’m focused at 71cm (bottom bar), that the near DoF is positioned at 45cm, that the far DoF is positioned at 1.62cm. We also see a representation of the focus field, in between the DoFs, eg the grey scale and defocus blur representations at the 10% distance points. At the bottom of the screen we also see “0cm(17)0cm”. What’s going on here?

Because, by default FOCUS is in focus stacking mode, and we haven’t taken an image yet, there is no ‘last DoF’ info to show, hence the 0cm. The (17) is telling us that the defocus component of the total blur criterion, ie 19microns, is 17microns. That is SQRT(Total_Blur^2 - Diffraction_Blur^2). Remember that diffraction blur only varies with aperture and is considered constant through the scene. In this case, at F/5.6, diffraction is low.

OK, nothing new in the Focus Bar so far. So let's illustrate the focusing by colour approach by assume we wish to carry out a focus bracket/stack, from a near field point of interest that we have focused on, and that we wish to capture the sharpest image we can at infinity, ie better than a 'barely acceptable', HFD capture.

This first screen image shows our illustrative starting point, where we have focused at 93cm and our near and far DoFs are 53cm and 3.58m respectively.

Let’s take our first capture.

As we can see nothing has changed in the top focus bar, as we haven’t changed our focus. But what we do see is an updating of the near and far DoFs of the last captured image, ie at the bottom of the screen.

But let’s assume that the on-screen text is not readable, ie sun glare on the LCD or failing eyesight. Let’s now start focus stacking towards infinity using colours alone.

Here is the screen capture when we have refocused but not yet taken our second image.

As we can read all the information let’s review what’s just happened. All we have done is refocus to 1.08m, ie from our original 93cm point. As a result of this the near and far DoFs have changed to 58cm and 7.8m respectively. Note that the DoF info at the bottom continues to show the previous image’s DoFs, eg 53cm and 3.58cm, plus the reminder that the defocus blur we are using is 17microns, ie following from the impact of the F/5.6 diffraction component.

But the major change on the screen, and what should be clear in any lighting conditions and with any eyesight, is the magenta bar.

The magenta bar is showing the focus overlap relative to the last image. In this case, noting the 10% distance marks on the focus bar, ie between the two DoFs, we can see that the overlap in about 40% of the DoF of this image.

You will have to take my word for it, that this 40% is the only solution available to me on this occasion, because the Canon lens control is not refined enough to give me other options.

So let’s take our second image (ignore the bright spot anomaly).

Now we see the magenta bar has vanished and that all the DoF info has updated, ie the current DoFs in the focus bar are showing 58cm and 7.80m, and the last image’s DoFs (at the bottom) are also showing as 58cm and 7.80m, ie the current image.

Let’s carry on refocusing towards infinity.

In this case (and this will be image-scene-setting dependent) we see that as we have focused passed the HFD, but that the focus point is less than infinity, ie 1.27m, and thus we have entered the infinity-focusing mode of the focus bar. In this mode a new focusing aid kicks in, the vertical bar on the right. You can also see the hint of magenta on the left of the focus bar, but note you may not as at infinity the bar is representing a huge distance, ie infinity ;-)

This vertical bar shows the focus breakdown of the total blur (CoC) criterion in microns, ie as set in the ML menu, the defocus blur component, ie the green bar, and the diffraction blur component, ie the yellow bar.

It just so happens in this case, this focus position shows that we are around the HFD point, as the focus bar is showing a total (defocus and diffraction) blur of 19microns, our total criterion, and the vertical infinity focus feedback is only showing the defocus and diffraction breakdown, ie the green and yellow areas, ie these two, taken together in quadrature, equals 19 microns.

Note also that the near DoF is showing 42cm, which is less than the first image we took! What’s going on here?

This is a feature of the focus bar (that can be changed) that I personally have set as a default. Namely, when you are optimising for infinity focus, ie planning to take a single image, you can set the near DoF to be calculated based on the defocus blur at infinity or twice this.

The above screen capture is thus showing the near DoF using twice the defocus blur at infinity. This feature is useful when you wish to optimise/minimise blur at infinity, ie low blur numbers, but know you can tolerate larger, relative blurs in the foreground, albeit less than the total criterion. In focus stacking mode, the focus bar’s near depth of field, when you are at infinity, can be ignored.

Clearly, we haven’t reached the optimum infinity focus yet, ie we are at the HFD focus position. So let’s keep focusing towards infinity.

The next few images show the feedback, with the final image showing that we have reached a limit, ie the green area has turned red. This alert is telling you that the defocus blur has reached a limit of twice the sensor pitch. Sensibly, it is not worth trying to reduce blur below this limit, hence the (red) warning. But note we are still only focusing at 7.60m.

So lets keep focusing towards infinity, which results in this situation.

Now we see the entire focus bar turn red, indicating that we have completely over focused and are ‘beyond infinity’, ie there is no more focus-based information to be gained. We need to back off focus, and take our final (3rd focus) bracket. Which tells us that our final bracket is at 3.84m and that our total infinity blur is 9 microns, ie double the infinity focus quality of an HFD capture.

Pulling all the above together, what we have done is use only colour feedback from the focus bar, after first focusing on a near field point of interest, eg using auto focus, and created a three image focus bracket set, namely these captures:

As we can see we have a sound focus bracket set, covering focus from a near field DoF distance of 53cm, out to an optimised infinity capture with a total blur at infinity of 9 microns (the best you could hope for).

I hope this new feature in the focus bar helps those that, like me, either struggle with small lettering or simply can’t beat the sunshine!


  1. Hi Garry, could you give a simple step by step guide for me what regards FOCUS script usage in the field.Cause everything seems very complicated for me. I have downloaded your Focus script ,installed it on ML. I have canon 5D mark III What settings of COC i have to set in my camera? 19 microns 15 microns or microns 30 ? And how should i use focus bar for taking single image as sharp as possible from foreground to background? I really need just simple steps without complex explanations thank you in advance :)

    1. Not a easy or straight forward question. But let’s see if this helps:

      The image is only in focus at one distance, creating a thin plane of sharpness. At all other distances the image is ‘out of focus’, ie defocused;

      Our eyes (and brain) can only see/interpret detail down to a certain resolution: you will read about line pairs per millimeter;

      Below this, we see everything equally sharp. This defocus on the sensor is spoken about in terms of a blur called the ‘circle of confusion’;

      For a full frame (DSLR) camera an acceptable (sic) CoC is consider to be around 29 microns, say 30 microns;

      For a crop sensor it would be less by the crop, ie 1.6 most Canon EOSs;

      But this CoC is not considered the most exacting, thus it is typical to consider CoC (or blurs) half this, ie, say, 15 microns for a 5D3;

      The above ignores diffraction blur, which is only related to aperture. To account for both blurs we need to ‘add them’ together. But we need to add them in quadrature, the root mean square of both, thus total blur = sqrt(defocus*defocus + diffraction*diffraction);

      If we know the total blur, ie between 30 and 15 microns, say, then we can work out the acceptable defocus blur, eg at a total 30 blur of microns = sqrt(30*30 - diffraction*diffraction). This is what the focus bar works out at presents to you when you infinity focus the far depth of field;

      At the hyperfocal distance the blur at infinity is ‘just’ the acceptable blur, ie only just in focus;

      The focus bar allows you to access the blur info as you focus away from the HDF. Obviously if you focus at infinity then infinity (alone) will be in focus;

      The amount of defocus blur you can accept is up to you. For an on-screen image a total (sic) blur at infinity of, say, 30 is OK. But for a judged print, you should aim towards 15 microns (total);

      However, if the defocus blur goes below two sensors pixels, then you are not able to gain anymore, ie don't focus this far. On a 5D3, this is about 12 microns of defocus (sic) blur.

      I hope this helps a little?



    2. Thanks Garry ,but I'm afraid it doesn't help me a lot :(
      I just need simple answers what coc setting to use in ML 30 for web display and 15 for prints? I know its easy for you ,but believe me its not form most people reading your blog that is why there is no comments at all because you have to write what you know in simple understandable language. Simple examples with simple explanations are best teachers. Now i see no use of that script because i don't know how to use it.
      If i set coc 15 on my 5D3 and try to focus a scene to get max sharpness front to back what should i see on focus bar? left and right sides lets say 42cm to infinity 15 ? and all that colors top bar and side column with colors :) It just seems to complex people never will use that because it is realy hard to understand the whole approach here. But thanks anyway for trying to explain ,but i guess i'm too stupid to understand all that focus script workflow.

  2. Oh dear. I think you are getting confused with the CoC blur criterion, that remains fixed, and the dynamically created infinity blur, that varies as you focus between the HFD and infinity.

    I hope my latest post helps: