Landscape Focusing Helper Script

Started by garry23, May 05, 2017, 07:08:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

garry23

I've just up-issued the above script and you can read about it and access it here: http://photography.grayheron.net/2017/05/landscape-focusing-helper-script.html

Basically the script fully automates moving an AF lens to the HFD.

It then provides you infinity diffraction and optical blur information so you can fine tune your focus.

As usual I welcome any feedback and/or improvement ideas.

Cheers

Garry

garry23

Opps!

Had a silly mixed version error in the script.

All corrected now :-)

a1ex

The options for maximizing DOF look quite interesting; some variation along the same lines might be useful for subjects moving unpredictably within a fairly narrow range (e.g. set your focus distance at 1 or 2 meters, then run the script to maximize DOF at this distance).

About taking over the MENU button - it's indeed tricky, since each camera has its own set of buttons. I would have defined a submenu with all the options - but I guess the reason you did it that way was because you wanted to try more options and evaluate focus on all of them, for example.

You could make use of menu's ability to become "transparent" in LiveView, showing only the current option. It's not fully exposed*) to Lua, but you can enable this mode by pressing the LiveView button while in ML menu (of course, in LiveView).

*) Actually you can access this mode from Lua using the edit_mode field (set it to 2 = EM_MANY_VALUES_LV), but I have only tested it on numeric fields (on those settings where I wanted to have a live preview while adjusting).

garry23

@A1ex

Thanks for the useful feedback and thoughts.

I guess as a 'personal scripter', rather than a hard-core ML coder, I tend to script for myself and my equipment: but I'm keen to share so others may benifit from my work.

I also try and liberally comment my scripts and I hope this helps others adapt my work. For instance, others can easily change my button 1 and 2 in the script.

I think this approach, i.e. others easily tuning a script for their camera is one reason non-compiled Lua is a great tool.

This script showed me I need to learn more about the 'limitations' of ML Lua and how to sensibly change things as the camera state changes, eg going back and forth between Canon and ML GUI.

I have some other ideas and will be up issuing the script in the future.

As usual, I want to repeat my thanks to you and others for making Lua possible. Lua is a very accessible way to 'extend' ML to cover individual needs/likes.

Cheers

Garry

garry23

I had a brainwave and have updated the script: http://photography.grayheron.net/2017/05/quick-update-on-landscape-focusing.html or https://gist.github.com/pigeonhill/da46cf783d26e1469cb3c3b12144d46e

The script now shows the user the blurs at infinity (diffraction, optical and total) and, based on the total blur at infinity, estimates the near DoF that also meets this blur criterion.

By the way, as a humble scripter I had to solve a problem in that the usual Lua rounding function (which you can get on line) kept failing in places. So I wrote my own rounding function, albeit for 1 dp.

As usual, I welcome any/all feedback.

Cheers

Garry

BBA

@garry23

Thanks for sharing !
Always interested to see the improvements !

A1ex ideas are quite interesting too!
Was thinking of a variation where the user sets/indicates the positions/plans of sharp/blur focus needed (through AF) in the near field and far field : the script can then optimize the shots to be taken, display the curves ...or signal if some conditions are mutually exclusive.

Dumb question :
Stacking softwares choose the regions in each picture that contribute the most to a sharper final picture. The blur regions are the less blurred (at least it is what I think).
What about taking the blurred parts from a more/the most blurred picture or the most DoD ? (opposition sharp on blurred background) ?

garry23

@BBA

This script is a helper script for taking single images. 

My landscape Auto Bracketing Script will handle my focus bracketing needs. All I do is set an appropriate blur, i.e. the more exacting the blur criterion, the more brackets I need.

As you imply, there's lots you could do :-)

Cheers

Garry

BBA

Sorry ; off focus...
Should be moved elsewhere.

garry23

Just a short post to say I've refined my infinity and HFD landscape focusing helper script.

https://gist.github.com/pigeonhill/da46cf783d26e1469cb3c3b12144d46e

Read the info in the script, but essentially, to use the HFD auto positioning, use the two keys and toggle through the options.

The interesting bit is the Infinity focus helper, which gives you info on three blurs at infinity, i.e. diffraction, optical and total. All in microns.

You are also provided the near depth of field distance that satisfies the total blur at infinity.

The  optical blur will turn red at a blur of 0, indicating you are over focusing, i.e. AF lenses allow over focusing at infinity to account for glass temp and/or IR focusing needs. You want to back off red. The total blur turns red if the blur is less than the sensor limit, i.e. 2 x sensor pitch or size. Set this in the script to suit your camera, eg my 5D3 I set this at 13 microns, that you are not going to see improvement past this point.

Remember, for a FF sensor, a total blur of, say, 30 microns is OK for screens, well until we get 8k screens  ;). For more extacting print work, you should consider dividing this by 1.5 or 2. That is, say, aiming for an infinity blur of, say, 15 microns.

