Histograms and Common Exposure Problems
Exposure is the all-important moment when a camera's shutter opens and allows light to reach the film. A camera's exposure primarily controls the brightness and contrast of a shot, but can also influence an image's grain, focus, and the amount of motion recorded. When you work in 3D graphics, it is up to you to simulate the results of a real camera's exposure settings.
This article discusses a number of common problems related to exposure and contrast that can hurt the quality of your renderings if you don't identify and correct them. Your own visual inspection of test-renderings is always the most important way to monitor the tones used in your scene. However, a valuable tool called a histogram can help you double-check your scene's exposure.
A histogram is a chart plotted by the computer to show how frequently each possible tone appears in an image. To see a histogram of your rendering, load it into any paint, image processing, or compositing program that has a histogram function.
Figure 1 shows a typical histogram. For each of the 256 possible levels of brightness in the image (analyzing an image with 8 bits per channel), a vertical column is plotted. The height of each column is determined by the number of pixels in the image that use the tone corresponding to the column. The columns on the left show the number of pixels using black and dark values, the height of the columns in the center shows how many pixels use medium tones, and the height of the columns on the right shows how many pixels use brighter tones, up to pure white on the extreme right.
Figure 1 A histogram plots the frequency of different numeric color values in a rendering. (Head model by Amy E. Medford, from the NURBANA Collection.)
A histogram offers a useful window into your use of different shades in a 3D rendering. The following sections will show how a histogram can help you identify and correct various exposure-related problems. Each section discusses different problems that you can identify with a histogram. Checking a histogram to augment your own visual appraisal of a scene is a valuable skill that will help you maintain the quality of your work, and ensure that your renderings can survive the transition from your monitor to other monitors, film, television, or print output.
A problem frequently seen in beginners' work is overexposure. Overexposed images use only light tones and do not take advantage of the darker side of the available palette.
Without having taken full control over their lights, beginning users often allow too much light to spill everywhere, and end up overexposing every scene they render.
The histogram in Figure 2 indicates an image that is overexposed. The tallest columns are on the extreme right, indicating many bright pixels used in the rendering. The lowest columns of the histogram are on the left, indicating that few black or darker tones are used.
Figure 2 A histogram shows overexposure as a concentration on the right side of the graph.
Unless your entire scene needs to be brightly lit for a specific reason, such as to show a flash of lightning within an animation, you generally should take advantage of the full palette, including dark tones as well as light ones. If your histograms reveal a lack of darker tones in your renderings, you can take several steps to improve your lighting:
Be sure that you are not using too many light sources: Delete any lights in your scene that don't have a clear and specific purpose.
Turn off global ambience, to be sure that no extra light is being added to all the surfaces in your scene.
Restrict the scope or spread of your lights by limiting the falloff range of lights to a specific area or limiting the cone angle of spotlights.
Be sure that shadows are being fully rendered and that you don't have a lighter tone selected for your shadow color or umbra intensity. After adjusting your scene, make a new rendering, and check the histogram again to ensure you are using a full range of tones from dark to light.
If your renderings are overexposed according to a histogram but don't look overexposed on your computer's monitor, be sure there isn't too much glare hitting your monitor or too much light reflecting off the screen, and be sure your display is bright enough to show a full range of tones.
Overexposure is usually an easy problem to fix. Within a few weeks or months, most students learn not to overexpose all their scenes. Sadly, right around the time students start paying attention to their lights, they often trap themselves into making the opposite mistake: underexposure.
The histogram in Figure 3 reveals an underexposed image. The columns of the histogram appear on the left side only, indicating that only the dimmest shades of the palette are being used in this rendering.
Figure 3 A histogram shows underexposure as a concentration on the left side of the graph.
If a histogram reveals that your renderings are underexposed, check your 3D scene for some possible causes of underexposure:
Your lights might have too low an intensity, and some need to be made brighter.
Your lights may be set to attenuate or decay before they reach your subjects, so you may need to increase the fall-off distance or reduce the attenuation.
Be sure that any reflective surfaces have something to reflect, and that there is something to see when you look through any transparent surface. If a surface is surrounded by blackness, then being reflective or transparent would only make it darker.
Lights can sometimes be accidentally shadowed, such as by the light-fixture models that surround them. If one of your lights doesn't seem to be brightening your scene the way it should, check to see if the surrounding geometry needs to be excluded.
Check any global settings, such as depth fading or fog effects, which can sometimes darken a scene no matter how bright your lights appear.
After you have fixed underexposure problems in a scene, you should render it again, and be sure that the histogram shows a full use of the palette, instead of only the dimmest shades.
Optical Effects and Underexposure
A particularly deadly combination occurs when an optical effect, such as a light glow or lens flare, is used in an otherwise underexposed scene. Bright optical effects can make a scene appear to be fully exposed in a histogram, even if the objects themselves are all underlit.
Bright optical effects in a shot make objects that were already murky even harder to see. If you need to add optical effects in a scene, start by making test renderings without the effects to determine if your subject is properly exposed.
A problem closely related to underexposure is banding, also called posterization or contouring. An image with banding problems appears to have distinct steps or bands of color instead of continuous shading. Potential banding problems can be indicated by gaps between the columns within the histogram, as shown in Figure 4.
Figure 4 Banding artifacts are shown in a histogram as gaps between the columns and are especially noticeable on the man's cheek in the rendering.
Banding is often caused by performing excessive manipulation or image processing on an image. This problem commonly appears when you try to correct a dimly lit rendering by brightening the image in a paint or image-processing program. The gaps in the histogram appear because the small number of adjacent shades used in the original image spread out across the palette when you brighten the image. Similar banding artifacts are sometimes caused if an image has been represented with a reduced bit-depth or in an indexed color mode, and then converted back into full color.
You can fix or avoid banding problems in several ways:
Be sure that your scene is fully lit, not underexposed.
Consider adding texture maps to any untextured surfaces. Sometimes even a small amount of color or bump mapping gets rid of banding artifacts.
If you are digitizing images or texture maps with a flatbed scanner, try to adjust the brightness and contrast to your satisfaction within the scanner's control panel, instead of adjusting the image after digitizing.
Give lights a realistic tint, rather than using pure white lights. Staggering the red, green, and blue channels reduces any banding or stepping to one third.
Activate a small amount of dithering, if it is still needed, to avoid any remaining banding artifacts.
Not every gap in your histogram is necessarily a problem. Natural variation in an image sometimes makes more of one tone appear than another. Even if you are not worried about banding, however, the guidelines to prevent banding are good general work habits, and do not take much extra effort to follow.
A histogram that appears concentrated entirely in one area of the palette, as shown in Figure 5, reveals a low-contrast image. When an image uses only tones towards the middle of the palette, without taking advantage of more extreme dark or light tones, the scene can appear faded, or as if you are viewing it through a fog.
Figure 5 A low-contrast scene is shown in a histogram as a concentration all into one narrow area.
Technically, both overexposure and underexposure (as described previously) are types of low-contrast images. An overexposed image is a low-contrast image that uses only the brightest available tones, and an underexposed image is a low-contrast image that uses the darkest available tones. This means that you should start fixing any low-contrast scene by reviewing the overexposure and underexposure checklists earlier in this article.
If your renderings are suffering from low contrast, also be sure that you have clearly defined the source and direction of one key light, and that any fill lights in your scene do not add up to rival or overpower the brightness of your key light.
Low contrast is only a problem if it is unwanted, or inappropriate to your scene. There could be times when you want to intentionally create low-contrast scenes, for example:
Low contrast can help simulate an atmosphere filled with fog, dust, or snow.
Low contrast images can look nostalgic, such as a faded yellow photograph.
Low contrast scenes can appear softer, as with photographs of models shot through gauze.
Low contrast renderings can serve as neutral backgrounds, such as design elements that will be layered behind text in a title sequence.
If you find a low-contrast rendering appropriate for your needs, then you don't always need to consider limited contrast to be a problem. In fact, too high a level of contrast can also be a problem in some scenes.
A histogram that is divided into separate columns of dark and light tones, with very few medium tones in between, indicates a very high-contrast rendering. The histogram in Figure 6 shows the image has almost no shading, only a flat area of white, and a flat area of black.
Figure 6 A high-contrast scene creates a histogram with discontinuous concentration of both bright and dark pixels.
High-contrast images can be used for dramatic effect. A bold, high-contrast image will often help grab a viewer's attention more than a low-contrast image. While maintaining adequate contrast is essential to making a viewable image, too much contrast can mean that portions of the image are hidden in darkness or overexposure, and that shading between the extremes of dark and light is not being used as fully as it could to model the form of your subject. Focus on controlling your level of contrast to create the level of definition you need in a scene, without losing all of the intermediate tones required for full shading.
You can manipulate several factors if you want a high-contrast image.
To achieve high contrast, choose spotlights, instead of omnidirectional lights, to focus your light in concentrated areas.
Be sure your shadows are being rendered with a dark enough shadow color for high contrast, and choose raytraced shadows if you also want a starker edge.
Lights that are set to attenuate rapidly with distance or that use an inverse square falloff pattern, generally contribute to a high-contrast scene.
To raise the contrast, turn off any global ambience in your scene, and use low or moderate amounts of fill lighting.
Be sure to check your image itself if you are verifying the level of contrast, instead of relying solely on a histogram. The histogram will show the use of tones from all over your image, while contrast is most visible where bright and dark tones are placed near each other, with a sharper transition between them.
An annoying problem with digital images is clipping. A digital palette reaches the maximum level of brightness it can represent at pure white, and a minimum level at pure black. Sometimes, in areas of extreme highlight or shadow, the shading of your scene crashes into these limits, beyond which the variation of tones cannot continue.
For example, if an area of your rendering is already pure white, then no matter how much extra light you add, the area will not get any lighter. Any extra light or shading above pure white is clipped down to the brightest displayable value. Figure 7 shows a scene where the white level has been clippedthe histogram builds up to its highest column on the extreme right.
Figure 7 Clipping is represented in a histogram with a sharp "cliff" on the side of the value range.
If you want to take advantage of the full palette, including bright and dark tones, then you can't completely avoid all clipping. At times, having areas of your scene touch pure black and pure white can be desirable, and won't necessarily be a visible problem in your rendering.
Clipping can become very visible, however, if you brighten or darken an image after it is rendered with clipping. For example, Figure 8 shows what the image from Figure 7 would look like if it were darkened in an image-processing program. The area that was previously blown out to pure white has darkened into a uniformly gray area that is unnaturally flat and lacks shading. The problem is that clipping gave all the pixels in overexposed areas an identical pure white value, with no shading or variation. If image processing is used to darken the clipped image file, it can reduce all of the pure white pixels to a uniform gray tone, but it cannot show any of the shading and variation that was clipped away in the original rendering. The same flat, clipped appearance could also result from an area that had been underexposed or pure black in the rendering, then brightened through image processing.
Figure 8 Digitally adjusting the brightness of an image after it is rendered can transform any clipped areas into unrealistically flat regions of the picture.
Pay attention to the level of clipping if you are planning to adjust the brightness of your images after they are rendered. You don't want to tie your hands by blowing out areas you might want to darken later or by completely underexposing areas you might want to lighten.
Every output device has a gamma value that describes the relationship between the signal sent to the device, and the device's final output. A video monitor's gamma describes how different video signal levels correspond to the actual brightness on the screen. A printer has a gamma that describes the relationship between the levels of shading in an image file, and the darkness of the ink it actually applies to the paper.
Once black ink is added to white paper, the paper can start getting dark very quickly. A color value that appears to be halfway between white and black on your monitor might produce a much darker tone on a printed page. If you have developed your renderings by viewing them on a computer monitor, and then want to print them out, gamma correction will usually be necessary. Gamma correction is an image-processing function that adjusts an image to compensate for the gamma of different devices. Gamma correction can be viewed as a curve, plotting a relationship between the original tones of the image and the output tones, as shown in Figure 9. A straight line (as shown on the left side of 9) would indicate no change to the image, with every output tone being identical to every input tone. The curve on the right would increase the image's gamma, making the midtones of the original image brighter.
Figure 9 Gamma correcting for print changes the transition from dark to light using a relationship that can be viewed as a curve.
Changing the gamma can appear to change the brightness of an image. However, it does not necessarily move the black level (the darkest tones used in an image) or the white point (the brightest tones used in an image). The gamma controls the speed of the transition in between the dark and light. Figure 10 shows an image before and after gamma correction for print. Notice how portions of the histogram have been expanded where the gamma curve became steeper, and compressed where the curve had less of a slope.
Figure 10 Histograms before gammar correction (top) and after (bottom) show a shift in the brightness of midtones.
If you make good use of the available palette when initially designing and rendering a scene, then your rendering should be able to survive whatever image processing is applied (either manually or automatically) to output the rendering to more than one medium.
It is a good idea to check your histogram after any image processing change, especially a gamma correction. It is normal to see at least a few gaps appearing in your histogram, from any areas that have been stretched by a gamma correction. This effect should remain relatively minor if you have properly exposed your original image. However, if you have been underexposing your scenes, then you could develop serious banding problems when you gamma-correct for print.