# How is tonal range of a colored image mapped to a scale of 0-255 in RGB histogram?

RGB histogram (as displayed by Adobe Photoshop) of a colored image maps the available tonal range to a scale of 0-255 (pure black to pure white on horizontal axis). Tonal range, the way I understand, is the range of all possible color values which is represented using 24 bits, ignoring gamma. For histogram of individual R/G/B channels, it's much more intutive as I presume an 1-to-1 mapping of tones. But, how is that 24 bits of information mapped to 8 bits in RGB histogram?

For photoshop CC, Window -> Histogram -> All Channels View brings up the Histogram dialog with a drop-down menu allowing to select RGB, Red, Green, Blue, Luminosity, Colors. RGB histogram is different from Luminosity histogram as the example shows. I am keen to know how RGB histogram is being computed from the source image. This is the one (not the Luminosity histogram) is primarily shown with Curves adjustment tool.

• Recommend closing because it's unclear what you're asking. Look: you can map colorspace into RGB wth as many bits for each of the layers as you want. "tonal range" has no quantifiable meaning. Commented Jul 16, 2016 at 13:47
• how is 24 bits of information compressed into 8 bits x 3 (RGB) = 24 bits? where is the compression? Commented Jul 16, 2016 at 13:53
• @szulat I changed "compressed" to "mapped" Commented Jul 16, 2016 at 13:56
• There is no "RGB histogram". There is an R, a separate G, and a separate B histogram, all three shown on one diagram. R, G and B are each 8 bit values. There is no "compression" happening. Commented Jul 16, 2016 at 13:58
• Although the meaning has gotten a little murky recently, historically the use of "tonal range" or "tonal value(s)" is in reference to the overall luminance or brightness range, not to the range of colors or hues. Please see this question for more: photo.stackexchange.com/questions/72730/… Commented Jul 17, 2016 at 1:21

I have found the following link explaining the RGB histogram. Note that it talks about the Adobe Photoshop RGB histogram.

It basically states that the RGB histogram is just the addition of the R, G and B histograms, and so as it is, a very misleading histogram. It is not a histogram of luminosity or similar quantity.

Are you are asking about that single line, usually white or gray, 0-255 histogram that is generated from three 0-255 RGB values?

One way to do it is to display luminance. You take the RGB values of an individual pixel and calculate luminance using formula

 Y = 0.2126*R + 0.7152*G + 0.0722*B


Or similar depending on the actual RGB color space. Then you draw single Y histogram instead of three RGB

• You are the ONLY person who properly understood my question. Thanks. Commented Jul 16, 2016 at 17:21
• I have updated the question. I can see that RGB histogram is different from Luminosity histogram. Commented Jul 17, 2016 at 2:45
• Please note that luminance and luminosity are two different things. To calculate luminosity histogram look at Lab color space and how the values are converted from RGB. You would be looking at the L value. @Holmes.Sherlock Commented Jul 17, 2016 at 3:22
• I think that it is good to note that the formulae depends on the colour space of image. IIRC Photoshop prefers to use RAW image data for many things. Commented Jul 18, 2016 at 10:25
• @EuriPinhollow. I updated the answer, thanks for your comment. Wrt. Photoshop and raw data, regular Photoshop does not work with raw data, raw data must be converted in ACR before PS recognizes them. I believe PS uses the color space the image is actually in. Lightroom histogram of raw images is based on color space with ProPhoto RGB primaries with sRGB tone response curve. Non-raw files in LR show histogram based on its native color space. Commented Jul 18, 2016 at 16:11

Our images NEVER ignore gamma. All tonal image data (color and grayscale have many tones) contains gamma (except 1-bit line art does not need or use gamma). But Every One of our tonal histograms shows only gamma numerical values. Gamma was to correct nonlinear CRT displays. LCD displays technically do not need it, but we continue to put gamma into every image for compatibility with the worlds older images and older video systems. That's much easier than starting over. :) LCD simply decodes it before we see it. Gamma is in no way related to the human eye response as some newbies would tell it. Gamma is to correct CRT display.

The camera digitally samples the image, normally with 12 bit sampling. That means the original data range is [0..4096], not [0..255]. Every tone goes into one of these steps, converted to one of these numbers. Then gamma is applied.