Finally, the script has been tested on a 5D3 and I suggested it is best suited for short lenses, eg 'widish'.

As usual I welcome any feedback.

Cheers

Garry

garry23

Another tweak  ;)

...and another post: http://photography.grayheron.net/2017/05/to-infinitybut-not-beyond.html

For the landscape photographers out there, I don't think you will better this focusing approach  :)

a1ex

Very nice!

I'm still tempted to plot these graphs on the camera screen, but so far, their formula is still a mystery to me. I have a feeling the formula might be already in your script (or at least parts of it).

Found a summary at the end of this document (Appendix C), but got stuck at this line:

B_f = inf           if A <= L

That means, a 50mm lens cannot focus closer than 50mm? Or, rather, the formula I'm looking at is an approximation only valid at large focus distances?

(I know, I could just go brute-force and find out the blur size from test images at various focus distances, and use that for cross-checking the formulas)

(I've also played with cblur - also found on your blog - and noticed their javascript code, but it doesn't look like that code has an open source license...)

garry23

@A1ex

Have at look at the end of this user manual: http://toothwalker.org/optics/vwdof/vwdof21.pdf

May help you with what you are trying to do.

Cheers

Garry

garry23

@A1ex

BTW you said:

QuoteThat means, a 50mm lens cannot focus closer than 50mm? Or, rather, the formula I'm looking at is an a

I don't understand as the typical minimum focus distance, say, for a 50mm lens is about 350mm, i.e. without extension tubes.

The equation to plot the near and far focus curves is very simple. That reference I gave you gives you all you need.

However, although fun to do, IMHO those curves won't provide much help in the field.

Cheers

Garry

a1ex

Thanks, found my mistake (confused mm with cm).

BBA

@garry23, @a1ex

Very interesting : I very much like  :).
I have tested the preceding version and was astonished by the sharpness.

Quote
(I've also played with cblur - also found on your blog - and noticed their javascript code, but it doesn't look like that code has an open source license...)
What can be copyrighted :
- not the calculations : optics, algebra...
- the interface : the webpage as a whole ?
- something special in the algorithm ?

Always been learning in video, trying to get sharpness for landscapes (from my (now) ugly tests in 8mm/Hi8 then DV/(skipped HDV)/Full HD).... :o :-[ :-\ :P


IMHO (my 2 cents):
- This is the « specialists » man-machine interface : I personally like it as it gives the « behind the scenes » view.
The end user, especially not specialist, would be interested by the sharpness of the end result needed and not how to get it : so, a little « companion script » could ask the good questions (what are your needs...what do you want to do with your photo (high quality print, ...) ) and initialize the good parameters where needed, in the most obvious cases (see the next point).

- I very much like the sharpness of the picture on the front page of Pierre Toscani's  website http://www.pierretoscani.com/index.html (there is a contrast between sharpness and blur that also makes the result). btw, lot of interesting stuff in there (thanks to M. Toscani).

- I would be interested to know where, in micro-units, the lens goes actually :  i.e. try to use the script in lua fix environment and print the lens.focus_pos in a debug file, each time with the offset to try to compare apples and apples (and avoiding mechanical backlash)) ...for later...

- wonder if it can be interesting to calculate things like the depth of/from defocus : by the way, depth of field is « acceptable defocus ». Would like to experiment with that : are there good papers on that, what are the algorithms to compute the DoD DfD (Panasonic's field); would it confirm the results on far landscapes (or, off topic, far objects like the moon). If the blur spot is tinier than a given sensor pixel, it may be different on the whole picture? How can we deal with the different object distances present on the same picture? Is it possible to segment the picture according to the sensivity of the local DoD with focal distance....histogram of DoD...max DoD variation/max contrast...

- was also interested in displaying the curve (a zoomed part and a global curve or tendency) on the screen because it is really meaningful : I only have one little tiny fraction of the skills of a1ex (don't know how many zeros)  ???

Bottom line : Thanks   :) !

garry23

@BBA

I'm not going to attempt to answer all your questions/thoughts  ;)

However, here are a few reflections.

I decided to keep the output of script in microns of blur as this is easy to understand, once you know your camera. Thus on a full frame a 30 micron total blur can be classed a normal quality goal, i.e. if you are viewing a 6x10 at 10in, say. View closer, you should seek out an infinity goal of, say, half this. There are various simple equations that link lp/mm to viewing distance and 'print' magnification. However, for the landscape case, it all comes down to seeking an infinity total blur between, say, 30 and 15.

As for lens_pos I still can't see how it helps. Especially, if you factor in the assumptions we make about symmetrical lens, pupil mag. For me, if I can, I'll seek out 15 microns at infinity and back off to, say, 30 if I have to, i.e. to achieve a near field objective. That is assume you are printing, as this generates a higher quality objective than, say, posting an image on line.

I will most probably add some other features in the near future, so your post has got me thinking  :)

Cheers

Garry