﻿ Building Blocks of Spatial Analysis > Grid Operations and Map Algebra > Erosion and dilation

# Erosion and dilation

Erosion and dilation, in the context of grid operations, refer to morphological operations applied to binary and grayscale images. These are terms commonly used within image processing but only arise in a small number of GIS packages in this context. Erosion involves the removal (alteration) of pixels at the edges of regions, for example changing binary 1 values to 0, whilst dilation is the reverse process with regions growing out from their boundaries. Buffering is a form of dilation.

These two processes are often carried out using a form of kernel known as a structural element. A structural element is an NxN kernel with entries classified according to a binary scheme, typically as 0 or 1. If all entries are coded 1 then the structural element is a solid square block, the center of which is laid over each pixel in the source image in turn. Pixels that are coded as 1 in the structural element and extend beyond the boundary of a shape in the source image result in that element being extended or dilated. The shape of the structural element may vary, for example as a vertical bar, horizontal bar, cross shape or a user-defined pattern.

To illustrate this process we have taken a small section of a USGS DEM file and then applied dilation and erosion processes to this source. The results are shown in Figure 4‑83A-C.

Figure 4‑83 Dilation and erosion operations

A. Source DEM section

B. Dilation: 9x9 structural element, 9x3 vertical bar

C. Erosion: 9x9 structural element, 9x3 vertical bar

If dilation is followed by erosion the process is described as a Closing operation, whilst Erosion followed by dilation is known as Opening. These processes are not symmetric, and thus are generally not reversible. Opening eliminates small and thinner features, resulting in smoother edged regions, whilst Closing also smooths shapes but makes thin narrow features larger and eliminates small holes and narrow gaps. These changes are the result of deliberate morphological modification of the source data files. However, similar effects may be observed as a result of transformation operations performed manually or automatically for other purposes — for example resampling (changing resolution), rotation, multiple overlay, or map algebra operations.