honest.knave

this statement is false

honest.knave header image 2

Digital Photography Basics: Dynamic Range (part 2)

March 10th, 2008 · No Comments

This article is part of a series.

Hopefully you have a pretty good idea of what is meant by the term dynamic range now. Let’s get a little more hands-on.

Histograms

Simple Histogram

Figure 1: An extremely simple histogram.

First, you need to know how to read your image’s histogram. A histogram is a 2-dimensional graph of the frequency a particular value occurred. Remember our 8-bit cameras, with a grid full of pixels whose values could be anywhere from zero to 255? Now it’s time to start inspecting those values.

Imagine a really crappy black & white camera with only a 2-bit range, capable of storing values between zero (black) and three (white). If you took an image with this camera, it would look remarkably like something from the old GameBoy, having only four shades of gray to display. The histogram for that photo might look something like the example to the right.

The histogram displays the number of pixels in the image with each value. So maybe 50 pixels had the value zero, completely black. Then about 25 pixels were a dark gray (value=1), about 75 pixels were light gray (value=2), and maybe 90 pixels were white (value=3). This gives you a sense of what information a histogram is technically conveying, on a very simple level, but we’ll need a better example to start learning how to use histograms to improve our photos.

Real Histogram Example

Figure 2: A real world histogram.

In most cameras and photo editing packages, histograms look more like the one displayed in Figure 2. First of all, there are no numbers or indications of scale. Second, the range of values is much larger than the one above, so the graph looks more like a curve than a bar graph. As a further complication, all three colors — red, green, and blue — are represented on the same graph. Confused yet?

Tip: Here’s how you can see the histogram for your image:

Photoshop: On the main menu, select Window » Histogram.

Gimp: Right click on the image, select Colors » Info » Histogram.

So what is this histogram telling us? It seems that the majority of the pixels are bunched up at the low end of the range, meaning the majority of the picture is composed of darker pixels (including a whole lot of completely black ones). There are a moderate amount of middle range pixels, and then essentially zero bright values. (The lighthouse is definitely overexposed, but it’s such a small amount of pixels that you don’t even see the blip on the far right end of the histogram.)

Spend a minute reading this histogram and comparing it to the image it was derived from (at the left). Do this again when you start working with your own images — pull up the histogram and spend a minute studying it. Get comfortable with what the histogram is telling you, that experience will help you take better pictures in the future.

Note that in an RGB histogram like the one in Figure 2, the colors overlap. You will eventually get familiar with how colors add together, but for now, just know that red + green = yellow, blue + green = cyan, and blue + red = magenta. Areas where all three colors are combined would be white in the image, but for some reason, Gimp decided to use black in the histogram. On cameras that provide a histogram, the background is usually black, so all three colors add up to white, as you’d expect.

Setting black- and white-points

In the previous post, we talked about how the camera’s dynamic range can be too small to fit all the detail into an image. This is particularly common with a high contrast scene, such as the sunny day example. Well, just as often, the range is sufficiently big to capture everything. This happens in situations where you have lower contrast, and your subject(s) are lit relatively evenly.

In this case, you’ll often find that the entire range of brightness fits into your camera’s range, and the histogram shows this in the example below. The top half shows the image as the camera recorded it, and the corresponding histogram. Reading the histogram tells us that the darkest part of the image has a value above zero, and the brightest part of the image is well below maximum. The result is a flat, grayish image, as in the top half of FIgure 3.

Levels Example

Figure 3: Image before and after levels adjustment.

Now you might be tempted to find some kind of “contrast” knob, like you were fixing the picture on a TV. Both Photoshop and Gimp give you a contrast/brightness tool, and you probably found that already when you were trying to fix your flat images in the past. The problem is the contrast tools don’t give you any sense of what you’re doing to the values in the image. You don’t know when you’ve reached the point of clipping in either direction. You also don’t know if you’re still far from that point. You can achieve decent results, but they’ll almost always be less than optimal.

The correct tool to use for this job is the Levels adjustment. The bottom half of Figure 3 shows the image after I’ve adjusted the levels, setting true black- and white-points. You can see that the corresponding histogram has been stretched to fill the entire range of values now, so that the darkest points in the image are truly black, and the brightest points of the image are at the maximum brightness in the image.

The effect is dramatic, and truly brings life back into what was a pretty stale image. In fact, this is generally the first thing I do to any image I plan on developing. Note that you don’t always want to bring the bright end of the spectrum up, it depends on the subject and your goals. But setting a black-point is pretty much universally useful.

To set black- and white-points in your images:

In Photoshop, under the Image » Adjustments submenu, you have several options. You can try Auto Levels, Auto Contrast, and Auto Color, to see if they produce the results you’re looking for. These are the easiest options, but give you the least control. Auto Constrast, in this case, gives basically the result I was looking for. The other options affected the colors too much for my taste, so that the sky lost the reddish hues.

Alternatively, you can select Image » Adjustments » Levels (or hit CTRL-L), and adjust the levels by hand. Then follow the instructions below for Gimp, as the Photoshop levels dialog behaves almost identically.

Gimp Levels

Figure 4: Adjusting levels in Gimp

In Gimp, right click on your image, and select Colors » Levels. In the dialog that appears, slide the two arrows circled in Figure 4 until they frame the range of values in the histogram. I’ve marked the locations I used in this example with red arrows. As long as Preview is checked, you can watch the image change as you adjust the black- and white-points. You can also toggle the Preview checkbox to see how much you’ve changed the image from the original.

After you click Ok, the colors in your image will be scaled to the new range you specified. Values lower than or equal to the left arrow will be completely black, and values equal to or higher than the right arrow will be at their maximum brightness. All the values in between will be scaled proportionally.

Getting to know how the dynamic range affects your pictures is an important step in producing better photographs. As you get more comfortable with histograms, you’ll be able to produce better pictures simply using the histogram display on your digital camera. Additionally, when you get the pictures home, you can create a more pleasing range of values using the “levels” capability of your image editing software.

Tags: photography