Histograms: RGB vs. Luminance

Joined
May 5, 2005
Messages
24,496
Location
SW Virginia
It was never clear to me whether the luminance histogram displayed by our cameras is the sum or the average of the RGB channels, but I thought it was the sum.

This example clearly indicates that it is the average.

rgb_vs_luminance.jpg
Subscribe to see EXIF info for this image (if available)


The inset histogram is actually from ViewNX2, but the camera (D7000) displays an equivalent histogram.

The lesson to me is that the luminance histogram can be very misleading!
 
Joined
Jan 15, 2010
Messages
3,985
Location
UK
Quote:

Luminance histograms are more accurate than RGB histograms at describing the perceived brightness distribution or "luminosity" within an image. Luminance takes into account the fact that the human eye is more sensitive to green light than red or blue light. The luminance histogram also matches the green histogram more than any other color.
In order to produce a luminance histogram, each pixel is converted so that it represents a luminosity based on a weighted average of the three colors at that pixel. This weighting assumes that green represents 59% of the perceived luminosity, while the red and blue channels account for just 30% and 11%, respectively. Once all pixels have been converted into luminosity, a luminance histogram is produced by counting how many pixels are at each luminance — identical to how a histogram is produced for a single color.
An important difference to take away from the above calculation is that while luminance histograms keep track of the location of each color pixel, RGB histograms discard this information. A RGB histogram produces three independent histograms and then adds them together, irrespective of whether or not each color came from the same pixel.

I tend to agree relying on the Luminance information only may get you into trouble - how can you tell if an individual channel is clipping?
The other issue is if you are shooting in RAW then as I understand it the LCD histogram is only displaying jpeg which may show clipping that is not actually there in the RAW. I find this a little bothersome!
 
Joined
Apr 3, 2006
Messages
5,614
Location
Texas
The RGB histogram (Nikon, Adobe) simply just overlays the three channels. They are not summed, just overlaid, one behind another. One may hide smaller values behind it (often they all show as black), but taller values will extend above to overlook it, and the taller peaks will be visible. This shows contributions of the three RGB channels, but it does not show luminance or brightness.

The Luminance histogram computes a grayscale value, normally from the NTSC television formula from the three RGB components of the pixel, which is Luminance = 0.3 Red + 0.59 Green + 0.11 Blue

(note 0.3 + 0.59 + 0.11 = 1.0)

This matches the way the human eye weights the colors, and perceives the brightness, and it also matches the result on B&W film. B&W film becomes one value of gray, which is luminance.

So.... some RGB value like (5, 10, 200) ...
If you compute luminance (how bright it appears to human eye), it will be

5x0.3 + 10x0.59 + 200x0.11 = 29 (blue is not very bright)

So if you fill some Photoshop frame all with this (5, 10, 200) color,
the RGB histogram will show three spikes at 5, 10, & 200 (overlaid).

And then you convert it to grayscale with the Grayscale menu,
it will become this one 29 value of gray.


People make claims for better converting color images to grayscale using other means than the grayscale menu. For example, using the channels menu.. The Channels menu does provide ways to convert color to modify the gray values to be completely other values (not unlike using color filters in front of B&W film).... and the rest of the people have no clue what they are doing.

If you want the "accurate" way, that is the provided grayscale menu, and the NTSC formula.
 
Joined
May 5, 2005
Messages
24,496
Location
SW Virginia
Can't the D7000 display the three separate histograms?

Certainly. Thus this post.

Quote:

Luminance histograms are more accurate than RGB histograms at describing the perceived brightness distribution or "luminosity" within an image. Luminance takes into account the fact that the human eye is more sensitive to green light than red or blue light. The luminance histogram also matches the green histogram more than any other color.
In order to produce a luminance histogram, each pixel is converted so that it represents a luminosity based on a weighted average of the three colors at that pixel. This weighting assumes that green represents 59% of the perceived luminosity, while the red and blue channels account for just 30% and 11%, respectively. Once all pixels have been converted into luminosity, a luminance histogram is produced by counting how many pixels are at each luminance — identical to how a histogram is produced for a single color.
An important difference to take away from the above calculation is that while luminance histograms keep track of the location of each color pixel, RGB histograms discard this information. A RGB histogram produces three independent histograms and then adds them together, irrespective of whether or not each color came from the same pixel.

