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.

brapodam

Sure, here is the dev.log: https://docs.google.com/file/d/0BzFGDdZw7pVwTmFSTW9TUFdIb3M/edit?usp=sharing

Intermediate files open fine, I'll try enfuse now

EDIT: enfuse produces a file with the same error, though I don't see anything unusual in the command prompt when I run enfuse
Quoteenfuse: info: input image "00000001-h0.jpg" does not have an alpha channel;
enfuse: info: assuming all pixels should contribute to the final image
enfuse: info: input image "00000001-h1.jpg" does not have an alpha channel;
enfuse: info: assuming all pixels should contribute to the final image
enfuse: info: input image "00000001-m.jpg" does not have an alpha channel;
enfuse: info: assuming all pixels should contribute to the final image
enfuse: info: input image "00000001-s0.jpg" does not have an alpha channel;
enfuse: info: assuming all pixels should contribute to the final image
enfuse: info: input image "00000001-s1.jpg" does not have an alpha channel;
enfuse: info: assuming all pixels should contribute to the final image
enfuse: warning: no usable resolution found in first image "00000001-h0.jpg";
enfuse: warning:   will use 300 dpi
enfuse: info: loading next image: 00000001-h0.jpg 1/1
enfuse: info: loading next image: 00000001-h1.jpg 1/1
enfuse: info: loading next image: 00000001-m.jpg 1/1
enfuse: info: loading next image: 00000001-s0.jpg 1/1
enfuse: info: loading next image: 00000001-s1.jpg 1/1

Here's a final output file: https://docs.google.com/file/d/0BzFGDdZw7pVwRlZLMzh1d3lMcFU/edit?usp=sharing

a1ex

Can you upload a final jpeg file?

I have enfuse 4.0-753b534c819d, what version is yours? I know syntax changed a little between 3.x and 4.x, but I'm not using any advanced options here.

brapodam

Strangely enough though, GIMP is able to open it. Some programs, like the default image viewer in Ubuntu, as well as Avidemux (which I use for time lapse sequences) are unable to open it

a1ex

Here, imagemagick says:


convert: Sorry, there are legal restrictions on arithmetic coding `00000001.jpg' @ error/jpeg.c/EmitMessage/235.


So... try to output a png or tiff or something:


j  = os.path.join(out_dir, change_ext(f, ".tif"))

Audionut

Quote from: IliasG on July 15, 2013, 09:37:52 AM
As Alex wrote, 3 stops is expected for 5DIII.

I haven't got my head around how the logarithmic SNR ratio plays into the equation.
Judging from the histogram (and others I've been playing with) I posted above, the tonal quality of a single ISO 100 shot falls to crap around -10.5EV.  The histogram of the enfused shots, show all but 100% tonal quality over the entire 16EV.  That's more then 3 stops improvement :)  I haven't done any testing by eye.

http://www.clarkvision.com/articles/evaluation-canon-5diii/
QuoteTable 2 shows the noise as a function of ISO in image form. The images illustrate several things: 1) lower banding noise at higher ISOs. 2) Better detection of smaller signals at higher ISOs (the random noise decreases). 3) At a certain high ISO, improvements decrease, meaning there is no benefit to higher ISO. Note, ISO is a post sensor gain and does not increase sensitivity. Increasing ISO digitizes a smaller range (see Table 1) but does improve the noise floor. While some banding noise is apparent at ISO 1600, would not be noticeable in many images. At ISO 3200 and higher, banding noise is almost negligible.

Quote from: IliasG on July 15, 2013, 09:37:52 AM
It depends on the model............It also depends on the ISOs used

Indeed.  Just like everything in life, there are compromises.  From what I've seen of a1ex's code so far, this little trick doesn't come for free ;)

brapodam

Quote from: a1ex on July 15, 2013, 09:53:52 AM
Here, imagemagick says:


convert: Sorry, there are legal restrictions on arithmetic coding `00000001.jpg' @ error/jpeg.c/EmitMessage/235.


So... try to output a png or tiff or something:


j  = os.path.join(out_dir, change_ext(f, ".tif"))

Ok, setting the output file to png works. Thanks!

a1ex

Cool.

For timelapse, this script may not be ideal; you probably want the same settings on all files, rather than analyzing every single image and deciding how many exposures it needs.

If you disable highlight/shadow recovery (e.g. by setting the thresholds to extreme values), you should get similar results as with ML post deflicker. Maybe slightly less accurate because of downsampling.

pascal

Hi, does this ISO trick also work for video captures? I see you merge 2 ISO images somehow. But that does not work für video production then, unless we capture something static right?

a1ex

You'll see when I'll announce it. There are still some little glitches in the workflow, and I'll try to publish the code these days.

brapodam

Quote from: a1ex on July 15, 2013, 10:07:37 AM
Cool.

For timelapse, this script may not be ideal; you probably want the same settings on all files, rather than analyzing every single image and deciding how many exposures it needs.

If you disable highlight/shadow recovery (e.g. by setting the thresholds to extreme values), you should get similar results as with ML post deflicker. Maybe slightly less accurate because of downsampling.
I doubt setting the thresholds to extreme values will help, especially in something like a sunrise/sunset/day to night time lapse. If you set highlight level to the max (65k or something), for the dark photos in the whole sequence, the script will try to push the highlights up, causing what is supposed to be a dark sky to appear bright.

Nevertheless, I'll still try playing around with the thresholds to see if it works. Maybe something like setting the shadow level to 1 but lowering the highlight level from the default value.

