Microscopy Primer
Light and Color
Microscope Basics
Special Techniques
Digital Imaging
Confocal Microscopy
Live-Cell Imaging
Photomicrography
Microscopy Museum
Virtual Microscopy
Fluorescence
Web Resources
License Info
Image Use
Custom Photos
Partners
Site Info
Contact Us
Publications
Home

The Galleries:

Photo Gallery
Silicon Zoo
Pharmaceuticals
Chip Shots
Phytochemicals
DNA Gallery
Microscapes
Vitamins
Amino Acids
Birthstones
Religion Collection
Pesticides
BeerShots
Cocktail Collection
Screen Savers
Win Wallpaper
Mac Wallpaper
Movie Gallery

Interactive Java Tutorials

Contrast Enhancement and Histogram Specification

Contrast enhancement of a digital image can often be performed by modifying the histogram either automatically or interactively. This tutorial explores how image contrast can be enhanced in both cases by employing algorithsm that specify individual properties of the image histogram.

The tutorial initializes with a randomly selected specimen (imaged in the microscope) appearing in the left-hand window entitled Specimen Image. To the right of the Specimen Image window is an Image Histogram graph that displays the gray-level histogram of the Specimen Image in a vertical bar format (black lines), and the cumulative histogram function as a red curve. To operate the tutorial, select a specimen image from the Choose a Specimen pull-down menu, and choose a corresponding a histogram specification method from the Choose a Histogram pull-down menu. The Editable Histogram technique, which is one of the choices available in the Choose a Histogram pull-down menu, can be employed to interactively modify the cumulative histogram function. When this method is selected, a blue control curve is displayed in the Image Histogram graph.

Translatable point nodes may be inserted into any location in the cumulative histogram curve by clicking on the desired location with the mouse cursor. The added nodal points, including the endpoints, may be moved by dragging and dropping them anywhere within the grid of the Image Histogram graph window. The control curve will be updated while the point is being dragged, but all other components of the tutorial will be updated only when the point is dropped. Points may be removed from the curve by dragging them outside of the grid. Visitors should observe the effects that various histogram modification techniques incur on the appearance of the Specimen Image and its corresponding histogram.

The gray-level histogram of a digital image contains useful information pertaining to overall image contrast. The range of gray-levels that are occupied in the image histogram, referred to as the dynamic range of the digital image, is related to overall image contrast. If the range of histogram gray-levels is limited, then the corresponding digital image dynamic range is also restricted, resulting in poor image contrast. In order to enhance contrast, the dynamic range of the image should be increased to include as many gray-levels as possible.

One disadvantage encountered with a majority of contrast enhancement algorithms is that these techniques often necessitate user intervention for each set of images that require contrast enhancement. An algorithm that can be automatically utilized to increase the contrast of low-contrast images, with excellent results, is known as histogram equalization. This operation relies on a pixel brightness transformation to reassign image brightness values based on the image histogram. The cumulative histogram function (plotted in red on the histogram graph) assists in illustration of the histogram equalization operation on a digital image.

The cumulative histogram function is defined as the percentage of pixels whose brightness levels are less than or equal to a given brightness level. In the original histogram, the cumulative histogram function often appears as a more or less erratic curve whose rate of increase varies with the distribution of pixel brightness values in the histogram. In the equalized histogram, the cumulative histogram function will approximate a straight line. This occurs because the histogram equalization operation is designed to ensure that the cumulative histogram function increases at a uniform rate. As a result, the corresponding equalized histogram will have a uniform distribution among the full range of gray-levels, thereby increasing the dynamic range of the image and its overall contrast.

The histogram equalization algorithm operates by transforming the brightness value of each input pixel, n, to its corresponding output pixel brightness value, n', according to the rule:

where the sum is taken over N(i), the number of histogram entries with brightness level less than or equal to n, and where N is the total number of pixels in the image. This equation assumes that the range of possible brightness values is the interval [0, 1], although typical imaging hardware utilizes an 8-bit grayscale range of [0, 255].

In the tutorial, the Specimen Image can be equalized by selecting the Equalized Histogram option in the Choose a Histogram pull-down menu. The effects of histogram equalization are manifested in the Specimen Image by an overall increase in image contrast and brightness. Histogram equalization generally improves the visual quality of low-contrast images, and is particularly good at revealing features that were previously obscured in dark regions. Histogram equalization can degrade the quality of images that do not require contrast enhancement, and often induce posterization of gray-levels or an appearance of overexposure.

Although histogram equalization is quite useful for automatic contrast enhancement, it cannot be used to adjust image contrast interactively. This occurs because the technique only generates a single result, which is an approximately uniform histogram. For certain applications, however, it is desirable to specify the shape of the image histogram. A good example is the comparison of two images that have been captured under different conditions of illumination. Instead of modifying an image histogram, an alternative algorithm can be employed to specify a desired cumulative histogram function. The histogram software can be used to draw and manipulate the desired curve, and when the algorithm is applied, the new cumulative histogram function will represent a close approximation to the desired curve. Depending upon the shape of the curve, the resulting histogram can be shifted, compressed, or expanded, providing considerable control over image contrast and brightness.

The histogram specification algorithm operates by determining the inverse of the desired curve, and applying these values to the levels of the equalized histogram. (If the function corresponding to the desired curve has no inverse function, then a pseudo-inverse function can be constructed which closely matches the properties of the desired curve. One method for constructing a pseudo-inverse function is to acquire the level that is closest to the mean of the desired histogram for each ambiguous value on the curve). As an example, if the desired curve is a function g(r), where r represents a brightness level in the range [0, 1], then each equalized pixel's input brightness value, n, is transformed to a corresponding output pixel brightness value, n', according to the rule:

where N is the total number of pixels in the image. The sum is taken over N(i), the number of equalized histogram entries with a brightness level less than or equal to g(-1)(n).

In the tutorial, an arbitrary cumulative histogram function can be specified by selecting the Editable Histogram option in the Choose a Histogram pull-down menu. Visitors should experiment with different types of curves by adding control points to observe the effects of control curve changes on the image, the histogram, and the cumulative histogram function. If the curve shown in blue is always increasing, then the cumulative histogram function, shown in red, will generally match the control curve very closely. If the control curve decreases anywhere on the graph, then the cumulative histogram function will differ from the control curve. This is because the cumulative histogram function represents a sum of non-negative numbers, and therefore can never decrease.

Contributing Authors

Kenneth R. Spring - Scientific Consultant, Lusby, Maryland, 20657.

Matthew J. Parry-Hill, and Michael W. Davidson - National High Magnetic Field Laboratory, 1800 East Paul Dirac Dr., The Florida State University, Tallahassee, Florida, 32310.


BACK TO DIGITAL IMAGE PROCESSING TUTORIALS

Questions or comments? Send us an email.
© 1998-2022 by Michael W. Davidson and The Florida State University. All Rights Reserved. No images, graphics, scripts, or applets may be reproduced or used in any manner without permission from the copyright holders. Use of this website means you agree to all of the Legal Terms and Conditions set forth by the owners.
This website is maintained by our
Graphics & Web Programming Team
in collaboration with Optical Microscopy at the
National High Magnetic Field Laboratory.
Last modification: Wednesday, Mar 22, 2017 at 10:14 AM
Access Count Since March 8, 2001: 6594
Visit the websites of our partners in digital imaging education:
Visit the Olympus Microscopy Resource Center website. Visit the QImaging website.