I tend to agree relying on the Luminance information only may get you into trouble - how can you tell if an individual channel is clipping?
The other issue is if you are shooting in RAW then as I understand it the LCD histogram is only displaying jpeg which may show clipping that is not actually there in the RAW. I find this a little bothersome!

The RGB histogram (Nikon, Adobe) simply just overlays the three channels. They are not summed, just overlaid, one behind another. One may hide smaller values behind it (often they all show as black), but taller values will extend above to overlook it, and the taller peaks will be visible. This shows contributions of the three RGB channels, but it does not show luminance or brightness.

The Luminance histogram computes a grayscale value, normally from the NTSC television formula from the three RGB components of the pixel, which is Luminance = 0.3 Red + 0.59 Green + 0.11 Blue

(note 0.3 + 0.59 + 0.11 = 1.0)

This matches the way the human eye weights the colors, and perceives the brightness, and it also matches the result on B&W film. B&W film becomes one value of gray, which is luminance.

So.... some RGB value like (5, 10, 200) ...
If you compute luminance (how bright it appears to human eye), it will be

5x0.3 + 10x0.59 + 200x0.11 = 29 (blue is not very bright)

So if you fill some Photoshop frame all with this (5, 10, 200) color,
the RGB histogram will show three spikes at 5, 10, & 200 (overlaid).

And then you convert it to grayscale with the Grayscale menu,
it will become this one 29 value of gray.


People make claims for better converting color images to grayscale using other means than the grayscale menu. For example, using the channels menu.. The Channels menu does provide ways to convert color to modify the gray values to be completely other values (not unlike using color filters in front of B&W film).... and the rest of the people have no clue what they are doing.

If you want the "accurate" way, that is the provided grayscale menu, and the NTSC formula.

Where did you guys find that information? I searched the web quite a bit before I made this post. Thanks for the replies.

That information is helpful, and confirms my habit of relying on the separate RGB histograms for my photography. :smile:
 
Joined
Apr 3, 2006
Messages
5,614
Location
Texas
It's just how it is, it's always been known. Digital cameras have rather corrupted the concept, not much detail remains after B&W film disappeared. Nowadays, they try to explain luminance is brightness per unit area, which is a lighting term, which is not applicable to our histogram. But search Google for luminance ntsc and you will find much specifics. NTSC is the specification for the old standard television. They set the standards many decades before digital images.

Your red/yellow picture for example... luminance is mid range because it is not a bright picture, nor is it a dark picture. It is about middle range. Converting it to (true) grayscale will show that too.

If you want to know how bright it will be on a B&W CRT screen or in a B&W paper print, than that's the luminance histogram. It's also how the human eye perceives it as brightness. Red lipstick is shown darker than green grass for example, but the green probably is higher on the RGB histogram. This used to be important.

But if you want to know if your Red channel is clipping, that is the RGB histogram. But that is not about brightness (perceived by the eye). Clipped red will not be as bright as clipped green.
 
Joined
Jan 15, 2010
Messages
3,985
Location
UK
...Where did you guys find that information? I searched the web quite a bit before I made this post.....:smile:
I cannot speak for others however I have gathered a huge amount of material relating to digital from the net. Of course the biggest danger with this is that just because somebody publishes some web pages or a blog does not mean the information is correct and that they know what they are talking about! - just like taking too much notice of what the press tells us!

In this case I thought I did know the answer but sought confirmation from my files and then decided to quote this as a fairly comprehensive reply. I usually would quote the source as well but in this instance I do not now where it came from. Anyway WayneF seems to confirm this with his explanation and goes further to add numbers.

Wayne, your last comments surprised me somewhat i.e."People make claims...If you want the "accurate" way, that is the provided grayscale menu, and the NTSC formula."
You appear to be saying that the grayscale conversion in Photoshop is the most accurate of any B&W conversion method and by inference do not bother with any other way. Is this your belief?
 
Joined
May 5, 2005
Messages
24,496
Location
SW Virginia
I don't see how the histogram in my sample could be a 0.39 - 0.50 - 0.11 weighted average of the RGB histograms in the upper plot. There would certainly be something under the red histogram showing in the luminance plot.
 
Joined
Jan 15, 2010
Messages
3,985
Location
UK
Not sure I fully understand but guess you are expecting to see a peak of some sort in the luminance histogram somewhere near where the red channel is shown on the RGB version.

