Friday, May 19, 2017

Update to EOSM Toggler

Now I have the focus bar up and running, I needed to tweak the EOSM Toggler to ensure script-2-script compatibility in the UI.

The EOSM Togger was written specifically for the EOSM, ie this version is not a generic Toggler.


You can download the updated Toggler on the right.

The EOSM Toggler and focus bar look like this:


In the above screen dump we see the focus bar and the Toggler in its interactive mode, showing that the ML state currently selected (ready to change to) is AutoETTR. 

If you select this state (read the script's intro), then the Toggler will change the  ML Menus you have selected for that state and exit interactive mode. 

In interactive mode, you can go backwards and forwards through your Toggler states and have as many as you like.

The EOSM Toggler also works without the focus bar.

As usual I welcome feedback.

Focus Bar for Magic Lantern

A simple post to say I've rationalised the focus bar script and it now runs in the background, and controllable from the ML FOCUS menu.

I have cleaned up the UI and it now blends into the overall ML UI.



The focus bar script (FOCUS) on the right has extensive info built in.

The overall functionality follows from previous versions, eg:
  • I decided to keep the visualization of the focus field to a linear representation. I personally get more out of it this way. 
  • In addition to 'seeing' the focus field, and the fp and dofs, you can decide if you wish to see the near and far distance info shown below the bar.
  • For landscape photography, once the far dof is greater than 'infinity' the focus_bar distance reporting switches to total blur units (optical and diffraction in quadrature) at infinity for the far; and the dof distance based on the total infinity blur for the near dof.
  • Blur reporting at infinity is green if above the sensor limit (2xsensor pixels) and red below (make sure you set the correct sensor info for your camera).
  • The multiplier allows you to see the focus field beyond the far dof.
  • A multiplier of -1 switches the focus bar into dof mode. Note in all modes the focus bar functions during Canon zoom. Hint: this may help portrait photographers or videographers looking to 'ensure' the focus field is 'right', ie use Canon zoom and focus on the eyes (say) and check the focus field, ie front vs back focus.
  • A multiplier of 0 switches the focus bar into fp mode, ie see the focus field from zero to the fp.
  • I think it 'best' to have ML diffraction aware on (diffraction impacted green dots showing dofs) and switch diffraction off in the focus bar. This way you can see the impact of diffraction in the focus field. The focus field is black at unity blur (optical or with diffraction if selected). Unity blur is defined as the calculated blur divided by the ML set blur (CoC).
Finally, as always, I welcome any feedback.

Monday, May 15, 2017

FOCUS Tutorial



With the first (full) release of my new FOcus COmpanion Script (FOCUS, downloadable on the right), I thought I would write a short tutorial on one of the use cases, namely landscape focusing.

Before doing so, it is worth highlighting the core functionality of FOCUS:

  • It runs within the Magic Lantern Lua environment;
  • It runs continuously, unless you switch it off;
  • By default it is enabled in DoF (depth of field) mode, which we will discuss below;
  • The other modes are interactive mode, which allows you to direct the lens to the hyperfocal distance point, with various aperture options (we will cover this in a later tutorial); and a mode that provides more infinity focus info.

Before discussing how to use FOCUS, it is worth a reminder as to why focusing is not as easy as one would think.

First, modern AF lenses are great at what they do: auto focus. However, when it comes to manual focus, these lenses can be a challenge, eg no hard stop at infinity (to cover glass temperature variations and IR focusing) and, more importantly, very poor correlation between the lens markings and focusing distance, especially when you approach infinity, which, on a wide angle lens, favoured by landscape photographers, is not that far into the field.

Luckily, most modern lenses, even if they are not auto focus, report focus distance, which Magic Lantern gives us on screen and access to in Lua: in addition to aperture and focal length etc. In other words we have all the properties we need to do some interesting stuff.

Another reason that lenses are not ‘easy’ to focus is that their response is not linear. To see this all you need to look at is the focus info on the lens. For example, an x degree rotation of the lens at the macro end is not the same as an x rotation towards the infinity end.

Finally, the depth of field of a lens, ie the zone that to our eyes appears ‘sharp’ is not a simple function through the scene. For instance this chart shows a 24mm lens at F/8 focused at the hyperfocal distance. The green curve show the effect of diffraction, while the blue curve is ‘just’ the optical response. Unity is where the blur is just at our selected acceptable limit, ie around 30 microns here.



Around the plane of focus the difference is clear to see.  In the far field the curves asymptotically approach our set limit, 30 microns in this case; whereas in the near field’, focus collapses rather quicker and towards infinity blur. 

The above curve illustrates a key property of (non-macro) lenses, ie the near and far field responses are radically different: in a true macro lens the near and far depths of field are very small and ‘symmetrical’ about the plane of focus.

So how does the above insight and access to FOCUS help us?

The ‘secret’ of getting the sharpest landscape images, ie from the near to infinity, is to not (sic) use the hyperfocal distance, as, by definition, at infinity the focus is only just acceptable. See my previous posts for more information on HFD vs infinity focusing.

FOCUS brings you a new way to do landscape focusing, through access to three pieces of information: the total blur at infinity, a visual feedback on the optical focus field, ie without diffraction, and the 'usual ML' information about the near and far depths of field with diffraction.

OK, I appreciate some of you may have stopped reading, so lets show the Live View screen when FOCUS is running in its DOF mode.



Here we see the focus bar from FOCUS and, because we are in DOF mode, the left and right hand edges of the focus bar show the near and far depth of field points, ie the green dots (note the distances (within rounding limits) are the same as ML is reporting at the bottom). 

The red dot is the plane of focus, clearly illustrating the bias towards the near field. The focus bar shows the blur as it varies from 0 (white), at the plane of focus, to the ML set total acceptable blur (black), or Circle of Confusion if you prefer.

Clearly the above, random, starting position is not much good for our landscape, so let’s focus towards infinity until we see ML reporting that the far DoF is at infinity. 

The following image shows that we are at now at the HFD, a distance on 71cm, as ML is reporting the far DoF at infinity: as is the focus bar, which is telling us that the total blur is in fact around 28 microns, ie we have (manually) slightly ‘over focused’.



The key thing to note is that throughout the focus field, the acceptable focus is virtually fixed, ie the same level of grey (note the focus bar only shows optical focus blur, ie not diffraction). In this case black equals 30 microns. A total blur of 30 microns would be OK for screen representation, but not for high quality printing, where you would like to see a total blur of, say, half this.

But remember, although we are at the hyperfocal distance, we are in fact only focusing at about 71cm! What if we carried on, say, to the lowest total blur that we can get at infinity. This image next shows that state.



We have now moved focus to 4.25m and the total blur is reported as 12 microns. This is practically the lowest we can achieve with a 5D3, ie below this we are ‘breaching’ the 2xsensor limit, as the 5D3 sensor pitch is about 6.3 microns. Also note the focus bar greyness has shifted towards white, indicating that the optical blur across the field is about as low as you can get it.

So what have we gained by focusing beyond the HFD?

Well we have achieved about double the ‘total focus quality’, ie 12 microns vs 30 microns; which equates to doubling the print (lp/mm) quality. But what have we lost?

In this case, with a 12mm focal length, the acceptable near depth of field has reduced from 34cm at the HFD, to 1.1m using the infinity blur focusing approach. 

Note: the left hand of the focus bar reports the total (optical & diffraction) near depth of field if the far depth of field is less than infinity, ie at the HFD. Once the far depth of field is greater than infinity, the left hand end of the focus bar reports the depth of field that meets the infinity total blur, ie which will be different to the ML reported near DoF (1.1mm vs 55cm in the above example, ie the ML DoFs use the ML set total blur criterion, eg 30 microns in this example.

Clearly it is up to you to decide whether the above is acceptable, eg near field depth of field. But note you have a lot of information to use, eg:

  • A total blur at infinity of 12 microns, as good as you can hope to get;
  • A near DoF, based on 12 microns, of 1.1m;
  • A near DoF, based on 30 microns, of 55cm.

So let’s sum up.

With the new FOCUS approach to focusing we have the advantage of visually ‘seeing’ the focus field, as well as gaining access to some critical information at infinity. These new pieces of information, together with the ML supplied info, represents a new and enhanced way to control focus in your images.

In future posts I will provide more ‘case studies’ related to FOCUS, as well as illustrating additional functionality.

I hope you find this new approach as useful as I have; and, as usual, I welcome any feedback.

Saturday, May 13, 2017

Introducing the 'The Focus Bar'

In previous posts I introduced a 'new', Magic Lantern based, approach to landscape focusing; based on the idea of monitoring the optical, diffraction and total blurs at infinity.

This approach is simplicity itself, as all one needs to do is monitor the blur (provided in microns) and stop focusing when your blur criterion is reached.

For example, for full frame landscape photographers a total blur of, say, 30 microns is OK for screen presentation. If, however, you are seeking the best quality for printing, then a total blur goal at infinity of, say, 15 microns may be a better goal. But note blurs are related to image size and viewing distance.

Once your blur-focus condition at infinity is met, the script provides info on the near field depth of field position, that also meets the total blur criterion. Thus you know you have achieved your focus criterion from the near distance to infinity.

In this post I'm introducing (in beta) a new feature: a focus bar (see image below):


This 5D3 screen dump shows the landscape focus helper, with the new focus bar.

This version 'only' provides a visual feedback on the optical blur through the scene: although I plan to add in diffraction, ie so you can visualize total blur, in a later release.

The focus bar provides you a visual impression of the blur through the field, the red dot being the point of focus. This is important information for those seeking high quality images, as, unlike diffraction, optical blur changes through the depth of field.

The left hand distance is set at the HFD/4: as this script is for landscape photographers, ie unlikely to be seeking focus below HFD/4.

The right hand distance is a user variable and adjusted by a multiplier (from the script's menu). The multiplier is based on sensor-limited 'infinity' (which the script calculates), ie the distance where the optical (sic) blur is the same as the sensor pitch, or the size of single sensor site. That is about 6.3 microns on my 5D3.

The colours provide info on the optical blur through the scene, based on a menu selected 'unity blur', eg 30 microns was used above. The colours provide the following info:
  • Black: an optical blur equal or greater than the unity blur x a multiplier (1-9)
  • Grey: the blur between Black (above) and a unity blur (white)
  • Green: a blur between the unity value, eg 30 microns above, and half this
  • Yellow: a blur of less than half the unity blur, eg less than, say, 15 microns
  • The red dot is the focus point and this varies from HFD/4 to the limit identified above. If focus goes beyond the set limit, the red dot will be shown outside the focus bar, providing another piece of info to be used.
The script is available from the download area (right), ie HFD3. Currently this is a beta release and I welcome feedback.

Wednesday, May 10, 2017

To Infinity…but not beyond!



Modern lens are technical marvels and simple to focus via their Auto Focus (AF) feature. However, this simplicity hides some complexes: take infinity focus.

On older manual lenses there tended to be a hard infinity, ie the lens stopped focusing at infinity. These lenses were usually ‘calibrated’ by the manufacturer; thus one could set infinity focus in the dark, ie rotate the lens focus ring until it stopped. They also tended to have rather impressive markings on the lens to find specific distances, eg the hyperfocal distance.

With a modern AF lens, scales are rather ‘difficult’ to read and infinity is rather confusing, as you can focus beyond infinity, ie you are in the dreaded lazy L zone.

The lens manufacturers say that the Lazy L is there mainly to account for temperature variations in the glass and when you need to focus at Infra-Red frequencies.

OK, this sounds rather nice, but for the majority of photographers, the lazy L zone is rather wasted, eg how do you know by how much to adjust the infinity at a given glass temperature.

Because of the ‘confusion’ over infinity and the lazy L, I’ve decided to add a working-infinity feature into my Landscape Focusing Helper Script (see HFD2 on the right).

For those interested in the ‘simple, ie arm-waving, science’, the logic goes like this:

  • The human eye can only resolve details down to a certain limit. For someone with ‘normal’ eye sight it is said that one can resolve 5 line pairs per millimetre (lp/mm) at about 250mm away (10 inches);
  • The camera’s sensor has thousands of pixels, eg on my 5D3 the pixel pitch is about 6.3 microns. Thus, on the sensor, a lp is about 13 microns, ie 2 x 6.3 microns, equivalent to about 80 lp/mm on the sensor;
  • It is reasonable to consider a ‘focus blur’ (some may prefer to call this a circle of confusion) on the sensor as having a minimum that relates to this sensor-blur limit, ie about 13 microns;
  • The total (system) blur that we record is an amalgam of many sub-blurs. Once again, simplifying  things we may reduce the sub-system blurs down to two main ones: the optical blur that the lens creates, and that varies over the depth of the scene, and the diffraction blur, that is flat across the scene;
  • For the optical blur, we will simplify things even more and assume the lens is symmetrical;
  • We now have a way of defining a working-infinity, which we will define as a focus distance that creates a specified optical blur on the sensor. From the above, we can sensibly say that this blur can not be less that one pixel on the sensor, so let’s use that as our blur criterion;
  • The focus distance at which a specified blur (on the sensor) gives a specific value at infinity can be estimated (sic) by:
  • Where fd is the focus distance, f the focal length, k is the blur criteria and N the aperture number. Of course, the above calculates the HFD if you use that blur criterion, eg 30 microns;
  • As an example, at a focal length of 12mm, an aperture of f/10 and a blur criterion of 6.3 microns (our sensor pitch or size), infinity comes out at about 2.3m! Bluntly, focusing beyond this distance will not provide any more 'infinity detail' or in-focusness or 'acceptable out of focusness'.

Pulling all this together, how would I use the landscape infinity focus helper script on my 5D3? That is using Magic Lantern and my script

Here’s how, ignoring all the other ‘stuff’ like exposure and composition:

  • First, decide on the blur criterion you wish to use at infinity, remembering that on a full frame 5D3, a total blur of, say, 30 microns is ‘OK’, ie good enough for an HD monitor presentation (but worry about that 8K monitor you will buy in the future), and ‘OK’ for looking at a 10x6 (in) image at arms length - about a 5 lp/mm result on the print. For gallery and/or competitions, consider a total blur criterion at infinity of half the above, say, 15 microns: ie taking a hit on the near field DoF distance;
  • Ensure the ML settings are OK, ie diffraction aware on and DoF visible in LV;
  • Switch to Live View (LV) and look at the script’s info box. Let’s assume we are using a 12mm lens at f/8;
  • Focus towards infinity until the total (system) blur is around 15 microns. To illustrate things, here is a screen dump from my 5D3:

  • At the bottom we see that ML is reporting that the lens is focused at about 1.51m, giving an ML reported DoF from 46cm to infinity (based on a set 29 microns total blur in ML);
  • The script is showing additional info, ie that the infinity is anything beyond about 2.7m (!!!), and that a total blur (RMS of diffraction (11) and optical (12)) is about 16 microns at infinity, giving a near DoF of 64cm. That is we have achieved enhanced focusing (15 micron total blur) from 64cm to infinity;
  • As we haven't yet reached the lazy L zone, let's keep focusing towards the lazy L infinity zone;
  • The first thing that occurs (above) is the total blur turns red, warning us that the total blur is now less than the sensor limit, ie about 13 microns on the 5D3. This means that it is not really 'worth' focusing any more towards infinity. Remember, the more you focus towards infinity, the more DoF you lose in the near field (note we are now at 1.1m). But let's keep going, as the lens allows us to keep moving towards the lazy L zone. The optical blur (the centre blur reported above) turns red (below), warning that we are now focusing at or beyond an optical blur of zero;
     
  •  Going beyond this means we are over focusing. Note that our near DoF is reporting 1.6m: and we still could go on!
Bottom line: If using my script, good practice is to ensure there are no red warnings. Once you decide on your infinity total blur, eg between 15 and 30 microns on a full frame camera, getting the optimum landscape 'infinity focus' is simplicity itself. There is no need to worry about 'where is infinity'.

A final word of warning: appreciate the 'limitations' of the script, ie it is suited for 'shortish' lenses, ie don't expect to use the script on your 70-200; use it on your wide angle lenses.

As usual, I welcome any feedback on this post and any ideas to make this approach to landscape focusing better.

Saturday, May 6, 2017

Quick Update on the Landscape Focusing Helper Script

Had a brainwave as we were driving down to Cornwall, so an early update to the Landscape Focusing Helper Script (download on the right (Auto HFD2) or at https://gist.github.com/pigeonhill/da46cf783d26e1469cb3c3b12144d46e).

This version provides the ultimate feedback.

In addition to the blurs at infinity (in microns), ie diffraction, optical and total (the quadrature combination of diffraction and optical blur), the latest version provides the near field depth of field position that meets the infinity blur criterion.

For instance, if the total infinity blur is, say, 16 microns, the script's info box will provide the near DoF distance from the camera that meets this blur criterion.

Enjoy!

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 https://gist.github.com/pigeonhill/da46cf783d26e1469cb3c3b12144d46e

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