CeroNoice - HDR tool inspired from ZeroNoise

Started by a1ex, December 15, 2013, 04:47:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

a1ex

After having some trouble getting ZeroNoise working, I coded my own version of the algorithm (well, only the part I understood) and ran a little experiment to check whether you should really take as many brackets as you can, or whether you can get away with just 2 or 3 pictures spaced at 4 EV or more.

I've called my program CeroNoice, pronounced pretty much like ZeroNoise, with a Spanish "ce" ("hay que sacar la lengua").

Download: CeroNoice.exe. It requires dcraw (get it from cr2hdr.zip) and outputs 32-bit float DNGs (I know, it's overkill, but 16-bit float is not a native C data type).


Greg sent me a 6x2 EV bracketed sequence (thanks!):
IMG_5826.CR2 IMG_5827.CR2 IMG_5828.CR2 IMG_5829.CR2 IMG_5830.CR2 IMG_5831.CR2



The test script and results (warning: the files are huge, don't jump to download without reading what is what):

# 1 image, exposed for highlights
sh test.sh IMG_5826.CR2 && mv out.dng 26.dng && convert a.tif 26.jpg

# 2 images, 2 stops apart
sh test.sh IMG_5826.CR2 IMG_5827.CR2 && mv out.dng 26-27.dng && convert a.tif 26-27.jpg

# 2 images, 4 stops apart
sh test.sh IMG_5826.CR2 IMG_5828.CR2 && mv out.dng 26-28.dng && convert a.tif 26-28.jpg

# 2 images, 6 stops apart
sh test.sh IMG_5826.CR2 IMG_5829.CR2 && mv out.dng 26-29.dng && convert a.tif 26-29.jpg

# 2 images, 8 stops apart
sh test.sh IMG_5826.CR2 IMG_5830.CR2 && mv out.dng 26-30.dng && convert a.tif 26-30.jpg

# 2 images, 10 stops apart (!)
sh test.sh IMG_5826.CR2 IMG_5831.CR2 && mv out.dng 26-31.dng && convert a.tif 26-31.jpg

# 3 images, 4 and 6 stops apart (total 10)
sh test.sh IMG_5826.CR2 IMG_5828.CR2 IMG_5831.CR2 && mv out.dng 26-28-31.dng && convert a.tif 26-28-31.jpg

# 3 images, 6 and 4 stops apart (total 10)
sh test.sh IMG_5826.CR2 IMG_5829.CR2 IMG_5831.CR2 && mv out.dng 26-29-31.dng && convert a.tif 26-29-31.jpg

# 6 images, 2 stops apart (total 10)
sh test.sh IMG_5826.CR2 IMG_5827.CR2 IMG_5828.CR2 IMG_5829.CR2 IMG_5830.CR2 IMG_5831.CR2 && mv out.dng 26-27-28-29-30-31.dng && convert a.tif 26-27-28-29-30-31.jpg

Other scripts you may need to review or reproduce my experiment:
dngfloat_hdr.py (requires dng_validate.exe from Adobe DNG SDK v1.4, not earlier)
test.sh

Now it's your turn to look at these images, try my program and draw the conclusions.

Happy pixel peeping!

engardeknave

Oh wow, I will have to investigate these later.

QuoteGreg sent me a 6x2 EV bracketed sequence (thanks!):
IMG_5826.CR2 IMG_5827.CR2 IMG_5828.CR2 IMG_5829.CR2 IMG_5830.CR2 IMG_5831.CR2

This is kind of a shitty bracket. Are you lacking brackets to test with? I have so, so many.

a1ex


a1ex

Update: I've patched ufraw to open these 32-bit DNGs. Of course, internal processing is still 16-bit, but the range is chosen according to initial exposure compensation passed from command line. That means, if I start ufraw with "ufraw foo.dng --exposure=15", it will throw away 12 EV of highlight detail (initial exposure - 3EV) and will use these bits for shadow detail.

With this patch, I can run these DNGs through uniform_exposure.py and it just works. Here's what I've got from this example, with default settings:



The patch is very rough and quite invasive; I doubt it will be accepted if I submit it to ufraw tracker in at this stage. But if you want to try it, I'd be happy to see your feedback.


engardeknave

The two photos eight stops apart output is really an incredible result. I was unable to achieve this with those two photos even with manual adjustment via my normal methods. The others with more frames have less noise in the shadows, but the difference is not noticeable at normal resolutions. And if that is just what the script produced without manual adjustment, this is really significant. This may be a better HDR solution than anything else around now.

Going to download the scripts/patches and try it.

a1ex

Yes, all these pictures were obtained without manual adjustment. Caveat: if you want to use uniform_exposure.py you will have to compile ufraw after applying my patch (easy on Linux, but on Windows it doesn't seem easy).

Kirkt (a big fan of ZeroNoise and dual ISO) told me there's a HDR program that uses the ZeroNoise technique: http://www.lumariver.com/Products/LumariverHDR/

About Lightroom: after watching this tutorial, there seems to be a HDR processing mode in LR that lets you move the exposure slider from -10 to +10, but my 32-bit float DNGs can only be adjusted from -5 to +5. As far as I understood from here, DNG files are imported via Adobe Camera Raw, which is limited to 16-bit output. Marsu42 confirmed this. Boo...

After reading this I thought floating point DNG is the way to go, but I couldn't find a straightforward way for regular users to edit these files (except for dng_validate and my modified ufraw, both requiring geek skills).

If you have some contacts at Adobe, feel free to ask them to take a look at these files. I'm a total noob regarding Adobe products, so I'd like some help.

Walter Schulz

Quote from: a1ex on December 16, 2013, 07:54:58 AMIf you have some contacts at Adobe, feel free to ask them to take a look at these files.

Eric Chan is active in Luminous Landscape's forums and an engaged and helpful person. His nick is madmanchan. If you don't want to participate there you may contact him via email. Just visit http://people.csail.mit.edu/ericchan/photos/ and you will find his address.
If the name doesn't ring a bell just read credits for LR and/or CS/CC's RAW module. Or read http://blogs.adobe.com/photoshopdotcom/2013/07/principal-scientist-and-mad-man-eric-chan-discusses-his-role-in-improving-photoshop.html

Ciao
Walter

engardeknave

Yeah, I have no way of patching UFRaw, but I'm playing around with Ceronoice now. In one case I had somewhat better results than exposure fusion using Ceronoice with only two files out of a seven frame bracket. I had very poor results with a particularly terrible bracketed scene (the one with the brown floor/furniture bright window included in the brackets I uploaded).

I can't believe how fast it is. This opens up the possibility of creating multiple versions of a file.

32-bit tifs can be adjusted in ACR 8.0 from -10 to +10. Just tried it. (Big difference!) I don't know if there's some problem with outputting to tif. I personally have no need to save adjustments in a 32-bit format, but if someone wanted they could open tifs directly in Photoshop and skip ACR.

a1ex

For TIF output I'd also have to do debayer, apply white balance and (here I'm a bit lost) do all sorts of color space conversions, gamma and so on. Basically, a complete raw converter from scratch. Maybe dcraw-float can help here, didn't look into it.

a1ex

Quote from: engardeknave on December 16, 2013, 12:37:50 AM
This looks promising. Still have to go through it all, but here's those brackets: http://we.tl/BQVDTX8Ind

First results:
- I simply ran CeroNoice * in all directories (blindly)
- I placed all the DNGs in one folder (had to rename them manually, this was the most painful step)
- I opened each DNG in the patched ufraw (with --exposure=10), adjusted WB (spot WB on the walls and 1-2 notches towards warmer color) and saved ID files (*.ufraw)
- ran uniform_exposure.py with default settings while writing this post
- after that, I looked in the JPEG folder and got these files (didn't pixel peep them yet):





Now I'd probably tweak the parameters to brighten them a bit. This workflow feels very confortable to me.

Continued: I've changed shadow_level to 200000 from 5000, which resulted in some obscene exposures being fed to enfuse (roughly from 0 to +18 EV). The resulting images got brighter, but had low contrast (example), so I've ran "mogrify -sigmoidal-contrast 4 *.jpg" (on 8-bit jpeg, but if you want stronger edits you should switch to 16-bit tif):





Attempt 3:

Looking at some reference JPEGs posted by engardeknave here, I realized this kind of photos should be even brigher:



Since shadow level was already maxed out (the brightest exposure from enfuse input was almost white), I've biased enfuse towards brighter midtones by setting enfuse_options = "--gray-projector=value --exposure-mu=0.6" in the script (default is 0.5) and I've also enabled 16-bit TIF output. Applied -sigmoidal-contrast 5 via ImageMagick, converted to jpeg (quality 75 to keep files small) and here's the result:





And finally, you can download some 16-bit low-contrast TIF files (as saved by enfuse) if you want to edit them: 3871.tif, 9296.tif and 9717.tif.

In a nutshell, this is what you can get with my scripted workflow and minimal tweaking.

Greg

It looks great. HDR programs can throw into the trash.  ;D

bart

Wow those are very high quality, natural and pleasing looking results. Well done!

engardeknave

The colors are really bad, but we're getting very close on the levels. I say this because they are different photoshoots and they're starting to look consistent. Once they're consistent, there's a baseline, and it's just a matter of personal taste from there. In ACR there's sliders for "blacks" and "whites", which seem to adjust shadow and highlight contrast respectively. That's what I'd probably use on most of these. I think there might be something going on with conflicting colorspaces too. They should all be sRGB, but I might have shot some in AdobeRGB.

God these houses are ugly. I should have thought of this before, but I just dug up all the finished shots from my site. I had to do a lot of color adjustments for most of these, so don't get hung up on the colors. Also the finished ones are all straightened out too.





dmilligan

@a1ex,

You might be interested in PixInsight. It has a very good HDR merging tool (that is mask based like this technique): http://pixinsight.com/forum/index.php?topic=2320.0

Also, all the sorts of advanced stuff you can do with PixInsight (like PixelMath, image analysis and statistics) seems to me like it would be right up your alley. It's easily extensible and scriptable as well (it's designed that way), you can easily work with linear data and huge precision (64-bit float). Most of the tools and workflows are aimed at astrophotography though.

engardeknave

Ok, something must be wrong with your dngs, A1ex. Maybe the headers. I found that I could save a 32-bit TIF as DNG from ACR (strangely it stays 32-bit). Then I can open it up in ACR and adjust exposure from -10 to 10.

a1ex


engardeknave

Also noticed the file is twice the size. http://we.tl/Hu3av6SqHg

Your dng is ~84mb, Adobe's is 150. A 32-bit tif is 240. Photomatix produces a 32-bit .hdr file that is 63mb. This works great in ACR, except there's no way to open multiple .hdr files at once in ACR. So frustrating.

a1ex

From file size, I guess Adobe's DNG is a Linear DNG (that is, demosaiced). Will download and take a look.

engardeknave

I found this: http://www.adobe.com/support/downloads/dng/dng_sdk.html

No idea if it's useful. Looking at the source I see interesting things like "dng_mosaic_info.cpp" ("A interpolation kernel for a single pixel of a single plane") and "dng_linearization_info.cpp".

a1ex

You can open the DNG with dng_validate.exe from that zip.

Another idea: compress the DNG with Adobe DNG Converter and see if ACR likes it better.

engardeknave

Same after Adobe DNG convertor. I'd tried dng_validate, but it gave me an error message on both your DNG and the one I saved from ACR.

I also confirmed that there seems to be better highlight control in ACR with the Adobe DNG than the ones CeroNoise is making.

a1ex

CeroNoice does not make any highlight control. I have no idea what you are comparing.

For dng_validate, make sure you have the SDK for DNG 1.4, not earlier.

Greg


engardeknave

I tried that in ACR already. No effect. (The options for those of you who don't have ACR and can't read moonspeak are "Linear (demosaiced)" and "Uncompressed".)

QuoteCeroNoice does not make any highlight control. I have no idea what you are comparing

I'm talking about the sliders in ACR. The exposure control goes from -5 to +5 with your dng and -10 to +10 with Adobe's, but I wasn't sure if that was really meaningful until I tested with a few of the sliders in ACR.