Sticky

#### TUTORIAL: The histogram

What's the histogram?

OK, so you got that shiny new DSLR and started playing with the buttons. You had a look at the different displays on the back, stepping through the different available views of the pictures you've taken. One of these views looked a bit technical, with a funny-looking graph. That's the histogram.

Some cameras show the histogram as a display in its own right, while some show it as part of a screen-load of technical details with the histogram itself only taking up part of the screen. The bigger the histogram, the easier it is to read and make sense of, but even a small one is useful.

OK, so if it's a graph, what do the horizontal and vertical axes represent? The horizontal axis is lightness and the vertical axis is the relative frequency of pixels in the image. The left-hand end of the horizontal axis represents the bottom limit of lightness (i.e. black) and the right-hand end of the histogram represents the top limit of lightness (i.e. white). Both ends represent the limit of useful data (you can't get darker than totally black and you can't get lighter than totally white).

What does the histogram look like?

Want to see some examples? There are loads of articles illustrating this stuff already available on the internet, and I'll point you at a reasonable one. By all means read the whole article, but the main thing for now is to get a feel for what the histogram looks like for some typical situations. Take a look at this article, concentrating on the section in the middle entitled "Typical Histogram Examples", then meet me back here.

OK, hopefully that made some sense and you would now be able to predict the main tonal features of an image if you saw its histogram. That is, from a histogram, you should be able to make broad assessments such us that the associated image was generally underexposed, or that the image is mainly dark but with some much brighter areas.

Why is this stuff useful?

Experienced and competent photographers will often sneak a quick look at the LCD after a shot. This quick glance at the LCD is not to check the focus (the LCD is nowhere near good enough to do that accurately) or to check the composition (it's an SLR, so you've already seen the composition through the viewfinder) but to check the exposure. But how do you check exposure on the LCD? The apparent brightness and contrast of the LCD screen will vary dramatically with the surrounding lighting conditions; on bright days it can be very hard to see the screen clearly. You can alter the display brightness, but this just adds to the confusion; is the image bright because it's overexposed or because you have the LCD brightness turned way up? For these and other reasons, looking at the image on the LCD screen is a very unreliable way of judging whether the image is underexposed, overexposed or about right. So what are these experienced guys glancing at? You guessed it; the histogram. To do this yourself, all you have to do is set your camera to automatically display shots on the LCD for a few seconds after you take them (this might be the camera's out-of-the-box behaviour anyway) and change the LCD review settings to show the histogram. This way you can shoot and then, if you want to check the exposure, just give a quick glance at the histogram.

This is where I have to use a technical photographic term you might not have come across before. Sorry to hit you with all this complicated terminology, but this one's very useful. The term is "chimping" and refers to the act of checking your LCD screen after taking a shot. To execute a textbook "chimp", you should ideally point at the screen with a curved forefinger while going "Oooh oooh oooh... aaah aaah aaah....".

Whether or not the act of quickly checking the histogram after a shot counts as true chimping is a very hot topic; one of the most heated sociolinguistic issues in modern photography.

What could I do if the exposure is wrong?

The examples you looked at earlier included a "correctly exposed" case, as well as one with "too much" contrast and one with "too little" contrast. You might infer from this that the first exposure was "correct" and the ones with too much or too little contrast are somehow "incorrect" exposures of the same scene under the same lighting conditions. That is not the case. For a given scene under given lighting conditions, there is nothing you can do about the shape of the histogram; you can't compress or stretch the curve or alter the relative position of multiple peaks. All you can do is shift the whole histogram left or right by your choice of exposure settings. But remember the limits of useful data; if you increase your exposure, the whole histogram will shift to the right until the right-most peak starts to disappear off the right-hand end of the histogram. (Actually it doesn't disappear but all piles up in a very very narrow column at the right-hand edge.) Parts of the image represented by this part of the histogram will be "blown" (i.e will be so overexposed that they contain no useful data). Underexposing works in the same manner, but involves a shift to the left. If stuff piles up at either end of the histogram in this way, the remaining data will be presented as a flatter distribution, but this is just the result of a re-scaling of the vertical axis of the histogram to make it possible to include the very narrow but very tall peaks at the ends of the horizontal axis. These peaks represent the increased number of pixels that are either totally black (the left-hand end) or totally white (the right-hand end).