But then JPG files are all 8 bits (as is our video and printer systems), so to convert to 8 bits (24 bit color), each 16 bits of [0..4096] is changed to one step of [0..256]. This is a simple truncation to only the 8 most significant bits.

• 1. does not answer the question 2. incorrect about gamma being only useful for CRT and not LCD Commented Jul 16, 2016 at 15:50
• Exactly HOW does gamma help LCD? Precise details please. However, yes, I do know you cannot provide any meaningful answer. LCD use a LUT to decode gamma first, then they simply show the original linear reproduction, which they could have done without gamma. Commented Jul 16, 2016 at 16:08
• gamma correction usefulness does not depend on a particular display technology. this was true in analog tv and is still true for digital. gamma encoded brightness level has a nice property of being (nearly) perceptually uniform (equal signal changes correspond to equal perceptual differences). sending "gammaless" picture to a screen would use over 30 bits to display things that look to our eyes like the current 24 bit screens (effectively wasting bandwidth, processing time and energy). see also: cambridgeincolour.com/tutorials/gamma-correction.htm Commented Jul 16, 2016 at 16:34
• I am asking, HOW does that happen? You did not and cannot answer, it does not happen. I know about Cambridgeincolor, it is very wrong about this too of course. No one can explain HOW that can possibly happen, since it doesn't happen. Gamma is always decoded first, the eye NEVER EVER sees any gamma data. The eye needs to see only the same linear reproduction of what the lens saw. And it always does see the linear reproduction. Anything else would just be distortion. I will offer this: scantips.com/lights/gamma.html (much detail is there) Commented Jul 16, 2016 at 16:43
• of course we do not want to display the gamma-encoded data without decoding it first. but since you mentioned "the eye" - it reacts to the linear brightness but sends the gamma-encoded data down to the brain! that's why the gamma-distorted data feels so natural to us. it even touches the original question: try and see how the 8-bit RGB histogram nicely shifts when changing picture brightness. the "true" raw histogram (without gamma correction) does not behave this way, it is alien to our senses ;-) Commented Jul 16, 2016 at 16:57

A black and white picture made by a film camera is referred to as a “continuous tone” image. This is because the image is comprised of countless shades that go from white thru black with a smooth transition of tones.

When these images are migrated to books and newspapers, the procedure used, is to re-photographs them through a screen. The screen resembles a common window screen in that it consists of tiny squares. This process fractures the continuous image into countless dots; each has a discrete size based on the darkness or lightness of the image at that location. This image is called a “halftone” because a high percentage of the tones of the original are lost.

In modern times we fracture the picture into a grid consisting of millions of tiny fractions of the picture. Each of these picture elements or pixels is assigned a numerical value that communicates to the darkness or lightness of this tiny area of the picture. We call this process digitizing as the word “digit” corresponds to number, it is Latin for finger, we and do count on our fingers.

The digits used by the computer are only the 0 (zero) and 1 (one). We transmit them from place to place as a string of zeros and ones. A single such digit is called a “bit”. We generally send them in groups of four. The group of four digits is called a “nibble”. Two “nibbles” consist of eight digits and this group is called a “byte”. The 8 bit byte is used to transmit any value between 0 and 255 = 256 discrete values. In other words each pixel can have 256 levels of brightness.

A satisfactory monochrome image can be transmitted via sending thousands, perhaps millions of 8 digit bites. Digital photography is truly a paint-by-number scheme. Next we needed a way to send color images by digital transmission.

The first color picture was made by the Scottish physics James Clerk Maxwell in 1861. He had experimented with colored light and deduced that we see via light sensitive receptors that are sensitive to red, green, and blue light, the “primary” colors. He made the first color photographic image by taking three black and white photographs. One uses a red filter, one with a green filter and one with a blue filter. He projected and superimposed these three black and white images. Each image was projected thru the filter used to take the picture. Using this method, he showed the world the first color photograph and proved that color pictures could be taken using the three primary colors, red, green and blue.

Modern photography uses Maxwell’s three color theory. Our cameras actually take three pictures simultaneously. These are digitized by the camera. Three digital signals are transmitted, one 8 bite red image, one 8 bite green image and one 8 bite blue image. Now 8 X 3 = 24. The total count is 24 bites per pixel to send a color picture. Sometimes we say the digital pixel consist of three sub-pixels, one for each of the three primary colors.