My undestanding is that this would not be the case due to the Luminance biased towards the green. Therefore generally the luminance plot mimics most closely the Green channel although it does include the values of the blue and red weighted averaged.

You may find the information below of some interest
http://www.cambridgeincolour.com/tutorials/histograms2.htm
http://www.sphoto.com/techinfo/histograms/histograms2.htm
http://www.ppmag.com/web-exclusives/2007/12/what-is-a-histogram-and-how-do.html
 
Joined
May 5, 2005
Messages
24,496
Location
SW Virginia
Not sure I fully understand but guess you are expecting to see a peak of some sort in the luminance histogram somewhere near where the red channel is shown on the RGB version.

My undestanding is that this would not be the case due to the Luminance biased towards the green.

The bias toward green is reflected in the weighting of 0.5 mentioned in your post and Wayne's above. That won't eliminate the significant contribution from the red channel in the RGB histogram which doesn't show up in the luminance plot.

There has to be more to it than the simple weighting you and Wayne quote.

I'm going to check out your links now, but I think I have looked at some of them already.
 
Joined
Apr 3, 2006
Messages
5,614
Location
Texas
Wayne, your last comments surprised me somewhat i.e."People make claims...If you want the "accurate" way, that is the provided grayscale menu, and the NTSC formula."
You appear to be saying that the grayscale conversion in Photoshop is the most accurate of any B&W conversion method and by inference do not bother with any other way. Is this your belief?

I did not say that. The word accurate is in the sense that it is same as B&W film would reproduce the brightness tones of the colors, or accurate in sense of how the human eyes would perceive the brightness of the tones representing the colors. "THE WAY" that color is converted to grayscale is simply the NTSC luminance formula, period. I said the grayscale menu does that formula, and that B&W film is designed to mimic it too.

The "other ways" of converting color to grayscale are "creative" ways, to produce something other than original truth (altering the original RGB values first). About anything we do in post processing could fall into that class, so "better" is one thing, but "accurate" is another. We didn't like accurate, is why we are post processing. :smile: My comment suggested that we ought to understand the difference.

I mentioned the test of filling the Photoshop frame with one RGB fill color, like 5, 10, 200 (or any one value of RGB). Then look at the histogram and luminance. Then convert it to grayscale, and look again. That is the idea of it, and it will be very instructive to repeat such a test.

My example quoted blue at 200, and 200 is relatively bright on a 0.255 scale. But blue is not very bright to us, and human eyes would perceive its brightness at 0.11 x 200 = 22, instead of brightness corresponding to 200. (simply just look at it in the Photoshop test image). Our film and our eyes would say 200 is not an accurate number. :smile:



I don't see how the histogram in my sample could be a 0.39 - 0.50 - 0.11 weighted average of the RGB histograms in the upper plot. There would certainly be something under the red histogram showing in the luminance plot.

Luminance would have NOTHING "under the red", numerically. No more than any grayscale conversion would show the same "colors". Two different scales. Your red is around 220, relatively bright, relatively near clipping, but it is not "bright" to the human eye, nor would it be "bright" in grayscale.

You are correct in the sense that luminance is not good to detect clipping in the digital RGB channels. But also, the RGB histogram is poor to show brightness our eyes perceive.

The only direct correspondence of RGB to grayscale luminance is the 0.3R + 0.59G + 0.11B. This simply says human eyes see red about 3x brighter than blue, and we see green about 2x brighter than red. The eye in fact has greater response to green, and less response to blue. B&W film tries to mimic that response, in its way, when it converts the color scene tones to grayscale on the B&W film.

When converted to grayscale, we can no longer speak of RGB, there is no RGB. We only see gray then, measured in luminance. Very different system, with very different numbers.

Maybe a similar analogy, if we convert a board six feet long to be a board 2 feet long, we no longer have any number 6 to see or speak of. The number is now 2. And like graycale, there is no going back now, the 6 feet and the RGB values are gone now. Memories at best.

That said, there are people who actually imagine advantage to scan their B&W film in scanner color mode. :smile: Tony is right, we do hear much strangeness on the internet. Yes, scanners do have RGB sensors, but any color cast captured is a problem, not a virtue. Scanners can convert to output grayscale, using the same NTSC formula.

But, we do prefer the grayscale picture to represent red lipstick and green grass and blue sky in a similar way as human eyes perceive their brightness and remember those memories.

