Up until now, we have only been talking about histograms for black and white, or greyscale, photographs. However, most photographs make use of color.
In black and white photographs, a pixel value is represented by a single value that is directly related to the % grey value of the pixel. To refresh your memory, see figure 1 in section 1 of this article. However, in color photographs, a pixel value is actually a set of three values: red, green, and blue (or RGB for short). Each one of these values is also referred to as a channel (e.g. the red channel). All of the colors that can be produced by a computer screen or captured by a typical camera are represented using some combination of values for these three channels. The value for each channel can have a value ranging from 0 to 255.
For color photographs, there are a number of ways in which the displaying of histograms may change. The first way one can display a histogram for color images is to combine all the channels of the color pixel value using some function and then just display a single histogram that looks similar to a histogram for a greyscale photograph. However, how one combines the values from each of the channels is important. At first, it may seem tempting to simply average the red, green, and blue channel values to calculate the equivalent grey value, which is then used to place the pixel in the histogram. However, this type of calculation ignores the fact that the human eye has a different level of sensitivity to the colors red, green, and blue. Of those three colors, the human eye is most sensitive to green and least sensitive to blue. Therefore, as simple average isn't sufficient. Instead, a weighted average needs to be used, with the value in the green channel having the highest weight, and the value in the blue channel having the lowest weight. Such weighted averages tend to produced better results than simple averages when converting a color photograph to a greyscale photograph.
Another way in which a color histogram may be presented is to display multiple histograms, one for each channel. This is a straight forward way to display the data. However, it leaves it to the viewer to imagine what the overall brightness of the photograph is. For example, considering the discussion of using simple versus weighted averages to calculate greyscale values above, exactly how bright is a photograph with the majority of its pixels have high blue values, but lower green values?
My Nikon DLSR display uses both the first and second methods for displaying histograms when reviewing a photograph in camera. It displays a combined histogram along with separate histograms for each of the red, green, and blue channels.
Another approach is the approach used by Camera Raw. Camera Raw displays a single histogram that is in color. A separate histogram is created for each of the color channels, as was the case for the second approach. However, instead of displaying each of them in a separate histogram, they are overlaid on top of one another. The red channel is drawn in red, the green channel is drawn in green, and the blue channel is drawn in blue. As the histograms overlap with one another, the colors are combined, creating a colorful histogram. The magenta color is produced when only the blue and red channels overlap, the yellow color is created when only the green and red channels overlap, cyan is created when only blue and green values overlap, and white is created when all channels overlap. Figure 1 is an example of how Camera Raw displays histograms for color photographs.
Just like greyscale images, color images can have filters applied to them, such as the curves filter we previously discussed in previous sections of this article. However, there is an extra consideration to keep in mind when manipulating color photographs. Remember that for greyscale images, the maximum value for a pixel is 255. If a modification to the photograph would push that value above this limit, the value is instead clipped to, or maxed out at, the value of 255. In greyscale photographs, there is only a single channel (the % grey value). However, in color photographs there are three channels, each of which can have their values clipped to a value of 255. So, what happens when a single manipulation or filter causes one of the channel's values to be clipped, but not the others? The answer is that it can affect the hue and saturation of the pixel in question.
Figure 2 illustrates how the hue of a pixel can drift as the brightness of the pixel is increase. On the far left of the figure, the original color starts with an RGB value of (128, 192, 32). As one moves right across the figure, the value of the pixel is being multiplied by the values above the respective boxes. By the third box (i.e. by the time the RGB values are being multiplied by 1.4), the green channel is being clipped to the maximum value of 255. Once this occurs, multiplying by greater values increases the amount of red and blue, but not the amount of green in the pixel's color. By the time RGB value is being multiplied by 2.0, the red channel has also maxed out. As a result, the green red channels have the same value and the resulting color is shade of yellow instead of green, even though they did not have the same value in the original color.
To avoid a problem like this, one can reference the histogram for each of the channels for a given photograph. From the histogram, one can see how far values within the channel can be adjusted before clipping, either high or low, begins to occur. On cameras that display color histograms for photographs, the photographer can check to see if one or more of the channels are being clipped. If this is a problem, the photographer will know right away and can retake the photograph before leaving the location. There are few things more frustrating for a photographer than getting excited about a digital photograph you have taken, only to find out that the exposure isn't quite right once it is viewed on a screen that is better than the camera's LCD screen.