Pages: [1]   Go Down

Author Topic: B&W Channel mix BEFORE or AFTER gamma  (Read 3825 times)

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
B&W Channel mix BEFORE or AFTER gamma
« on: September 09, 2007, 07:13:28 am »

In this thread: http://luminous-landscape.com/forum/index....showtopic=17775 I was showing a program I am developing to blend different images expanding dynamic range and reduding noise.

As I work the data in high precision floating point, I can do several processes at a time without any loss of quality. In particular I am talking about the processes of:

1. Exposure correction (for the overexposed shots of the set)
2. Gamma correction (apply the: output=(input/max)^(1/2.2)*max, now not having to do it later in PS)
3. B&W conversion (according to CIE Y=0.299R+0.587G+0.114B or whatever the user selects)

By performing all those 3 steps at a time, in 64-bit floating point, we would obtain a final gamma corrected 16-bit B&W image with a tremendously high tonal richness that cannot be achieved if a linear integer 16-bit colour output is produced, as in this case channels would have already been rounded and moreover, the gamma correction we would apply later would generate holes in the low end of the histogram.

My question is: what is more conceptually right, to do the channel mix to build the B&W luminance BEFORE or AFTER the gamma correction?
When converting to B&W from colour in PS using the channel mixer, we are starting from an already gamma corrected image; however I have a feeling it's more correct conceptually to do it before the gamma correction. And into my program I can switch the order of steps 2 and 3.

Regards
« Last Edit: September 09, 2007, 07:16:15 am by GLuijk »
Logged

Jonathan Wienke

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 5829
    • http://visual-vacations.com/
B&W Channel mix BEFORE or AFTER gamma
« Reply #1 on: September 09, 2007, 10:04:38 am »

Channel mixing should be last, after gamma conversion. At that point calculating the gray value is a simple (R * x + G * y + B * y). It's the best way to do it working in 16-bit-per-channel integers, and changing to higher-precision doesn't alter the optimal order for doing things. All it does is make the penalty for doing things stupidly less severe.
« Last Edit: September 09, 2007, 10:08:47 am by Jonathan Wienke »
Logged

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
B&W Channel mix BEFORE or AFTER gamma
« Reply #2 on: September 09, 2007, 12:03:55 pm »

Quote
Channel mixing should be last, after gamma conversion. At that point calculating the gray value is a simple (R * x + G * y + B * y). It's the best way to do it working in 16-bit-per-channel integers, and changing to higher-precision doesn't alter the optimal order for doing things. All it does is make the penalty for doing things stupidly less severe.
[a href=\"index.php?act=findpost&pid=138165\"][{POST_SNAPBACK}][/a]

Thank you Jonathan I will listen to you.

BTW I will implement one of your suggestions; some weeks ago you talked about the possibility of performing a software 'Exposure to the right' at the same time as the blending.

I think I will definitively do that, so that the least exposed image of the whole set reaches exactly the 65535 level. In fact I will provide some way to allow a configurable % of blown pixels so we can even expose a bit more to the right than that, at a low cost (few pixels blown) and improving even more tonal richness in the shadows by reducing tone aggregation.

jbrembat

  • Full Member
  • ***
  • Offline Offline
  • Posts: 177
B&W Channel mix BEFORE or AFTER gamma
« Reply #3 on: September 09, 2007, 03:21:18 pm »

Quote
My question is: what is more conceptually right

I don't think there is a conceptual right palce.
Generally B&W is performed on gamma corrected data, but this is bacause the image is in that space.

I think you can try both and decide what is more pleasant.

Jacopo
Logged

PeterLange

  • Guest
B&W Channel mix BEFORE or AFTER gamma
« Reply #4 on: September 09, 2007, 04:40:49 pm »

Quote: >> Perhaps you've learned that you can compute the luminance of an RGB color by taking 30% of its red component plus 59% of its green component plus 11% of its blue component. These weightings are often expressed in three-digit precision as 29.9% red, 58.7% green and 11.4% blue. Did you ever wonder where these weightings came from?

You can find them in the above table as the relative Y values for red, green and blue for the NTSC color model. The more precise weightings are 29.8839% red, 58.6811% green and 11.4350% blue. But it should also be obvious that the real RGB weightings depend upon the color system in use. So the "standard" weightings are incorrect for other RGB systems like sRGB or Adobe RGB (1998).

Another relevant fact is that these weightings must be made in a linear RGB space, that is, after the gamma companding function has been removed. It is very common to see the weightings applied bluntly to the companded RGB values, which is wrong. <<

http://www.brucelindbloom.com/WorkingSpaceInfo.html

Peter

--
Logged

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
B&W Channel mix BEFORE or AFTER gamma
« Reply #5 on: September 09, 2007, 07:35:23 pm »

Quote
(...) Another relevant fact is that these weightings must be made in a linear RGB space, that is, after the gamma companding function has been removed. It is very common to see the weightings applied bluntly to the companded RGB values, which is wrong.

Peter

Clear as water, thank you Peter.

That website is a fantastic source of knowledge.
This man mentions digitaldog BTW
« Last Edit: September 09, 2007, 07:35:50 pm by GLuijk »
Logged

Jonathan Wienke

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 5829
    • http://visual-vacations.com/
B&W Channel mix BEFORE or AFTER gamma
« Reply #6 on: September 10, 2007, 04:34:47 pm »

I stand corrected on the B&W-conversion-before-gamma/companding thing, that actually makes sense. And I'm pleased to hear you like my auto-ETTR idea. A simple check box to activate the function, with a clip % amount like the Shadow/Highlight tool would be perfect. If you could manage to output to linear-RGB DNG so that I can keep my custom ACR color calibration I will happily buy your software.
Logged

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
B&W Channel mix BEFORE or AFTER gamma
« Reply #7 on: September 11, 2007, 07:15:52 pm »

Quote
If you could manage to output to linear-RGB DNG so that I can keep my custom ACR color calibration I will happily buy your software.[a href=\"index.php?act=findpost&pid=138499\"][{POST_SNAPBACK}][/a]

hehe DNG output would be fine, but not in my plans (for now).

However I must say that I intend to do something that will provide higher quality images in terms of tonal richness than any coming from a 16-bit linear RAW, since I plan to apply the gamma in floating point from inside my own code at the same time as the exposure correction.

Not sure it this will work on realistic colour pictures, since gamma has strong implications in Hue. But for B&W, I have great expectations.

This is a simulation of level agregation comparing:
1. Exposure linear correction -> then rounding to 16-bit linear integer -> then gamma
vs
2. Exposure linear correction+gamma -> then rounding to 16-bit non-linear integer

In the first case (which is the way I've been working up to now), linear levels ranging 5680 to 5695 for instance become the same 355 exposure corrected linear value which obviously turns into the same 6114 gamma corrected value afterwards in PS.

On the other hand, by applying the exposure correction and gamma at the same time in floating point, and applying the rounding only in the end, we can see 7 additional levels between the 6114 and 6122. So the tonal richness is heavily improved.



I think with this simple operation we can obtain incredibly rich images in terms of tonal richness, which in addition to the absence of noise will provide virtually undestructible B&W images on PP as the whole 16-bit gamma corrected low end of the histogram will be filled with levels (no holes at all).

I am not sure even if such a high tonal richness will be of use (perhaps it will make no practical difference over a free of noise 16-bit DNG), but I want to try it since conceptually sounds great.
« Last Edit: September 11, 2007, 07:23:51 pm by GLuijk »
Logged
Pages: [1]   Go Up