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

Erosion and Dilation of Digital Images

Erosion and dilation constitute two of the fundamental algorithms involved in binary and grayscale digital image processing. These operations are useful for applications such as noise removal, feature delineation, object measurement and counting, and estimating the size distribution of features in a digital image without performing an actual measurement.

The tutorial initializes with a randomly selected digital image of a specimen appearing in the left-hand window entitled Specimen Image. To the right of the Specimen Image window is a linear graph that displays the grayscale histogram of the digital image in the Specimen Image window. To operate the tutorial, select an image from the Choose A Specimen pull-down menu, and select an algorithm from the Choose An Operation pull-down menu. Depending on the algorithm selected, one or more of the vertical sliders located beneath the grayscale histogram window will be activated. The three sliders are entitled Erosion Iterations, Dilation Iterations, and Threshold Level. The settings for these sliders will affect the final appearance of the sample image in the Specimen Image window and the resulting histogram. Visitors should experiment with the settings of the sliders for the various algorithms and examine the effects on the appearance of the sample images.

A binary image is an image whose pixels are turned either on or off. A pixel that is turned on is represented with the maximum brightness value (white; 255), and a pixel that is turned off is represented by the minimum brightness value (black; 0). The following discussion references both binary and grayscale images.

The Threshold Level slider controls the grayscale value at which the sample image is thresholded. Thresholding is an operation that creates a binary image from a grayscale image. When a grayscale image is thresholded at a fixed level, those pixels whose intensity values lie above the threshold level will be turned on (set to white), and those pixels whose intensity values lie below the threshold level will be turned off (set to black). The purpose of thresholding at different levels is to obtain a more precise outline of features and selected region boundaries in a grayscale image before processing the resulting binary image through other techniques.

By utilizing the Grayscale and Binary radio buttons in the tutorial, it is possible to toggle between views of the specimen image in each of these formats. That ensures that operations normally applied to the binary image, such as dilation, erosion, opening, and closing, can be viewed when applied to the grayscale version of the specimen image as well. When the Grayscale radio button is selected, the algorithms utilized for the dilation and erosion operations are altogether different. Dilation and erosion of grayscale images consists of a ranking and replacement operation on pixel brightness values within a neighborhood. To erode a grayscale image, the central pixel of each neighborhood in the image is replaced by the darkest pixel value in the entire neighborhood. To dilate a grayscale image, the central pixel is replaced by the brightest pixel value in the entire neighborhood. The effect of grayscale erosion is to magnify dark regions of the grayscale image and to shrink bright regions. Grayscale dilation has the opposite effect of erosion, magnifying bright regions and shrinking dark regions. In the tutorial, the grayscale histogram illustrates the effects of these various operations on the pixel brightness values of the image.

When an erosion operation is performed on a binary digital image, a selected group of pixels are turned off that were originally turned on. The purpose of this operation is to remove pixels that are not associated with a specimen feature, but which are instead considered as part of the background. The method of classical erosion turns off any pixel that lies adjacent to another pixel that is turned off. This has the effect of removing a layer of pixels from all features and regions, causing shrinkage, which may have the side effect of dividing a singular feature into separate parts. The erosion algorithm is often applied to the problem of estimating the size distribution of features in a digital image. A grayscale or binary image can be eroded repeatedly and, at each step, the number of bright central points in each region is counted. By keeping a record of the number of bright regions that disappear at each step, the size distribution of features can be estimated.

The dilation algorithm has an opposite effect from that of the erosion operation on a binary digital image. Application of a dilation function will add pixels (turn on pixels) that lie directly adjacent to a specimen feature or selected region of pixels having a similar intensity. This process results in the growth of selected regions and features, which may have the side effect of causing formerly separated features to merge together.

The opening operation is a compound transformation that consists of an erosion step followed by a dilation step. The first step is to remove isolated pixels that are part of the background (erosion), followed by a restoration of the original regional boundaries altered by the erosion operation (a dilation step). This method is useful for removing white noise in a binary image, because white noise consists of mostly isolated lighter pixels that appear against a darker background. A series of erosion steps will eliminate the noise, and an equal series of dilation steps will restore the original feature boundaries.

The closing algorithm is also a compound transformation that consists first of a dilation step followed by an erosion step. Isolated pixels that are adjacent to regions of similar pixel intensity are turned on (dilation), followed by an erosion operation to restore the original boundaries that were altered by dilation. This technique has a tendency to fill gaps or breaks that occur between homogeneous regions in a binary image, which can be useful for counting features.

In the tutorial, the Erosion Iterations slider controls how many repetitions of the erosion operation are performed on the digital image in the Specimen Image window. Similarly, the Dilation Iterations slider controls how many times the dilation operation is repeated on the image. When the Opening or Closing algorithms are selected from the pull down menu, the Erosion and Dilation sliders work together to control the number of times these operations are performed on the image. In most instances the application repetition of these algorithms should be approximately equal.

Contributing Authors

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

John C. Long, 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: Tuesday, Jan 10, 2017 at 05:50 PM
Access Count Since March 1, 2001: 12856
Visit the websites of our partners in digital imaging education:
Visit the Olympus Microscopy Resource Center website. Visit the QImaging website.