MLV Lite - The sweet taste of MLV with none of the extra calories™

Lua scripting updated


Twitter: @autoexec_bin    Facebook: magiclantern.firmware    Live chat: [email protected]

Want to help with Magic Lantern development, but have no coding skills?

Author Topic: Script for deflickering and ramping ACR (.xmp) settings in Bridge  (Read 89619 times)

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 2948
  • 60Da / 1100D / EOSM
This script is for deflickering and ramping pretty much any ACR setting from Adobe Bridge over a sequence of images

Website:
http://davidmilligan.github.io/BridgeRamp

Script download:
https://raw.github.com/davidmilligan/BridgeRamp/master/BridgeRampingScript.jsx

Place this script in:
Windows:
%APPDATA%\Adobe\Bridge CC\Startup Scripts\
Mac:
~/Library/Application Support/Adobe/Bridge CC/Startup Scripts/

to have it automatically load on startup (or you can just double click it or open it with Bridge when you want to use it). It will add three new items to the context menu 'Ramp...', 'Ramp Multiple...' and 'Deflicker...'

Simply select all the images you want to ramp, right click, go to 'Ramp...', 'Ramp Multiple...' or 'Deflicker...' and fill out the dialog.

'Ramp Multiple' ramps the existing ACR settings that you select from the first image to last (kind of like a smart version of the 'Synchronize' in the ACR dialog). You can also specify keyframes by rating them 1 star. It will ramp settings from one keyframe to the next. The first and last images are considered keyframes even if not marked. The deflicker will use keyframes marked like this as well.

This script is useful for timelapse as well as RAW video. There's an "additive" mode so you can add to the existing value (useful for modifying the exposure value calculated by ML Post Deflicker, easier than the exif tool way, and you can make it ramp as well)

There's also a version of this script for Lightroom:
Download:
https://github.com/davidmilligan/LrDeflick/releases/download/v0.1.0/

Code
https://github.com/davidmilligan/LrDeflick
« Last Edit: July 23, 2016, 01:38:19 PM by dmilligan »
Testers Needed ->MLV Lite

RenatoPhoto

  • Moderators
  • Hero Member
  • *****
  • Posts: 1410
  • 5DM3 / 7D
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #1 on: October 17, 2013, 02:31:03 PM »
Sounds very interesting.  I have windows ACR 8.2 and Bridge CS6.  Is there any way I can use it?
http://www.pululahuahostal.com  |  EF 300 f/4, EF 100-400 L, EF 180 L, EF-S 10-22, Samyang 14mm, Sigma 28mm EX DG, Sigma 8mm 1:3.5 EX DG, EF 50mm 1:1.8 II, EF 1.4X II, Kenko C-AF 2X

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 2948
  • 60Da / 1100D / EOSM
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #2 on: October 17, 2013, 02:32:49 PM »
yeah it should work fine in cs6, just change that path to ...\Bridge CS6\Startup Scripts
Testers Needed ->MLV Lite

Danne

  • Hero Member
  • *****
  • Posts: 2299
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #3 on: October 17, 2013, 02:43:51 PM »
Sounds very promising. Gonna try asap. Thanks for contributing

RenatoPhoto

  • Moderators
  • Hero Member
  • *****
  • Posts: 1410
  • 5DM3 / 7D
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #4 on: October 17, 2013, 03:04:17 PM »
Sounds very interesting.  I have windows ACR 8.2 and Bridge CS6.  Is there any way I can use it?

Ok found the startup scripts here:

C:\Users\RE\AppData\Roaming\Adobe\Bridge CS6\Startup Scripts

Copied the script
Paste to notes and saved it as BridgeRampingScript.jsx
Placed a copy in : C:\Users\mycomputername\AppData\Roaming\Adobe\Bridge CS6\Startup Scripts
Opened Bridge and asked me if I wanted to load the script.  Clicked yes
Selected a group of images I wanted to change the exposure
Right mouse click and selected "Ramp ACR Settings"
On the drop down menu you can select any of the xmp settings, default "Exposure2012"
In Start I entered -2
in End I entered 0  (This will ramp my exposures starting at -2 and ending at 0)
Clicked additive
click ok

Whala!  All of the xmps where succesfully modified and ramped to my taste.

Nice script!  Thanks and great work.


http://www.pululahuahostal.com  |  EF 300 f/4, EF 100-400 L, EF 180 L, EF-S 10-22, Samyang 14mm, Sigma 28mm EX DG, Sigma 8mm 1:3.5 EX DG, EF 50mm 1:1.8 II, EF 1.4X II, Kenko C-AF 2X