This is the definition of panchromatic film (B&W, Panatomic-X for example). Most of us are not old enough to remember earlier orthochromatic film, which was B&W film that was sensitive only to blue and green, and it could even be processed under red safe lights. Blue came out lighter (brighter) and red came out dark (clear).
 
Last edited by a moderator:
Joined
May 5, 2005
Messages
24,496
Location
SW Virginia
The "Cambridge in Color" link provides the best explanation of how the luminosity histogram is computed:

How is a luminance histogram produced? First, each pixel is converted so that it represents a luminosity based on a weighted average of the three colors at that pixel. This weighting assumes that green represents 59% of the perceived luminosity, while the red and blue channels account for just 30% and 11%, respectively. Move your mouse over "convert to luminosity" below the example image to see what this calculation looks like when performed for for each pixel. Once all pixels have been converted into luminosity, a luminance histogram is produced by counting how many pixels are at each brightness — identical to how a histogram is produced for a single color.

This is clearly not the same as simply multiplying the three curves by their individual weighting and adding as I inferred from your first post and Wayne's post. Perhaps I "misinferred":wink:

But thanks for the links. I think I understand it better now.
 
Joined
Apr 3, 2006
Messages
5,614
Location
Texas
The "Cambridge in Color" link provides the best explanation of how the luminosity histogram is computed:

How is a luminance histogram produced? First, each pixel is converted so that it represents a luminosity based on a weighted average of the three colors at that pixel. This weighting assumes that green represents 59% of the perceived luminosity, while the red and blue channels account for just 30% and 11%, respectively. Move your mouse over "convert to luminosity" below the example image to see what this calculation looks like when performed for for each pixel. Once all pixels have been converted into luminosity, a luminance histogram is produced by counting how many pixels are at each brightness — identical to how a histogram is produced for a single color.

This is clearly not the same as simply multiplying the three curves by their individual weighting and adding as I inferred from your first post and Wayne's post. Perhaps I "misinferred":wink:

But thanks for the links. I think I understand it better now.



? I do not understand your comment, since it is exactly the same, the exact same NTSC formula.. ?


In the case of digital, the "multiplication" is done on each pixel, on each of its three RGB components. It is not multiplying the curve, whatever that means. Each individual grayscale pixel acquires one new luminosity value, and gives up three RGB values.

However, it is then drawing a new curve from the processed pixels.

The new data is luminosity data, no longer RGB data.
 
Joined
Jan 15, 2010
Messages
3,985
Location
UK
Wayne, thanks for the clarification on this - I did say I was surprised by what I percieved your statements seem to infer. Therefore it is obvious that I totally missed your point. You can probably gather that I am a fan of using either Channel mixer or B&W conversion when I feel the occasion demands for global correction, alongside using individual channels on their own layers for local correction. My apologies if it appeared that I was putting words into your mouth
EDIT: And I am old enough to remember and have used much Orthocromatic film - in the good old days? !!
 
Joined
May 5, 2005
Messages
24,496
Location
SW Virginia
? I do not understand your comment, since it is exactly the same, the exact same NTSC formula.. ?

No, it's not the same. What I had inferred from you original comments is that to get the composite luminosity histogram I would take the red value at each level (0-255) from the red histogram, multiply the number of pixels there by 0.39 and add it to the number of green pixels multiplied by 0.5 and the number of blue by 0.11.

In the case of digital, the "multiplication" is done on each pixel, on each of its three RGB components. It is not multiplying the curve, whatever that means.

So it is different. But we're arguing semantics here, and I am satisfied that I understand the process better now. Thanks to you both for your help.
 
Joined
Apr 3, 2006
Messages
5,614
Location
Texas
EDIT: And I am old enough to remember and have used much Orthocromatic film - in the good old days? !!

Me too. In the fifties, and early sixties, one of our most major and best photo tips was "always use pan film". :smile: It cost more, and we could not use safe lights, but we did worry about how red lipstick and blue sky came out in the B&W picture.

Film had its own ways, but the numeric conversion specs originate in the first NTSC TV standards, published about 1951. Because, earliest B&W television had to deal with original scenes being in color too.


No, it's not the same. What I had inferred from you original comments is that to get the composite luminosity histogram I would take the red value at each level (0-255) from the red histogram, multiply the number of pixels there by 0.39 and add it to the number of green pixels multiplied by 0.5 and the number of blue by 0.11.