There are many ways of adjusting the exposure. You can change the shutter speed or the aperture, or you can apply an exposure compensation. See your camera manual for how to do this stuff. (You could also use a higher ISO sensor sensitivity, but that would be quite an unusual way of doing it.) You get the idea by now that increasing the exposure will shift the histogram to the right, and decreasing the exposure will shift it to the left.

An obvious question is...

What should the histogram look like?

There is no right answer to this question. The histogram is what the histogram is, and there are just too many possible situations to consider in this short tutorial. Anyway, I can't tell you what result you're after; all I can do is show you how the histogram can help you control your camera more accurately. We'll just consider a typical scene under typical lighting conditions (whatever that means) which produces a histogram that sits comfortably within the left-hand and right-hand limits of the scale. In such a case, the exposure of the image could be decreased (shifting the histogram to the left) or increased (shifting the histogram to the right) without immediately bumping into the ends of the scale. This situation will probably the one that applies for most of the everyday pictures we take (and is actually the one described as having "too little contrast" in the examples we saw earlier). For most purposes, our question can then be re-expressed as "where should the histogram sit within the left-hand and right-hand limits?"

The answer is: it's up to you. That's probably not a lot of use to you, I agree, but it probably will be more useful to consider a less common but more extreme case, one where there is more likely to be a naturally "correct" answer. In addressing this issue, it is important to remember that...

... and that's regardless of how much it cost. To prove it, take a close-up picture of a pile of coal, or a close-up picture of a pile of snow. Unless you're in fully manual mode, both pictures will come out grey. And in both cases, the histogram will be a fairly narrow band in the middle of the horizontal range.

How can that possibly make sense?

The range of tones in both cases will be quite narrow; all black or near-black in the coal picture, and all white or near-white in the snow picture. (Remember that the field of view in the pictures is completely filled with either coal or snow.) The range of tones that the camera can record is called its "dynamic range". Because the coal/snow only uses a small selection of these available tones, the populated part of the histogram is quite narrow.

Now bear in mind that your camera doesn't have any general knowledge about the world. It knows nothing about snow and coal; it just works on the assumption that what's in front of the lens is a standard level of lightness. It expects a scene composed of nothing but coal to be that standard level of lightness, and it also expects snow to be that same standard level of lightness. (For non-beginners: this principle applies regardless of the metering mode you're using; it makes no difference whether you're using matrix, centre-weighted or spot metering.) As I told you, your camera is stupid. To be fair to the camera, how could it possibly tell well-lit coal from snow on a moonless night? It actually has no choice but to make the assumptions that it does.

So we end up with a narrow distribution (caused by the small range of tones) in the middle of the histogram (caused by the assumption of a standard level of lightness).

So if you want your snow to appear white rather than grey, you're going to have to shift the histogram to the right. (If you want your coal to appear black rather than grey, you'd have to shift the histogram to the left, but we'll work through the snow example because shifting the histogram to the right is a much more common thing to do.)

A more technical aside... it is usually stated that most cameras' metering systems are based on the assumption that the world is a standard 18% grey, but this statement might not actually be true.

How do I shift the histogram to the right?

You can probably answer this yourself by now; you increase the exposure. You can do this by opening the aperture wider, using a longer shutter speed, or applying a positive exposure compensation. It seems counter-intuitive to increase the exposure when shooting a bright subject like snow, but that's what you have to do if you want it to appear white.

How far should I shift the histogram to the right?