Danne

  • Hero Member
  • *****
  • Posts: 2299
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #5 on: October 17, 2013, 03:36:04 PM »
Sounds like solving the missing piece of the timelapse puzzle. Gonna try on my mac tomorrow
« Last Edit: October 17, 2013, 05:03:42 PM by Danne »

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 2948
  • 60Da / 1100D / EOSM
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #6 on: October 18, 2013, 02:28:29 PM »
So I'm actually close to getting this script to be able to do deflickering itself, I just need a little help with some Maths. I've managed to pull a bitmap of the Bridge preview (it's lowres, 8bit, but should be enough info to do the deflicker I think, also that helps speed b/c this is a script not native code) and generate a histogram from it from within my script. This entire process takes about 1-2s, so I think this should actually be feasable in terms of speed since that's the vast majority of the computation. It's certainly less time than it would take to have it load the entire image in photoshop and use photoshop's histogram data.

So now what I'm assuming I need to do is calculate where some target percentile is on the histogram (should be easy). Then calculate how far I need to move that to get it to some target level, and convert that to EV.

For example, let's say my target percentile is 50% and the target level is 127. I calculate the histogram and find that 50% is at 143, so now I know I need to shift left by 16. So how do I compute that as EV from an 8 bit (0-255) value? Am I on the right track at all here?

I found the function used by ML post deflicker called raw_to_ev, it basically does the following calculation: ev = -log2(raw_max) + log2(raw_value). Is that all I need to do?
Testers Needed ->MLV Lite

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 8921
  • 5D Mark Free
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #7 on: October 18, 2013, 02:33:01 PM »
You need to compute it either in raw or 16-bit linear space, or know the curve somehow.

log2 is a very crude approximation of this curve.

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 2948
  • 60Da / 1100D / EOSM
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #8 on: October 18, 2013, 02:42:52 PM »
so should I just reverse engineer the curve in 8 bit space, like take a blank white image apply a bunch of different EVs to it and do a logarithmic regression on the data points? Or is it just not feasible to try and calculate with 8 bit data?
Testers Needed ->MLV Lite

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 8921
  • 5D Mark Free
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #9 on: October 18, 2013, 02:46:32 PM »
Yes, if the "picture style" is always the same, this should work.

To simplify things, you may want to convert the image to grayscale first. For reversing, I think it's enough to render some image at say -0.5 and +0.5 EV (or maybe even smaller) and recover the curve from there, but I'm not sure if the accuracy is enough.

Some theory: http://en.wikipedia.org/wiki/Histogram_matching

Also look at the older bulb ramping algorithm: it reversed Canon curve on the fly in order to compute the EV from it. Should be exactly what you are looking for.
« Last Edit: October 18, 2013, 02:48:22 PM by a1ex »

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 2948
  • 60Da / 1100D / EOSM
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #10 on: October 18, 2013, 03:07:49 PM »
thanks a1ex!
Testers Needed ->MLV Lite

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 2948
  • 60Da / 1100D / EOSM
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #11 on: October 19, 2013, 12:23:20 AM »
It's working!!!

So what I ended up doing was using the tone curve instead of trying to calculate exposure adjustment. The tone curve is specified in 0-255 values so no conversion is needed. I computed the values of several various percentiles (25,50,75 perhaps more or a better selection would work better?) on a reference image, then those become the y values of the tone curve with the image's percentiles values as the x.

It seems to be working, I haven't had much of a chance to test and put it through it paces yet.

Any suggestions?
Testers Needed ->MLV Lite

Danne

  • Hero Member
  • *****
  • Posts: 2299
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #12 on: October 19, 2013, 12:51:15 AM »
hats of to you. Can,t wait to try it out. See if I get up to do I night to day timelapse tonight

rsmith02

  • New to the forum
  • *
  • Posts: 33
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #13 on: October 19, 2013, 03:30:38 AM »
Is it possible to do any of this in Lightroom? I only have old versions (CS3) of bridge. Could it work in CS3 Bridge and then Lightroom can read the fixed .xmps?

rsmith02

  • New to the forum
  • *
  • Posts: 33
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #14 on: October 19, 2013, 03:45:00 AM »
I tried it with CS3 and got an error:

"An error occurred while running a startup script named 'BridgeRampingScript'. It may not be compatible with this version of Bridge;


Error in C:\Users\me\AppData\Roaming\Adobe\Bridge CS3\Startup Scripts
Line 4: <!DOCTYPE html>
Variable or value expected
"

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 2948
  • 60Da / 1100D / EOSM
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #15 on: October 19, 2013, 05:34:46 AM »
Sorry, wish I could help you, Lightroom does not have scripting support and I don't have CS3. The script will probably work as far back as CS5, but that's about it.
Testers Needed ->MLV Lite

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 2948
  • 60Da / 1100D / EOSM
Re: Script for ramping ACR (.xmp) settings in Bridge
« Reply #16 on: October 19, 2013, 05:59:11 AM »
Updates:
I've added a couple more percentile levels and tried to optimize their distribution.

Skipping lines to speed things up a little

Deflicker now ramps from the first image selected to the last image selected. (initially it just tried to make all the images look like the first one). This should help for scenes where the lighting changes dramatically (i.e. sunset, sunrise). If you have a scene with a pretty static period, then a transition (such as some amount of night sky then a sunrise), you might want to select and deflicker the static period, then select and deflicker the transition separately, so the ramping is smoother, or you may not need to deflicker the static period at all, in which case only deflickering the transition will save you time.

You should be able to use some amount of the various controls that are known for causing flicker such as clarity and highlights, just apply those settings first to non-deflickered images, then run the deflicker.

If you need to rerun the deflicker make sure you clear the tone curve from all images before hand or the script will calculate the tone curve to apply incorrectly (since there is already one being applied).

I've got some before/after sample videos rendering at the moment, will post them soon.
« Last Edit: October 19, 2013, 06:09:49 AM by dmilligan »
Testers Needed ->MLV Lite

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 8921
  • 5D Mark Free
Re: Script for deflickering and ramping ACR (.xmp) settings in Bridge
« Reply #17 on: October 19, 2013, 09:21:44 AM »
Code: [Select]
var percentiles = [0, 0.3, 0.5, 0.75, 0.95, 0.99, 1.0];

Are you sure? This is no longer statistically robust, try to stay close to the median.

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 2948
  • 60Da / 1100D / EOSM
Re: Script for deflickering and ramping ACR (.xmp) settings in Bridge
« Reply #18 on: October 19, 2013, 02:27:45 PM »
I have no idea what should work, just trying things, what would you suggest? only the median?
Testers Needed ->MLV Lite

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 8921
  • 5D Mark Free
Re: Script for deflickering and ramping ACR (.xmp) settings in Bridge
« Reply #19 on: October 19, 2013, 02:35:34 PM »
I'd say try a few percentiles and choose the one that crosses the middle of the sky (roughly).

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 2948
  • 60Da / 1100D / EOSM
Re: Script for deflickering and ramping ACR (.xmp) settings in Bridge
« Reply #20 on: October 19, 2013, 03:01:49 PM »
Maybe I need a UI with a preview like you showed me with the percentile highlighted and let the user pick.
Testers Needed ->MLV Lite

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 8921
  • 5D Mark Free
Re: Script for deflickering and ramping ACR (.xmp) settings in Bridge
« Reply #21 on: October 19, 2013, 03:05:11 PM »
Yeah, that would be perfect. You can try the 2.3 version to see a UI that lets you select a percentile; something like that would be good IMO.

What I'd like to try is to use the median of the difference between images. I'm using it in dual ISO for matching brightness line-by-line; you can see the result here: http://www.magiclantern.fm/forum/index.php?topic=7139.msg83086#msg83086

(look at horizontal banding)

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 2948
  • 60Da / 1100D / EOSM
Re: Script for deflickering and ramping ACR (.xmp) settings in Bridge
« Reply #22 on: October 19, 2013, 07:40:17 PM »
okay, so I dropped trying to use the curve to deflicker and using exposure instead.  ev = 2 log2(x) seems to be a pretty decent approximation. You can now run several passes of the deflicker, it should get better each time (basically each iteration is reducing the error between ev = 2 log2 (x) and what ACR exposure is actually doing). After about 3 passes it's just about perfect. Percentile is now user selectable, I'm working on a percentile preview (image manipulation in scripting language may prove to be just to slow, we'll see).
Testers Needed ->MLV Lite



dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 2948
  • 60Da / 1100D / EOSM
Re: Script for deflickering and ramping ACR (.xmp) settings in Bridge
« Reply #23 on: October 20, 2013, 12:07:03 AM »
Deflickering Test
Testers Needed ->MLV Lite

Danne

  • Hero Member
  • *****
  • Posts: 2299
Re: Script for deflickering and ramping ACR (.xmp) settings in Bridge
« Reply #24 on: October 20, 2013, 12:10:04 AM »
genius!

 

courtesy