Histograms and the FluBy Mike Pasini, Editor
Imaging Resource Newsletter
What better time than cold and flu season (epidemic at that) to settle down with warm liquids, next to incandescent light fixtures, and snuggled under flannel sheets to finally come to grips with your histograms? None better than now, we think, particularly if day-time television is getting on your nerves.
Once you've gotten the picture, you'll find that histograms are not only a very revealing tool, but a useful one for making easy improvements to your favorite images.
What is a Histogram?
A histogram is a chart. Period. Just a chart. Like something you might see
in Excel. In fact, it's a bar chart.
So what does a histogram graph?
Well, to make a histogram, your histogram software (usually an image editing program) reads every pixel (that's a picture element, or a spot in plain old English) in your image and counts how many of them are black, how many of them are white, and how many of them are one gray or another.
In short, a histogram graphs your image's luminosity, or brightness.
The bottom axis of the graph (where the Years usually appear in an Excel spreadsheet) represents the scale of luminosity values from black (aka 0) to white (255) with 254 grays in between (don't be fooled by the 0).
The side axis of the graph (where the dollars usually go) represents the number of pixels for each luminosity value from 0 to, well, whatever it takes.
So if you have no white pixels in your image, the right end of the histogram will be flat. And if you have no black pixels, the left end will be flat.
If you have a black-and-white image, you'll have one tall line at the left
end representing all the black pixels and one tall line at the right end for
all the white ones. And if there are twice as many white ones as black ones,
the line at the right end will be twice as tall as the line on the left.
If you have an image that only displays four grays, it will only have four lines.
But when you look at your digicam's image, you should see a very nice mountain range with no gaps. It may not go all the way from black to white, but don't be alarmed -- that can be an asset.
And what about color?
Well, no, there's no color. Really? Yes, really. Luminosity only. Brightness.
But, you can get this information for every color channel of your image. You
digicam records images in three channels: red, green and blue (RGB if you're
working on your vocabulary), and your software can show either the composite
luminosity of all the channels at once, or the luminosity in the red channel,
the green channel or the blue channel individually (which is often the most
Now that you know what a histogram (and annual report graph) is, you probably
want to see one. Not so fast. Your homework assignment is to make one first.
And we have just the place to send you: http://www.hofstra.edu/~matscw/stats/histogram.html,
which is Stefan Waner's Histogram Generator page at Hofstra University.
Play with the value in the top window (change the number of black pixels, for example) and redraw the histogram to see exactly how a histogram works.
What Good is It?
You may have stumbled onto Brightness and Contrast controls or Hue and Saturation options in your image editing software and fumbled with various settings to try to improve a picture that just didn't look as good as you knew it could.
You were working too hard.
Using nothing more than what you already know about histograms, you can enhance brightness and contrast and color correct your images.
There's another advantage to using a histogram to do this: control. If you alter your image using Brightness and Contrast, say 10 percent, you alter every pixel by 10 percent. Using a histogram, you can independently set the highlight, shadow, and (generally) midtone.
But there's also a disadvantage (so don't strut around the neighborhood bragging about histograms). You can only work with those three points (sometimes just highlight and shadow, depending on your software) of the luminosity scale. That's why it's so easy, of course, and fast (and foolproof). But for world domination, you need access to the entire luminosity scale -- and only working with Curves provides that. We'll get you there, but not today. Today we're mastering histograms -- or Levels.
Open an image whose exposure you don't like very much (but that you might call typical of a sunny day) and hunt around for the histogram or Levels command in your image editing software.
Your software may offer an automatic correction. Try it. Untry it. Often it isn't pretty. That's because the software can't see your image. It just sifts through the data, redistributing (or remapping) the pixels in a blind, uniform, proportional, even-handed way. An automatic adjustment only works well if your image just needs contrast enhancement. Otherwise, it's time to get manual.
The first step is to set the black and white points (or shadows and highlights) of the histogram to match the data of your image. Assuming, we hasten to add, that you don't have a night scene or snow scene before you.
Just slide the triangular input slider on the left to the first group of pixels on that side. And slide the triangle on the right to the first group of pixels on that side. You can stop just where they start or a little inside (oh, go inside, be brave!).
What have you done!!?
Well, you've just enhanced the contrast a bit. You've said, hey, map black and a few really dark grays (depending on how far to the right you took that slider) to black, and map white and some really light values to white.
If you did it to the composite image (all the channels at once, which would be the default), you've got the contrast nailed down.
But unless you're working with a grayscale image, you may still have a color shift to deal with.
Adjusting Color With Levels
Take that same magic power and use it with a picture that needs some color
adjustment. Something with green skin tones, say, or yellow room light. You
can do some basic color correction, which often is all that an image needs.
But don't work with the composite channel (or RGB). Instead, look at the channels individually, making our contrast adjustment to each. So select the Red channel and adjust its luminosity, then select the Green channel (it will look different) and adjust its luminosity. Don't be alarmed at the strange color effects until you adjust the Blue channel, too. The blue channel often comes up short on lighter values.
Now you have an image with enhanced contrast whose color is (we hope) more balanced. But you may not be happy with it yet.
When we compressed the tonal scale of each channel, we also shifted the midtone (that middle slider). If your image wasn't high- or low-key (snow or a night scene, for example), this may not be a problem. But if the big bump in your histogram wasn't in the middle, you may not like the color cast you're looking at right now.
We can do something about that.
In most applications, you can adjust the midtone slider too. Dragging the slider for a particular channel to the right (and you may have to do it for each) darkens the midtones (more of them are dark), while dragging the slider to the left lightens them. You'll notice this as a color shift.
That's as fine-tuned as your image gets with a histogram. If that still isn't enough, you're ready for the advanced seminar on curves.
Keeping Output In Mind
Outside the lab (where people do not wear white coats socially), these machinations must be done with a particular output device in mind. Either an RGB screen or a CMYK printer, for example. So the channels may vary, and what's white or black may vary, too. Our simple exercises here are intended to explain the tool, so you can start using it more than dictate its use.
And the more you use it, the less likely you'll be to sneeze at it.
This article is reprinted from The Imaging Resource Digital Photography Newsletter,
Features Column, published January 28, 2000