So it is different. But we're arguing semantics here, and I am satisfied that I understand the process better now. Thanks to you both for your help.


No, not semantics. Yes, it is exactly the same 0.3R + 0.59G + 0.11B formula. Where do you think your link got those numbers? (answer, NTSC TV specs, 1951, for converting RGB color to grayscale). There is absolutely zero difference. I am desribing luminance, and telling how to see that in Photoshop (you will understand a lot by looking too). Your link may be telling less, but is showing it in your browser. But it is the exact same thing... called luminance.

No, you do not multiply the number of the pixels. For each and every individual pixel, you multiply that one pixels three RGB components, using this formula - for the purpose to convert it to grayscale luminosity, which is what grayscale images show. This is what your link is doing.

Each individual pixel is the only thing that has the RGB component data values. The neighboring pixels are likely somewhat different values. The histogram simply shows a bar chart of all the new pixel values.

The example was: One pixel at say RGB (5, 10, 200) becomes one gray pixel at (5x0.3 + 10x0.59 + 200x0.11) = 29 luminosity. The data value of this one gray pixel is different now. There is no longer any concept remaining about color or about RGB, it is one gray scale pixel now. If you actually enter those values in Photoshop, and look at the histograms, it should become very clear.

Then the histogram graph similarly plots a bar chart to show how those new pixels values are distributed. That bar chart part is similar graph of all pixels values, but each pixel is now different (grayscale now).


There are trivially different formula numbers today, often ignored in general use.

This link for example: http://en.wikipedia.org/wiki/Luminosity

says: In Adobe Photoshop's imaging operations, luminosity is the term used incorrectly to refer to the luma component of a color image signal; that is, a weighted sum of the nonlinear red, green, and blue signals. It seems to be calculated with the Rec. 601 luma co-efficients (Rec. 601: Luma (Y’) = 0.299 R’ + 0.587 G’ + 0.114 B’).


This is a newer formula, but is hardly different, the actual difference is only
(-0.001R - 0.003G + 0.004B). You will never be able to perceive that difference.

They weight blue very slightly higher now. When they say the "weighted sum", they mean the formula computation.

The difference in terms that they mean may be semantics (the names of things). Luminosity is now considered to be intensity per unit area, for example, foot candles per square meter or something (I dont know, and dont care). They want to reserve the term for that use in lighting. But photography and astronomy has always had other ways. Most words in English have multiple meanings.
 
Joined
Mar 4, 2006
Messages
4,830
Location
Newcastle, Wa
It is good you brought this up Jim. When I am teaching landscape shooting, I always make sure people are looking at the separate RGB histograms. You can make a much better educated decision on what is important and if a channel is blown. I think many folks just use the luminance histogram and may not even know you can see the RGB channels. I have my camera set so the RGB channels pop up after each shot on the camera LCD, people may think I'm chimping the picture, I usually don't even look at that, just a brief check of the RGB histogram as the light is changing.
 
Joined
May 5, 2005
Messages
24,496
Location
SW Virginia
It is good you brought this up Jim. When I am teaching landscape shooting, I always make sure people are looking at the separate RGB histograms. You can make a much better educated decision on what is important and if a channel is blown. I think many folks just use the luminance histogram and may not even know you can see the RGB channels. I have my camera set so the RGB channels pop up after each shot on the camera LCD, people may think I'm chimping the picture, I usually don't even look at that, just a brief check of the RGB histogram as the light is changing.

Agreed. Looking at only the luminous (luminosity?) histogram in my original post, I would have increased the exposure by probably 2/3 stop. But that would have caused the red channel to be completely blown out.
 
Joined
Jul 14, 2008
Messages
3,055
Location
UK
Jim,

That's a very interesting point. It's what you do after you interpret the histogram that matters.

The same can also be said of the WB setting. Having a "wrong" WB set in camera can also cause you to under/overexpose due to your interpretation of the Histogram.

On top of that there is the fact that you are reading the JPEG histogram and not the actual RAW values.

DG
 
Links on this page may be to our affiliates. Sales through affiliate links may benefit this site.
Nikon Cafe is a fan site and not associated with Nikon Corporation.
Forum post reactions by Twemoji: https://github.com/twitter/twemoji
Forum GIFs powered by GIPHY: https://giphy.com/
Copyright © Amin Forums, LLC
Top Bottom