Histogram
In a color photo each pixel has a value (0-255) for each color. The histogram above shows the distribution of pixel values for each color (red, blue and green), Where they overlap the secondary colors (magenta, cyan and yellow) show, finally the areas that have all three colors are shown as gray.
A histogram is a bar graph. We use histograms in photography to show how many pixels of each value there are in a photograph. Each pixel in your photo has a value from 0 (which is black) to 255 (which is white). The left side of the graph represents the black end of the scale and the right side represents white.
The picture on the right, a color histogram, shows the distribution of all the colors in the picture separately. Whilst this may be of interest to a very advanced Photoshop user, us mere mortals will get all the information we need from the luminosity histogram such as the ones shown below.
The luminosity histogram, as the name suggests, shows the combined value of each pixel on one graph. So we can see at a glance whether the photo is too dark or too bright.
The Problem
You might think that the best way to see if the picture is too dark or too bright would be to look at the image itself, after all, we can see it there on the screen thanks to the magic of digital photography.
The trouble with doing that is that the image that you see will vary according to how bright the screen is (they are often adjustable or indeed self adjusting) and how bright the ambient light is. If you view your camera screen in bright sunlight it is going to look very different to when you view it in the dark.
The best way to see if a picture is correctly exposed is to look at the histogram. Most decent DSLR cameras have a histogram option that you can look at when reviewing the picture. Find out how to turn it on and use it to judge your more critical shots, or at least the first one in a series.
Judging the Histogram
It is quite easy to see when a picture is well exposed, the histogram will have large columns in the mid-rage and little or no information at either end. Take a look at these three pictures together with their histograms.
The first one shows us the correctly exposed picture. The histogram tails off to nothing at the highlight end, telling us that there are almost no pure white pixels in the picture. At the shadow end (left) the drop off is quite steep and there are a few pixels in the photo that are pure black, but basically we have captured as much information as we can from this scene. When the scene contains more contrast than our camera can handle, we can't capture it all in one shot, so we have to make a compromise. It is better to have a few shadow areas that are completely black than to have burnt out highlights, which are much more noticeable.
The picture above, as you can see, is badly under exposed. The pixel distribution is bunched up down the shadow end and there are virtually no pixels with a value greater than mid-gray. Although we can lighten this shot up in Photoshop, the problem is that, when you have a a large number of pixels with a value of 0 there is no differentiation between them. All we can do is spread out the values that are greater than zero, which will make the picture very contrasty. It is much better to capture all the information (ie different pixel values) you can, in the camera.
Finally, in the over exposed version, you can see that we have a large number of pixels with a value of 255 (white). No matter how much darkening you do in Photoshop, you can't differentiate between one white pixel and another, so the detail in the highlights is lost forever.
Capturing the Maximum Amount of Information
Hopefully you can see from these examples that making a correct exposure, where a very few pixels are pure white and a very few are black as in the first example, records the maximum amount of detail from the scene to your camera.
If you later choose, for artistic reasons, to discard some of this detail, that's OK, but it is much better to have it all in the first place.
There are a few techniques to help you get the best exposure, such as bracketing and exposure compensation, but it is important to be able to read a histogram.