Petteri's Pontifications
My musings about photography, mostly.
RSS feed


One of the most powerful tools available in post-processing photos is the Levels editor. It displays the picture's levels histogram and allows you to manipulate it with a few simple but effective controls. After this lesson, you will understand what a levels histogram can tell you, and how you can use it to greatly improve the color balance and tonal range of your image. Your pictures will gain a lot of zing: the colors will be brighter, the shadows richer, and the highlights brighter without having lost detail.

What is a levels histogram?

A color picture in digital form is actually a composite of three pictures: one red, one green, and one blue. When these pictures, called channels, are combined, they create the full-color image. Every pixel making up one of these monochrome (single-color) channels has a certain brightness, or level. A levels histogram simply displays the relative amount of each level in the picture. Black is to the left, 100% color is to the right, and the intermediate values are somewhere in between. Using the Levels tool, you can look at the histograms for each of the channels separately, or the "master" histogram (usually marked RGB) where the three channels are combined.

"Good" and "bad" histograms

Different kinds of pictures have different histograms. A picture taken in a blizzard will contain mostly light gray shades: its histogram will show a big peak towards the right, and much smaller amounts of darker shades towards the left. A night landscape will show a big peak towards the left, where the dark shades are, and probably a narrow but high spike representing the bright highlights (stars, streetlights, the moon). The position of the peaks and troughs doesn't really tell you anything very useful.

What is more important, however, is where the histogram starts and where it ends. To the left of the starting point, you will see a flat line: there are no pixels with shades darker than that present in the picture. The same goes for the end point: to the right of the point where the histogram falls back to the bottom level is another flat line: there are no pixels in the picture with shades that are brighter than that point.

Ideally, a histogram should start from zero precisely at the black point -- the leftmost position in the histogram -- and fall back to zero precisely at the white point to the right. This would mean that all of the possible shades that can be represented are present, the shadows fall to a deep black, and the highlights climb to a bright white, but no shades are clipped or cut off.

If a histogram is "cut off" towards the left or the right, it means that the photo has been so badly overexposed or underexposed that information has been lost: areas that could contain detail were recorded as pure black or pure white.

This can happen for a variety of reasons, over- or underexposure being only one of them. For example, it could happen that the scene is so contrasty that the camera just can't capture all the tonal difference. You can easily see this in the histogram: it is clipped at both ends, or clipped at one end with the other end falling to zero very close to the endpoint. This does not necessarily mean that the picture is ruined: for example, on a bright sunny day, you would expect reflections off glass or water to show up as pure, white, bright points; in a night landscape, you'd expect streetlights to appear in the same way.

Normally, however, you should try to expose the picture so that the histogram spreads over as wide an area as possible without being clipped at either end. The D7i's live histogram is a great help to this -- you can control it by changing exposure value (move the histogram left or right) or by adjusting the Contrast setting (bunch it up together or spread it out further).

In practice, you'll often get pictures where there's some flat or nearly flat line at one or both ends of the histogram. This will mean that shadows will be rendered as dark gray rather than black and highlights as light gray rather than white: the image will be lacking in contrast, it'll look flat, and the colors will look muddy and desaturated. In my opinion, Minolta's engineers could've done better when optimizing the histogram in-camera... but that's another story altogether. Still, this is not difficult to fix afterwards.

A note about adjusting levels

Whenever you make a levels adjustment, you change the brightness of pixels in one or more of the three channels. Since there are still only a finite number of possible levels they can take, you will lose information, as some formerly discrete levels get merged with others. You can see this phenomenon in the histogram as "toothcombing:" gaps will appear between the levels, giving the histogram a comb-like appearance. In an 8-bit image, like the JPG's produced by digital cameras, you will have 255 steps between black and white. It has been shown that the human eye can distinguish about 200 levels. Therefore, you can in theory throw out 55 levels without visible damage to the image. However, if you make several levels adjustments, you can easily lose more than this. So, whenever you make a levels adjustment, try to get it right the first time. If you didn't, undo and try again instead of making several small tweaks.

By the way: the big advantage of RAW files is that they have many more than 255 levels per pixel. Minolta RAW is 12-bit: this means that it has over 4000 possible levels. Scanner RAW files are even deeper: they have about 32000 possible levels. In other words, you can do much more dramatic and intricate levels manipulation to them without causing visible deterioration of the image. Still, 8 bits is plenty for most things you'll want to do. Just remember not to be tempted into too much tweaking.

Levels manipulations

OK, so now we know what a histogram is and what it can tell us. Let's move on to things we can do to it with the levels tool. There are three simple but effective things you can do: you can clip the flat parts out of the histogram, making blacks black and whites white, you can set the white balance either by fixing a neutral point or by manipulating the levels individually, and you can set the balance between highlights and shadows. We'll cover these three operations next: select a straight-from-the-camera picture that you like but that looks a bit flat and muddy, open it in your favorite photoeditor, and bring up the levels tool. I've picked this one: a slightly underexposed picture of, you guessed it, a cat.