UPDATE: setting shadow_level to 1 and highlight_level to 500000 as suggested by a1ex produced results similar to post deflicker (no highlight or shadow recovery) for time lapse purposes. Exposure transitions were smooth for the most part but there were a few inconsistencies towards the end of the video



Quote# from 0 to 65535
highlight_level = 50000
midtone_level = 10000
shadow_level = 1000
The values there can't be 0. Using 0 as the shadow level results in a divide by 0 error  :)

a1ex

Setting highlight_level to 500000 and shadow_level to 1 should disable any correction. It's out of range, but it works because highlight correction is always negative compared to midtones, shadow correction is always positive.

CarVac

Can I expect this magical HDR readout mode to read the sensor quickly enough to be hand-holdable, or is it just a way to do HDR capture on a tripod, but in a single file (by effectively doing multiple silent exposures at different ISOs, for example)

I dream of getting clean shadows from handheld shots. I have written a tonemapping program of sorts that benefits enormously from clean shadows, but there are so many times when I don't have a tripod for bracketed shots.


togg

Quote from: a1ex on July 14, 2013, 02:04:50 PM
No, just one.

I'm not sure I've got it. You have found/invented something that increase the DR of a single photo?

Yoshiyuki Blade

Quote from: a1ex on July 14, 2013, 10:50:45 AM
Easy, with that theory that almost nobody believed: ISO 1600 is less noisy than ISO 100.

;)

Something along these lines: http://www.guillermoluijk.com/article/nonoise/index_en.htm

Dang, I wish I learned about this earlier  ;D I've been dabbling with enfuse by pushing an image in different directions and merging them together and thought, "Damn, it's great that I can see lots of shadow+highlight detail in one exposure now, but man it's noisy in the shadows." Now I gotta grab some new footage while it's still day outside at a high ISO and play with it later.  :o

brapodam

Quote from: togg on July 16, 2013, 12:14:16 AM
I'm not sure I've got it. You have found/invented something that increase the DR of a single photo?
The DR is there, he just found a good way to squeeze all of it out of the image. I don't think you can "increase the DR of a single photo"; what's captured in a raw photo is stored in the raw photo, you just need to be able to bring it out.

CarVac

Quote from: brapodam on July 16, 2013, 02:07:11 AM
The DR is there, he just found a good way to squeeze all of it out of the image. I don't think you can "increase the DR of a single photo"; what's captured in a raw photo is stored in the raw photo, you just need to be able to bring it out.

No, I don't think that's the case. The DR is not there; this supposedly actually reduces the noise in the shadows relative to an ordinary image readout.

hjfilmspeed

Im so confused. So far it seams to be a a way to merge 2 exposures but not a standard HDR way. I read a little and from what i understand one exposure is a normal exposure possibly protecting highlights a little and the other is for shadows, not to bring up shadows but to clean them up. But ive always found canon iso to be strange. i thought sensors had a native iso so how can canon have all these iso options. is it just meta data or what? I would love to try this what ever it is.

ilguercio

I guess there is more behind it than simple automatic color grading.
:)
Canon EOS 6D, 60D, 50D.
Sigma 70-200 EX OS HSM, Sigma 70-200 Apo EX HSM, Samyang 14 2.8, Samyang 35 1.4, Samyang 85 1.4.
Proud supporter of Magic Lantern.

ilguercio

I guess this also mean that now you know how the heck the ISO speed works on a Canon DSLR.
Any hints?
Canon EOS 6D, 60D, 50D.
Sigma 70-200 EX OS HSM, Sigma 70-200 Apo EX HSM, Samyang 14 2.8, Samyang 35 1.4, Samyang 85 1.4.
Proud supporter of Magic Lantern.

IliasG

Quote from: Audionut on July 15, 2013, 09:58:07 AM
I haven't got my head around how the logarithmic SNR ratio plays into the equation.

It's simple when working in stops (log2). ISO 1600 should have 4 stops less DR than ISO100. DXO measures it at only 1stop lower so the gain is 3 stops.

QuoteJudging from the histogram (and others I've been playing with) I posted above, the tonal quality of a single ISO 100 shot falls to crap around -10.5EV.  The histogram of the enfused shots, show all but 100% tonal quality over the entire 16EV.  That's more then 3 stops improvement :)  I haven't done any testing by eye.

At -10.5EV SNR is 1.0 .. totally crap .. but I would call it simply crap even at -9EV where SNR is around 4.0 ..



Look at how many values have population ..  8500 from 50000 available at best. On 0R0A0640-fullres-soft.DNG I count 12800 from 52000 available.
Raw levels density starts at 1:1 at the darks and goes up to 1:9 at highlights. Looks like a 14bit log file linearized at 16bit

QuoteIndeed.  Just like everything in life, there are compromises.  From what I've seen of a1ex's code so far, this little trick doesn't come for free ;)

Can you clarify .. what's the cost as you see it ?.




escho

I hoped, the dual iso trick would work with my 600D. But as I see in the code of alex, it only works on 5d3 and 7d. Nevertheless great work!

Edgar
https://sternenkarten.com/
600D, 6D, openSUSE Tumbleweed



togg

Quote from: a1ex on July 16, 2013, 06:36:37 PM
The mystery should clear up now.

Announced here: http://www.magiclantern.fm/forum/index.php?topic=7139

Now we are talking :D I want to read the pdf to understand how all of that was possible.