Last week I had some time to play with ETTR and I think I've found a way to avoid the severe underexposure in scenes with high dynamic range (e.g.

like this).

https://bitbucket.org/hudson/magic-lantern/commits/fcdc23eb5d7dHow it works:

- If the midtones get too noisy, the ETTR algorithm will stop underexposing.

- Same thing if the shadows get too noisy.

How to quantify "too noisy"?

For midtones it's easy: the median "brightness" gives you the signal level, so we can use the SNR. So, when I say the midtone SNR is 5 EV, this means half of the image has a SNR less than 5 EV, and the other half has a SNR higher than 5 EV. Pretty easy and statistically robust.

For shadows, I've chosen the 5% percentile. So, in this context, the shadows having a SNR of 3 EV means 5% of the image pixels have a SNR lower than 3 EV, and the other pixels will be brighter than that.

Keep in mind that 5% is bigger than you may think, since it refers to image area, not linear size. The linear percentage is roughly 22% (1/4.5).

So, you can choose 2 noise limits, one for midtones and one for shadows, and the image will not get noisier than that (but you may lose some highlights). This setting has the highest priority, so it will sacrifice highlights even if you disallow clipping from the other settings.

I'm not yet sure what are some good defaults for this new trick, so it's turned off by default.