Implements the morphologicerosion operator for shape processing.
structure The structuring element. May be a one- or two-dimensional array. Elements are interpreted as binary (values are either zero or nonzero), unless the Gray keyword is used.
x0 (optional) The x-coordinates of structure's origin.
y0 (optional) The y-coordinates of structure's origin.
Values An array providing the values of the structuring element. Must have the same dimensions and number of elements as structure.
The optional parameters x0 and y0 specify the row and column coordinates of the structuring element's origin. If omitted, the origin is set to the center, (Nx / 2 , Ny / 2 ), where Nx and Ny are the dimensions of the structuring element array. However, the origin need not be within the structuring element.
Nonzero elements of the structure parameter determine the shape of the structuring element (neighborhood).
If the Values keyword is not used, all elements of the structuring element are 0, yielding the neighborhood minimum operator.
You can choose whether you want to use gray scale or binary erosion:
Briefly, ERODE returns the erosion of image by the structuring element, structure. This operation is also commonly known as contracting or reducing. It can be used to remove islands smaller than the structuring element.
The result is an image that contains items that now contract away from each other. Features that either slightly touch or are connected by narrow areas may disconnect, becoming separate, smaller objects. Any holes or gaps in or between features become larger as the features in the image shrink away from each other. Sharp-edged items and harsh angles typically become dull as they are worn away; however, in some cases areas that were dull may become somewhat sharper as a feature erodes away.
TIP: Erosion can be used to change the morphological structure of objects or features in an image to see what would happen if they were to actually shrink over time.
Used with binary images, the origin of the structuring element is moved to each pixel of the image. If each nonzero element of the structuring element is contained in the image, the output pixel is set to one.
Letting A represent the erosion of an image A by structuring element B, erosion may be defined as:
where (A)-b represents the translation of A by b. The structuring element B may be visualized as a probe which slides across the image A, testing the spatial nature of A at each point. Where B translated by i, j can be contained in A (by placing the origin of B at i, j), then Ai, j belongs to the erosion of A by B.
img = ERODE(aerial_img, struct, /Gray)
struct
has a value of [1 0 1].
Figure 2-33 The ERODE function has been used to "wear away" the visual elements of this 512-by-512 aerial image.
Figure 2-34 The ERODE function has been used to "wear away" the visual elements of this 512-by-512 aerial image.