Author Topic: SD6 - Auto Levels on unclamped data ?  (Read 1227 times)

The new HDR modes allow data to go to go outside of the 0..1 ( or 0..255 ) range, but apparently the Auto Levels node only works for data inside this range - unless i'm doing something wrong :)

Is there going to be support for "Auto Levels" to work on unclamped height data at some point ?

Or maybe Nodes that find the min/max value of height data, and write that value to a whole image ?
That way it would be possible to roll your own "Auto Levels" with a Pixel Processor for example.


I've tried to put together a node like that.  :D Basically it's working exactly like you've described it — it finds min/max values in an input image and remaps it to a new range. By default, it remaps to 0...1, but I've exposed the variables so you can choose another range if you would like to do so.

It is a preliminary work result, some bugs are to be expected. Tested it on HDR panoramas, seems to be working. Check it out to see if it's working for you — the node is attached below (for now, it will work best for resolutions of 1k or 2k).

Cool stuff ! :)

Seems to work quite well !
Is it accurate or more of an approximation ?

At the core, it should be mathematically accurate. This formula is used to remap values: NewValue = (OldValue - OldMin) * (NewMax - NewMin) / (OldMax - OldMin) + NewMin.

However, finding the OldMin and OldMax is quite an expensive operation in this implementation, so at higher resolutions (2k+) performance would start to drop quite a bit. To alleviate it, the node makes sampling for OldMin and OldMax values in lower resolution. Though there are some countermeasures, in some cases when resolution optimization is too extreme for a given image, due to downsampling OldMin and OldMax values can be sampled inaccurately (a small bit higher or lower than they are in fact). Most of the times, however, countermeasures mentioned above tend to work great, so it will produce a mathematically accurate result at a good speed for most cases.

One more note: I've spotted some strange occurrences when the image is being remapped to a range other than 0...1. It is possible that some pixels would get a value a little bit off this new range. For example, if you remap it to a range of 0.41 - 1, some pixel сan get a value of 0.409998 or like that. I believe this is a precision issue due to operating with Float values, but I'm not sure about it. As a workaround, I've decided to clamp such "stray" values — in practice, it shouldn't cause any problems, as the margin of error there is minuscule.

In the end, I've decided to release this node to the public as Auto Levels Plus. I think that auto levels functionality with an ability to specify a custom remap range is pretty cool in itself, with an HDR data support coming as an extra boon :) Will post here when it's live.

It's available  :) Controls were simplified a bit and it is .SBS instead of .SBSAR.,15281.0.html