|
|
| Landrew |
| Posted: Dec 17 2007, 09:31 PM |
 |
|
Advanced Member
  
Group: Members
Posts: 102
Member No.: 17383
Joined: 1-December 05

|
Howdy,
This is kind of a random question, but I am hoping that a reader here with graphics knowledge might know the answer.
In film and computer graphics it is quite apparent that midtones are more saturated than highlights. This can be easily seen as the color of highlights fades to white as they blow-out. Furthermore, one can use photoshop to see that shadows are even more saturated than midtones. So saturation always seem to fade as you go from dark to light.
So I am wondering what is the math behind this? In computer graphics rendering and in reality, light reflected from a surface will retain its hue and saturation regardless of "how much" light bounces off. Light does not change color when there is more of it.
I figure some sort of exposure function is being applied to the light, and I would love to know what the actual equation is.
Btw, by my figuring, it can't be a power function like gamma, because if saturation is defined by
sat = 1 - min/max
then doing somthing like squaring min & max will indeed change the saturation, but it will not fade the saturation as min & max increase. I.e.
sat = 1 - ( k * min / ( k * max) ) ^ gamma
gives just
sat = 1 - k ^ gamma * ( min/max) ^ gamma
Cheers, Landrew |
 |
| phaeron |
| Posted: Dec 18 2007, 04:22 AM |
 |
|

Virtualdub Developer
  
Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02

|
I've experimented with this a little bit and have had mixed results, but the basic idea I think is to decrease saturation when a color value is overbright instead of hard clamping the colors, which results in ugly hue shifts, particularly to yellows. It's hard to do well, though, because you end up with an image that looks a bit flat at the high end. I think the way I did it in HLSL was something like this:
| CODE | float y = dot(color, lumaAxis); float maxc = max(color.r, max(color.g, color.b)); color = y + (color - y) * saturate((1 - y) / (max - y + 1e-10f));
|
I believe there is actually a slight perceptual shift to blue as light gets dim enough that the eye switches from primarily using cones to rods, but that's only a factor in very dim light. |
 |
| Landrew |
| Posted: Dec 19 2007, 07:23 PM |
 |
|
Advanced Member
  
Group: Members
Posts: 102
Member No.: 17383
Joined: 1-December 05

|
I've done something similar which I call "hue based clipping" that holds HSV hue constant by essentially taking an RGB value and keeping "min", clipping "max", and then settings "mid" to whatever value retains the original hue.
But in terms of light modeling and the mapping of light [0..inf] to tone [0..1], I've never seen an equation for an exposure function. I "guessed" one function based on a statistical model of photons hitting film grains and came up with
tone = 1 - 2 ^ ( - light )
This does have some expected properties. It gently blows out with minimal hue shift. And it fades saturation smoothly all the way from shadows to highlights, which can be seen by plotting saturation: 1 - tone( k* light ) / tone( light ) for any k in [0..1].
I wonder where I could look for find out what exposure functions cameras, graphics shaders, etc. use... I don't know of any forums or books that would get this into the math...
Cheers, Landrew |
 |
| phaeron |
| Posted: Dec 20 2007, 08:44 AM |
 |
|

Virtualdub Developer
  
Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02

|
You might want to look into the tone mapping functions used for high dynamic range (HDR) rendering. There is one set documented in the DirectX SDK that involves a linear ramp ending with an asymptotic curve (k * x / (x+c)), and GPU Gems 2 has some exponential tone mapping functions (exp(-k*x)). |
 |
| Landrew |
| Posted: Dec 20 2007, 08:23 PM |
 |
|
Advanced Member
  
Group: Members
Posts: 102
Member No.: 17383
Joined: 1-December 05

|
Thanks for the pointers! The second one you mentioned from GPU gems is the same as the one I guessed, just inverted. Its the first confirmation I've ever found of that function 
Cheers, Andrew |
 |
| arklight |
| Posted: Jan 19 2008, 02:25 PM |
 |
|

Advanced Member
  
Group: Members
Posts: 135
Member No.: 8316
Joined: 16-January 04

|
| QUOTE (phaeron @ Dec 17 2007, 10:22 PM) | I've experimented with this a little bit and have had mixed results, but the basic idea I think is to decrease saturation when a color value is overbright instead of hard clamping the colors, which results in ugly hue shifts, particularly to yellows. It's hard to do well, though, because you end up with an image that looks a bit flat at the high end. I think the way I did it in HLSL was something like this:
| CODE | float y = dot(color, lumaAxis); float maxc = max(color.r, max(color.g, color.b)); color = y + (color - y) * saturate((1 - y) / (max - y + 1e-10f));
|
I believe there is actually a slight perceptual shift to blue as light gets dim enough that the eye switches from primarily using cones to rods, but that's only a factor in very dim light. |
Hmmm.
unfortunately film stock doesn't always see color the way our eyes do. I see in most modern films a desaturation from mid to high mids to light. with also a bias towards BLUE.
will up some image examples sometime.
Even though they might change the lighting circumstances, add optical filters to change the OVERALL hue, this desaturation effect is still apparent. In the 300 challenge when mimicking film it was most appent.
http://neuron2.net/board/viewtopic.php?p=8...8029f8b150e39dc
What would be great is AFTER altering that colour is outputting it to image formats/image sequences that can contain the colour subtlties that we associate with film like HDR- DPX, Cineon,OPENEXR,HDR blah blah.DPX being the leader at the moment.Instead of crushing it back out to 8 bit per channel on it's way out.
Which is why it looks right when you are colour editing it.
But looks wrong when you are viewing the outputted final product.
there are very very few opensource software out there that can even open, let alone view these files. this being one of the few that can....
http://www.rendernan.com
edit paint in hdr, export hdr....opensource...
http://www.cinepaint.org/
other HDR info...
http://en.wikipedia.org/wiki/Digital_Picture_Exchange
http://en.wikipedia.org/wiki/Openexr
This destaturation thing is also why nagiller "bugsbunny's" HSV (hue saturation value) curves implementation in the gradation filter....
http://forums.virtualdub.org/index.php?act...=ST&f=7&t=15039
which can import HSV AMP FILES files from smart curve,
http://www.free.pages.at/easyfilter/curves.html
means you can easily using curves add or remove saturation across the tonal range of the image while correcting any changes in brightness etc with the value curve.
Heri Mkocha |
 |
| phaeron |
| Posted: Jan 19 2008, 09:23 PM |
 |
|

Virtualdub Developer
  
Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02

|
Interest in HDR video is slowly increasing, but not much of it has trickled down to consumer level. The modern video compression techniques don't generally accommodate HDR, although there have been a few SIGGRAPH papers about extending MPEG-1/2/4 to support MDR or HDR with sideband data. The desktop is firmly limited to 32-bit right now, and the most you'll generally get in display fidelity is 10 bits per channel, if you go full-screen. For a while now, BrightSide has had a display that uses a combination of software-controllable LED backlights and an LCD panel to display HDR imagery, but consumer-level software doesn't support it. Tools that are used in 3D or in film tend to support the OpenEXR format, and the half float format is now generally supported in hardware, but again video software support is lacking. |
 |
| arklight |
| Posted: Jan 26 2008, 05:11 PM |
 |
|

Advanced Member
  
Group: Members
Posts: 135
Member No.: 8316
Joined: 16-January 04

|
Here are some examples of some frames, that show some of the film bias i'm talking about...
DESATURATION:

WARMER SATURATED DARK TONES...COOLER DESATURATED LIGHTER TONES:


I know colored lighting, filters optical and digital have produced an array of film styles ( look at sin city).But I think the trends above apply for the majority of the film styles used.
Heri Mkocha |
 |