The backlog of photography-related posts for this blog is now almost as long as the virtual pile of half-written IT-related ones but I’ve been meaning to write something about histograms in relation to digital photography ever since Andy Gailer‘s presentation on working with raw digital camera images at my local camera club last year.
For the first few years that I owned a digital camera, I ignored the histogram – quite simply because I didn’t understand it. Since Andy explained it to me, I find it an incredibly useful tool for helping me ensure that I’ve captured the maximum amount of data in my images.
The histogram, quite simply, shows 256 levels of light (tones) that are present in an image. The peaks indicate a large volume of pixels in a particular tone and the troughs appear where there are fewer pixels. On the left side of the histogram are the dark areas and on the right side are the lighter areas.
Take, for example, the accompanying picture of a post box outside a gift shop. As can be seen, I took this after a snow fall and I didn’t compensate for the light reflected by the snow. Even though the camera’s automatic white balance would have attempted to make some corrections, the snow shows as grey and the histogram tells me that most of the pixels occur in the darker areas to the left of the graph.
My camera will show me a histogram but if I view this in Adobe Photoshop, I can see a little more detail. As well as some statistical data about the mean levels and the standard deviation, I can hover my mouse pointer over the graph and see how many pixels appear for a given level. In this case I can see that at level 247, there are only 24 pixels (out of more than six million in the entire image) – effectively there is very little happening in the highlights.
By adjusting the levels, I can alter the highlights (white slider), midtones (grey slider) or shadows (black slider) and improve the overall exposure of the image. Effectively, I set the black and white points and adjust the contrast.
The ideal histogram is evenly distributed with no breaks and a gradual tail off for shadows and highlights. If I hold the Alt key (Option key on a Mac) as I preview the adjustments, I can see the pixels which are being clipped from the image and I should stop just before this become noticeable (Adobe Camera Raw will show clipping as blue or red pixels when this option is enabled). A few points to note are:
- Over-exposed images will have clipped highlights and under-exposed images will exhibit clipping in the shadow detail.
- The vertical scale is of no real consequence (it’s just an indication of the number of pixels at any given light level).
- Clipping is effectively throwing away part of the detail in the image and should be avoided where possible although it can be used to effect (e.g. as a deliberately high- or low-key image).
- By adjusting the midtones, the overall brightness of the image may be altered without clipping.
- Low contrast images will have a very narrow histogram, whilst high contrast images will cover more of the graph.
- Techniques such as high dynamic range (HDR) photography (and tone mapping) can be used to increase the light levels captured in the image – effectively increasing the exposure latitude.
- For finer control, individual histograms may be viewed for red, green and blue colour channels or the luminosity.
In this example, I have adjusted the highlight details by moving the white slider from 255 to 203 (and Photoshop has automatically adjusted the midtone levels for me). The end result is a picture which appears to be better exposed although looking at the histogram tells me that there is some detail missing from the shot now (effectively 42 levels have been cut out and the remaining 204 levels of light have been redistributed across the scale – hence the gaps in the graph). These gaps/spikes are an indication of a phenomenon known as image posterisation (or banding) which is not very evident in this image but can generally be spotted in areas of shadow, or the sky, caused by a reduction in the bit depth of the image.
There are those who will say that image adjustment using levels is a very crude tool; however it’s useful to demonstrate how to read histograms. Hopefully this post has thrown some light onto what is one of the more technical aspects of digital photography but is also a very useful tool.