The levels tool

When I brought up Levels, this is what I got:

Let's look at the box, and identify some of the controls. At the top is the channel selector. Currently the combined channel is shown, but you can also select each of the channels individually. In the center is the histogram itself. Below it is a line with three arrowheads: the black point, the midpoint, and the white point. These are the most important levels controls -- usually referred to simply as "the levels sliders". To the right is a series of buttons, under which are three eyedroppers, a black, gray, and white one, and the preview box. We'll ignore the rest of the controls for now, and concentrate on these.

First, let's look at the histogram. Chances are that it won't be the "ideal" one, with tones covering the entire range from left to right but falling to zero at precisely the endpoints. From this one we can see that the picture is underexposed: there's a stretch of completely flat area to the right, and a longer nearly flat area next to that. (That's actually that cat's nose: we don't want to clip it completely, because that would lose us the detail on it.)


The first thing we want to do is make the darkest tone present in the picture black, and the lightest tone white. In other words, we want to stretch the histogram so that it covers the full range from black to white. This is called clipping, because we're clipping out the left and right edges of the histogram. This will improve contrast and make it a lot snappier. To do this, simply drag the white triangle left and the black triangle right to the points where the histogram leaves the zero level at each end. Note how the picture changes to reflect this.

Note: Often it's entirely OK to clip out parts of the histogram that contain very little data, in this case the single-pixel-thick line that extends from the right end of the histogram. In this case it won't work: by trying it, I noticed that the cat's nose turned completely white and "blown-out," which we don't want.

Setting the highlight and shadow balance

The next thing we want to do is get a nice balance between highlights and shadows. In this case, the picture is still looking a bit dark. We want to lighten the midtones while keeping the highlights and the shadows. In other words, we want to pull some of the left part of the histogram towards the right "elastically," causing the right side to be bunched closer together and the left side stretched further apart. This too is really easy. The gray slider represent the mid-point. Simply drag it towards the left to make the picture lighter (the point to which you've moved it becomes the new midpoint). Left is lighter, right is darker. Observe the image change, and once you've got it looking like you want, leave the midpoint there. Easy!

White balancing

OK, so we've clipped the histogram and balanced the tones. Now we need to white balance it: the picture has a somewhat unattractive yellowish cast to it. We want the cat's white fur to be neutral white. There are two ways to do it: the quick and dirty way and the manual way. Most of the time, the quick and dirty way works just as well as the trickier manual way, but we'll cover both, quick and dirty first.

Quick and dirty...

Look at the eyedroppers. They correspond to the three sliders we just manipulated. They allow you to set the sliders by pointing at a color in the picture. The black and white point sliders aren't very useful in digital photography, as there usually isn't a known baseline to work from. They're more useful for processing film scans, where you can set the black point from the unexposed film stock. We'll ignore them for now. However, the gray eyedropper is very useful. Click on it to select it. Then look for an area in the picture that should be a neutral gray, the closer to medium-gray the better, but light or dark gray usually works too. Click on it. This will set the neutral point to that color and white balance the colors to match. Didn't like it? Click again, on a neighboring pixel, and repeat until you're happy. After a couple of tries, I usually get what I want.

Extra credit: manual correction

I'm a bit of a control freak, though, so I often prefer to do white balancing manually. This isn't difficult either, and it's very slightly more time-consuming. To do this, look at each of the color channels in turn and adjust them by clipping and setting the gray point. Since my picture was on the yellow side, I looked at the blue channel first, clipped a bit more from the right, and dragged the gray point to the left. It was already close to what I wanted, and I only needed to tweak the green and red channels very slightly. Pay attention to the shadows when doing this: if you over-correct with the gray point, you can easily wind up with a color cast in them.

Finishing up

Once you're happy with your corrections, select OK to apply them. If you change your mind, Undo, bring up the levels, and start over. As I mentioned above, it's best to make all your adjustments at one go -- clipping, tone balancing, white balancing -- because multiple applications of Levels will eventually cause visible degradation to the image. But while the panel is open, play to your heart's content: the degradation will only happen once you apply the changes with OK.

This is what I ended up with:

...and its matching histogram:

Note the toothcombing that has been introduced by the operation. At this level, it's not visible (or at least obvious) to the naked eye, but if you were to run a similar operation on the manipulated image a few times, it would acquire a certain "harshness" from it. There's a way to mitigate this, but I'll cover that in a further lesson (if we get that far).

With these very simple techniques, you can dramatically improve the appearance of your pictures and rescue a quite a few "washouts". In a further lesson, we'll look at Curves, which will give you finer control over different parts of the histogram, but for most pictures, Levels is all the tonal control you'll need.


Select a picture with which you're not entirely happy: it looks flat, desaturated, or dark. Open it up in the photoeditor of your choice, and apply the following steps to it as described in the lesson:

  1. Clipping the histogram
  2. Setting tonal balance
  3. Setting white balance

Post the "before" and "after" pictures, and explain exactly what you did and why.