That depends. A typical requirement would be to have the very brightest parts of the snow to appear white (or very near-to-white) but to retain the ability to distinguish tonal differences between this bright snow and snow that is slightly less bright. (Remember that although the populated part of the histogram is very narrow, it's not a vertical line; there is some tonal variation in the image. To get this result, you would have to increase the exposure so that the right-hand edge of the populated part of the histogram just kissed the right-hand end of the histogram scale. This would mean that the very lightest parts of the scene were being recorded as total white.

In practice, the easiest way to increase the exposure by the appropriate amount is to meter on the scene (or, preferably spot-meter, on the very brightest part of the scene) and then add a standard exposure compensation. A compensation of +1.7 usually works well for my Nikon D70. This usually nudges the histogram nicely over to the right-hand edge. Another technical aside... as well as getting nicely white highlights in snowscapes, this technique is more generally applicable and is known as "exposing to the right".

A slight qualification

When I say you can't change the shape of the histogram, that's not strictly true. (So I lied; sue me.) Your camera's settings will provide a certain amount of control over image contrast when shooting JPEGs. That's equivalent to doing some very crude post-processing and it will effect the histogram to some extent. I personally don't shoot JPEGs anyway, choosing to shoot RAW instead, but that's a whole other story. You can also change the histogram radically during post-processing, but this tutorial is only considering stuff you can do in-camera.

But I will make...

a quick comment on post-processing

"Post-processing" refers to manipulations you do to the image after you've got it onto your computer. It is also often called "image manipulation". This would involve the use of special image editing software, such as Photoshop, Paintshop Pro, The Gimp etc. The term Photoshop is often used generically as if it's a verb e.g. "this picture has been Photoshopped".

Especially in the context of post-processing, people will refer, as I just did, to editing the histogram. This is because advanced post-processing software provides tools to stretch, shrink and distort the histogram directly. This can give the impression that the histogram is somehow a thing in its own right. It's not, it's still just a convenient representation of the distribution of tones in the image. So "editing the histogram" is just shorthand for "editing the tonal distribution in the image by using a software control in the form of a histogram". This tutorial doesn't cover how to do such post-processing, and the histogram is a useful tool even if you intend to do no processing at all. Indeed, an accurate exposure, which the on-camera histogram can help you achieve, can reduce the need for post-processing.

I hope you found that interesting and useful. You can find out more stuff about histograms by following these links:

www.photographyreview.com/histogramguidecrx.aspx
www.cambridgeincolour.com/tutorials.htm
www.luminous-landscape.com/tutorials/understanding-series...
www.picturecorrect.com/photographytips/digital_camera_his...
www.sphoto.com/techinfo/histograms/histograms4.htm

[Edited for a few typos.]
It's a good tute, Gary.
And thanks very much for the links.
Richard
Great stuff. On histograms, I am trying to capture a high-rez histogram to print alongside the final image for a project. I wrote to Nikon but they claim you cannot export histograms. Anyone know of any tools that would allow this while on this subject?
Maybe do a screen print of one from your image editing program.
Richard
Gary, I am impressed!

Maria
@ Jer I recently took a picture on my laptop, of the histograms, when in the Picasa viewer. Not the best of histograms, but I think that if you shoot in RAW, you could use the better ones, out of Photoshop.

Have a look in the thread called: ASSIGNMENT 4 "Tutorial Lightmeter" CONCEPT.

Not the most advanced way to save a histogram, but it could help...

@ Gary Jones: excellent tutorial, so many great things to learn on this group...

Mike.
Thank you Gary Jones. Fantastic information. The digital world - my head spins.
Why cant you just shoot in raw and avoid most of this crap sense there is no such thing as a perfect histogram!
There may not be a perfect histogram crap... but the goal is to have a perfect exposure and not rely on RAW to compensate for a poorly executed technique. Of course I shoot both RAW and JPEG and use the RAW when I screwed up the exposure, but hopefully, one day, with all the tutorials in this group, including the Histogram, I will be able to use only JPEG...Thanks again Gary
Mike
Thanks a bunch, but you haven't actually explained what the GRAPH meant....... what the the x and y axis represent? good tutorial by the way
@ howangcturtle From the tutorial:
"OK, so if it's a graph, what do the horizontal and vertical axes represent? The horizontal axis is lightness and the vertical axis is the relative frequency of pixels in the image. The left-hand end of the horizontal axis represents the bottom limit of lightness (i.e. black) and the right-hand end of the histogram represents the top limit of lightness (i.e. white). Both ends represent the limit of useful data (you can't get darker than totally black and you can't get lighter than totally white)."

The Y axis is the number of pixels ( the higher the peak the higher number) and the X axis is the brightness. To the left is black to the right is white...
Have a look at the 4 graphs in "ASSIGNMENT 4 "Tutorial Lightmeter" CONCEPT" thread and you will notice a graph shifted to the right for the overexposed picture. An underexposed picture will have the peaks shifted to the left.
I hope this helps.
Mike
eokip1...

"Why cant you just shoot in raw and avoid most of this crap sense there is no such thing as a perfect histogram!"

You can shoot in RAW, as I do all the time, and still find the histogram a useful tool. I didn't go into this stuff in the tutorial because I thought it was an inappropriate level of detail, but, when shooting RAW, a JPEG image is automatically produced and stored as part of the RAW file. The on-camera histogram then represents the distribution of tonal levels in this JPEG image rather than in the original RAW image. This does not affect the usefulness of the histogram when shooting RAW. It just means you can take into account the extra leeway of shooting RAW when considering the histogram; you might find when you come to convert the RAW data that some highlights that were borderline-blown according to the camera's on-board histogram aren't actually blown at all in the RAW data.

Did I actually say that there was such a thing as a "perfect histogram"? Well, kinda. I made an indirect such claim by referring to the article on exposing to the right. This explains how a digital camera's imaging system stores a disproportionate amount of the potential data at the bright end of the dynamic range. Half the available lightness levels are stored in the brightest "stop". If you don't make use of this brightest stop (i.e. if you have no pixels in the stop-worth of lightness levels at the right-hand end of the histogram) then you are failing to make use of fully half of the lightness levels your camera can store. This can have serious implications if you want to adjust levels in post-processing; the data just won't be there to provide the range of tones you might want, and you'll end up with unwanted "posterization" effects.

There's a good Adobe white paper on this stuff written by RAW guru Bruce Fraser (PDF here). The key sentence from the Adobe article is...

Correct exposure is at least as important with digital capture as it is with film, but in the digital realm, correct exposure means keeping the highlights as close as possible to blowing out, without actually doing so. Some photographers refer to this concept as “Expose to the Right” because you want to make sure that your highlights fall as close to the right side of the histogram as possible.

The histogram is only a guide to what your camera has done, but it's a very useful guide because it provides rough but quantitative information on the nature of the exposure. It is entirely up to the photographer how, or if, to make use of that information. There cannot be a perfect histogram without perfect knowledge of what the photographer wants to achieve, but under the particular circumstances described above, where the photographer wants to maximise the amount of useful data being captured, the histogram can be used to guide the taking of what could be deemed a "correct" exposure. In this sense, there can indeed be a perfect histogram for a given subject under given lighting conditions.

Similarly, in the snow example I discussed in the tutorial, I would argue that if the photographer wants the brightest parts of the image to be true white, then the appropriate position of the histogram is for the right-hand end to be almost but not quite blown. That would also be a "perfect" histogram, if you like.

But maybe this is all crap, too.

howangcturtle,

"Thanks a bunch, but you haven't actually explained what the GRAPH meant....... what the the x and y axis represent?"

As vizugonesailing has just pointed out, I did indeed, very explicitly, address those points. I'm sorry if I didn't do it clearly enough.

[Edited for a couple of typos.]
Groups Beta