Automatic color grading script for photos (uniform_exposure.py)

Started by a1ex, July 10, 2013, 08:35:55 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

a1ex

Highlight, midtone and shadow levels are used to decide what exposures to use for developing the image. Values are normally from 0 to 65535 (though you can use higher values to push the exposure even more).

From this:

def get_medians(file):
    return get_percentiles(file, [50, 99.99, 1])


you can see that:

- Midtones are the median brightness of the image. So, if you don't use any highlight/shadow recovery (that is, no HDR processing, just a plain curve), you will get JPEGs with the same median brightness. That's effectively the deflicker algorithm used in ML for timelapse.

- Highlights are metered at 99.99th percentile (so, the brightest 0.01% of all pixels will be considered "specular highlights" and ignored). A lower highlight_level will reduce the exposure used for highlight recovery (so it will recover more highlights).

Note: the darkest image will be developed at no less than -0.5 EV, because usually there's no more useful highlight detail below this level.

- Shadows are metered at 1st percentile (maybe I should choose the 5th percentile, as in ETTR). This would basically meter the darkest object in your scene. So, if you want brighter shadows, increase shadow_level.

So, midtone_level gives the basic exposure (for mitdones), and the other two are used to decide whether you need highlight/shadow recovery (and how much). If the exposure values are too far apart, it will insert some intermediate values, according to ev_step (because enfuse seems to give less ghosting with small EV increments in the bracketed sequence).

Once it decides the exposure values, the script invokes ufraw and enfuse, which do the hard work.

Tip: to disable highlight/shadow recovery, set highlight_level = 1e10 and shadow_level = 1 (extreme values, which will be interpreted as "no highlight/shadow correction needed"). If you do that, the script will do a simple deflickering, with no HDR processing.

afre

Thanks A1ex, The reason for my query is that I feel like my settings are arbitrary. I would like to set things with more precision and confidence, getting a desired result without having to wrestle with the parameters too much. E.g. apply 10% highlight and 5% shadow recovery. It's meant to save time after all and I don't think it's doing that for me at the moment ::)

Basosa

Hi everyone,

First of all, thank you for this amazing software and more generally for magic lantern.
I realize each step described in Reply #84 by a1ex (each version of each software), but I have the same problem that cineNoisis. When I launch the program  two folders are created (jpg and tmp) but they are empty.
I have tried several paths but none works.

I have the following message:
Warning could not creat output dir 'jpg'
Warning could not creat output dir 'tmp'
Traceback>most recent call last<:File "C:\expotest\uniform_exposure.py", line 251, in <module>
Files= sorted4<os.listdir<raw_dir<<
WindowsError: [Error 3]the specific path can not be find 'raw/*.*'

I also try to patch ufraw but I have the following error message:
File "F:\expotest\patched-ufraw.py"
Experimental<read:hackish>support 32-bit floating point DNGs
SyntaxError: invalid syntax

I use windows 8.1 pro x64
I am sorry but I am not familiar with coding, so any help will be welcome

Regards

Basosa

Hi again, maybe I have found something but I still have troubles.
My ms-dos starts automatically with C:\Users\Sebastian. So I put all files in this directory and afterward I get this new error message:
Temperature=5500 –green=1
'convert' is not recognized as internal or external command
Before I moved the files to this directory the script also created empty jpg and tmp folders in C:\Users\Sebastian.
I hope that could help understand my problem (or maybe not)

a1ex

The last error means you should also install ImageMagick (which provides the "convert" command).

Basosa

Hi a1ex,

Effectively it was a problem of ImageMagic, the first time I didn't pick all the options.
But (unfortunately) now at the end of the installation I have this error message:
unable to execute file: ppm
shellExecuteEx failed; code 2.
The file specified cannot be found
But at the end a dialog says the installation is done. I can run 'uniform_exposure.py' but my picture is very strange.
So I don't know if it has something to do with the error message or if I have to change the parameters of 'uniform_exposure.py' (I suppose it is still a problem with Image Magic).

http://www.casimages.com/i/150310092529869962.jpg.html

Thank you again.

a1ex

Your image is a dual ISO one? If so, you need to convert it first to DNG with cr2hdr.

(you can leave both the CR2 and DNG in the raw directory - the script will pick the DNG if it finds both files)

Basosa


88oak88

hello, how do I change the file output quality in uniform_exposure script
for 100% or change the output to .tif, I would use for my photos. the script is many great but would like to customize it to my needs. I know some programming. thank you and thanks for the great work team ML.

a1ex

Quote from: 88oak88 on March 10, 2015, 11:52:20 PM
[...]change the output to .tif [...] I know some programming. [...]

In this case, finding the answer is as simple as opening the script and pressing CTRL-F, T, I, F (at least with Firefox).

88oak88


cedricb

...is there a way of generating roughly the correct amount of midtone/highlight/shadow levels needed for a specific image?  ...maybe based on the histogram?  ...or is it just based on try and error to get a pleasant result?  :-\

a1ex

Yes, take a look at "override_settings" (there is an example commented out).

cedricb

...ok fine but how do you achieve the calculation of the "best guest" of the midtone/highlight/shadow ?  ...maybe by doing a histogram redistribution/equalisation and comparing with the original?  (don't know I'm just speculating or talking rubbish!!)

Otherwise did you see my PM?  ;)

a1ex

The script looks at the histogram to decide the midtone exposure level, and how much highlight/shadow correction is needed for each image. Usually I run a test pass at low resolution (faster), then take a quick look at all the pictures, and I override the settings for those pictures that don't look the way I like (just trial and error). I also adjust other things like WB, saturation or crop/rotate in ufraw (and save .ufraw files where needed - the script will use them if they are present). Once those adjustments are done, I run the script again at higher resolution for the final output.

Nicovideolab

Hello.
I write from Italy (google translator)
I'm in love with ME and Dual Iso and I'm starting to use the fine program of self-correction.
I wondered if it was possible to add an option that would allow to have outbound another CR2 or DNG with its file .xmp so as to re-open it directly in Camera Raw (curves have already settled) and deal with only the color?
It could be an idea that still allows you to manage the final phase of the conversion.

nikfreak

Did anyone already have the idea to clone / transform / code this script for Lightroom or implement it as a Photoshop script / plugin. Heck, I even don't know if that would be possible but it came just up to my mind...
[size=8pt]70D.112 & 100D.101[/size]

a1ex

As a starting point, one can use dmilligan's deflicker script: www.magiclantern.fm/forum/index.php?topic=8850
It uses histogram analysis as well, so it should be easy to implement something similar.

Nicovideolab


Nicovideolab


Nicovideolab



This is the foto.All'improvviso started this difetto.Non know if I inadvertently changed something,

ruli

hi,
I'm a complete noob here  :'(
can i get help?
I've installed everything but its not run as expected; i think the one is about adding path to computer; i'm using windows 8.1; anybody?

thanks

Scipione205

@a1ex:

I didn't understood how this script works; I would like to understand how to apply a tonal curve so that I can decide wich raw value will correspond to the middle gray. I shoot dual iso 100/3200 and I use an exposure meter and I set aperture and shutter speed for a choosed EI from 100 up to 3200, then when I develop the image I must fight with the curve tool... it's a nightmare because it is only 255x255...
I would like to meter the raw values of middle gray for every EI from 100 to 3200, and then write a script that applies a tonal curve to retrieve the proper EI.



nezn2007

can you help me?)
i have cr2 dual iso photos, is it possible to add dual iso procession to python batch?

350D

Correct me if i've missed something, but, any GUI or app available here for these scripts already?