Author Topic: NEW: Auto Super Resolution Bracketing Script  (Read 919 times)

garry23

  • Hero Member
  • *****
  • Posts: 1047
NEW: Auto Super Resolution Bracketing Script
« on: December 20, 2016, 11:13:37 AM »
As many will know, although I'm not a C coder, I do like playing around with Lua scripting, and as a stills photographer I'm always looking for ways to exploit Lua. So far I've got auto bracketing working for exposure, focus, exposure & focus together, and LE simulation.

I'm pleased to say I think I've found another use for ML-Lua, ie auto bracketing for super resolution photography.

Rather that drone on here please read my latest post: http://photography.grayheron.net/2016/12/a-new-technique-for-super-resolution.html

Simply put, I'm exploiting a 'weakness' in all non-cine lenses, ie focus breathing or focal length shortening, to allow me to simulate sensor shifting (used in multi-image super resolution photography).

Once I have automatically collected the SR bracket set, I simply post process in Photoshop (warning: takes a long time).

As usual, I welcome any feedback from the ML community.

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 9456
  • 5D Mark Free
Re: NEW: Auto Super Resolution Bracketing Script
« Reply #1 on: December 20, 2016, 12:39:59 PM »
Just throwing in a related idea: with an IS lens, in photo mode LiveView, by triggering the half-shutter (even in software), the image will move a little (I've tested this a while ago with a 18-55 IS lens). Combined with full-res silent pics, it might be useful for super-resolution as well.

garry23

  • Hero Member
  • *****
  • Posts: 1047
Re: NEW: Auto Super Resolution Bracketing Script
« Reply #2 on: December 20, 2016, 01:07:18 PM »
A1ex

Yes I've noticed the IS 'jiggle' and wondered about that pixel level offset myself.

I haven't explored it yet, but, as you say, it's worth looking at.

Cheers

Garry

mothaibaphoto

  • Senior
  • ****
  • Posts: 304
  • pesky kid
Re: NEW: Auto Super Resolution Bracketing Script
« Reply #3 on: December 20, 2016, 02:07:59 PM »
Great idea. You need to get patent for it (before Canikon will do that).

garry23

  • Hero Member
  • *****
  • Posts: 1047
Re: NEW: Auto Super Resolution Bracketing Script
« Reply #4 on: December 20, 2016, 05:10:46 PM »
UPDATED: added sensor shift strategy

@A1ex

Did some experiments and there appears to be enough bracket to bracket variation, ie a pixel delta, for 'just' an IS jiggle to work.

But I've added in options for the user regarding sensor shift strategy.

Here is the 'refined' code:

Code: [Select]
--[[
This script simulates a super resolution stack for post processing...
by simulating sensor shifting by changing focus. Because of this, the script is 'limited' to taking...
sharp images between the HFD and infinity.
This script assumes you are on a tripod, ie not handholding as 'normal' in super resolution stacking (without a special sensor)
This version does NOT work with FRSP...at the moment :-)
Should be in LV
Canon review should be set to OFF
Usual caveat: script was written for my workflow and enjoyment, and 'only' tested on a 5D3

Version 0.2

*******************************************************************************************************
*   *
* If you reference this script, please consider acknowledging me: http://photography.grayheron.net/   *
*   *
*******************************************************************************************************
--]]

function my_shoot() -- to grab an image
camera.shoot(false)
end

function jiggle(around)
for i = 1, around do
    key.press(KEY.HALFSHUTTER)
    msleep(100)
    key.press(KEY.UNPRESS_HALFSHUTTER)
end
end

function move() -- to HFD position irrespective of lens starting position
if lens.focus_distance ~= 0 and lens.af then -- lens is OK
if lens.dof_far ~= lens.dof_near then -- ok to move
if lens.focus_distance < lens.hyperfocal then
repeat
lens.focus(-1,2,false)
until lens.focus_distance >= lens.hyperfocal
repeat
lens.focus(1,1,false)
until lens.focus_distance <= lens.hyperfocal
repeat
lens.focus(-1,1,false)
until lens.focus_distance >= lens.hyperfocal
else
repeat
lens.focus(1,2,false)
until lens.focus_distance <= lens.hyperfocal
repeat
lens.focus(-1,1,false)
until lens.focus_distance >= lens.hyperfocal
end
else
beep (3, 200 , 500)  -- warning message
display.notify_box("Check aperture", 3000)
end
else
beep (3, 200 , 500)  -- warning message
display.notify_box("Check lens settings", 3000)
end
end

function check_lens_ready() -- just in case
if lens.focus_distance ~= 0 and lens.af then -- lens is OK
repeat
msleep(100)
until lens.focus(0,1,false)
end
end

function check_bookend() -- adds an over exposed FRSP frame
if supermenu.submenu["Bookends?"].value == "yes"
then
local tv = camera.shutter.ms
local av = camera.aperture.value
camera.shutter.ms = 1
camera.aperture.apex = 9
my_shoot()
camera.shutter.ms = tv
camera.aperture.value = av
end
end

function go() -- and run the script
local lens_ok = true
local num_step = 0
local del = 0
local count = 0
local inf = 100000 -- pseudo infinity
local pos = 0
menu.close()  -- just in case
if lens.af and lv.enabled then -- alright to use script
msleep(supermenu.submenu["Delay"].value * 1000)
check_bookend() -- requested or not
move() -- back to HFD to start super resolution bracketing
count = 0
    for count = 1, supermenu.submenu["Number of images?"].value do
count = count + 1
my_shoot()
if count ~= supermenu.submenu["Number of images?"].value then
if supermenu.submenu["Sensor shift mode"].value == "IS Jiggle" then
jiggle(2)
elseif supermenu.submenu["Sensor shift mode"].value == "Lens Move" then
check_lens_ready() -- just in case
lens.focus(-1,1,false) -- move towards infinity
else
check_lens_ready() -- just in case
lens.focus(-1,1,false) -- move towards infinity
jiggle(2)
end
end
msleep(200)
        end
check_bookend() -- requested or not
beep (3, 200 , 1000)  -- and display message
display.notify_box("Script Finished Running", 5000)
else -- something is wrong
beep (3, 200 , 500)  -- and display message
display.notify_box("Sorry, can't use the script", 5000)
end
end

supermenu = menu.new
{
    parent = "Shoot",
    name = "Super Resolution Bracketing",
    help = "Works best with wide lens: be warned!",
depends_on = DEPENDS_ON.LIVEVIEW,
    submenu =
{
{
name = "Run Script",
help = "Does what it says after pressing SET",
depends_on = DEPENDS_ON.LIVEVIEW,
select = function(this) if lv.enabled then task.create(go) end
end,
},
{
name = "Number of images?",
help = "Number of super res images to take",
min = 4,
max = 20,
value = 4,
icon_type = ICON_TYPE.BOOL,
select = function(this,delta)
this.value = this.value + delta
if this.value > this.max then
this.value = this.min
elseif this.value < this.min then
this.value = this.max
end
end,
               },
{
name = "Delay",
help = "Delays script start by stated number of secs",
min = 0,
max = 5,
value = 0,
icon_type = ICON_TYPE.BOOL,
select = function(this,delta)
this.value = this.value + delta
if this.value > this.max then
this.value = this.min
elseif this.value < this.min then
this.value = this.max
end
end,
},{
name = "Sensor shift mode",
help = "Choose one of three strategies",
choices = {"IS Jiggle","Lens Move","Both"},
},
{
name = "Bookends?",
help = "Places an underexposed frame at start and end of bracket set",
choices = {"no","yes"},
}
}
}

garry23

  • Hero Member
  • *****
  • Posts: 1047
Re: NEW: Auto Super Resolution Bracketing Script
« Reply #5 on: December 20, 2016, 10:57:05 PM »
Just updated with a user selected sensor shift strategy :-)

DeafEyeJedi

  • Hero Member
  • *****
  • Posts: 2725
  • 5D3 / M1 / 7D / 70D / SL1
Re: NEW: Auto Super Resolution Bracketing Script
« Reply #6 on: December 23, 2016, 06:35:05 PM »
Thanks @garry23 for your continuous work as always and look forward to testing out your latest scripting via LUA.
5D3.123 • EOSM.203 • 7D.203 • 70D.112 • 100D.101

garry23

  • Hero Member
  • *****
  • Posts: 1047
Re: NEW: Auto Super Resolution Bracketing Script
« Reply #7 on: January 02, 2017, 02:56:59 PM »
For those interested in ML-enhanced super resolution photography, you may like to read my latest post: http://photography.grayheron.net/2017/01/further-experiments-in-super-resolution.html

Licaon_Kter

  • Senior
  • ****
  • Posts: 490
  • M
Re: NEW: Auto Super Resolution Bracketing Script
« Reply #8 on: January 12, 2017, 10:16:47 AM »
Niiice  :)

 

courtesy