DILATE Function
Implements the morphologic dilation operator for shape processing.
Usage
result = DILATE(image, structure[, x0, y0])
Input Parameters
image — The array to be dilated.
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.
Returned Value
result — The dilated image.
Keywords
Gray — A flag which, if present, indicates that gray scale, rather than binary dilation, is to be used.
Values — An array providing the values of the structuring element. Must have the same dimensions and number of elements as structure.
Discussion
If image is not of the byte type, PV-WAVE makes a temporary byte copy of image before using it for the processing.
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,
, 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 maximum operator.
You can choose whether you want to use gray scale or binary dilation:
If you select binary dilation type, the image is considered to be a binary image with all nonzero pixels considered as 1. (You will automatically select binary dilation if you don’t use either the
Gray or
Values keyword.)
If you select gray scale dilation type, each pixel of the result is the maximum of the sum of the corresponding elements of
values overlaid with
image. (You will automatically select gray scale dilation if you use either the
Gray or
Values keyword.)
Background Information
The DILATE function implements the morphologic dilation operator on both binary and gray scale images. Mathematical morphology provides an approach to the processing of digital images on the basis of shape. This approach is summarized below.
DILATE returns the dilation of image by the structuring element, structure. This operation is also commonly known as filling, expanding, or growing. It can be used to fill holes that are equal in size or smaller than the structuring element, or to grow features contained within an image. The result is an image that contains items that may touch each other and become one. Sharp-edged items and harsh angles typically become dull as they expand and grow.
note | Dilation 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 expand over time. |
Used with gray scale images, which are always converted to a byte type, the DILATE function is accomplished by taking the maximum of a set of sums. It may be conveniently used to implement the neighborhood maximum operator, with the shape of the neighborhood given by the structuring element.
Used with binary images, where each pixel is either 1 or 0, dilation is similar to convolution. On each pixel of the image, the origin of the structuring element is overlaid. If the image pixel is nonzero, each pixel of the structuring element is added to the result using the logical OR operator.
Letting
represent the dilation of an image
A by structuring element
B, dilation may be defined as:
where (A)b represents the translation of A by b. Intuitively, for each nonzero element bij of B, A is translated by i,j and summed into C using the OR operator.
Openings and Closings
The opening of image B by structuring element K is defined as:
The closing of image B by K is defined as:
where the erosion operator is denoted by θ and is implemented by the ERODE function.
As stated by Haralick et al:
“The result of iteratively applied dilations and erosions is an elimination of specific image detail smaller than the structuring element without the global geometric distortion of unsuppressed features. For example, opening an image with a disk structuring element smooths the contour, breaks narrow isthmuses, and eliminates small islands and sharp peaks or capes.
Closing an image with a disk structuring element smooths the contours, fuses narrow breaks and long thin gulfs, eliminates small holes, and fills gaps on the contours.”
For example, when the origin of the structuring element is at (0,0) it would look like:
0100 0110
0100 0110
1000 1100
0000 0000
Example 1
Figure 5-3: Before and After Image with DILATE Applied shows what an aerial image looks like before and after applying the DILATE function three different times. For this example, the following parameters were used each time:
status = DC_READ_8_BIT(!Dir + '/demo/gallery3/data/aerial_demo.img', aerial_img)
WINDOW, 0, Xsize=512, Ysize=512, Title='Original Image'
TVSCL, aerial_img
struct = [1, 0, 1]
dilated_img = DILATE(aerial_img, struct, /Gray)
WINDOW, 2, Xsize=512, Ysize=512, Title='Dilated Image'
TVSCL, dilated_img
where struct has a value of [1 0 1].
See Also
For details on the approach used in the DILATE function, refer to the source document: Haralick, Sternberg, and Zhuang, “Image Analysis Using Mathematical Morphology,” IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. PAMI-9, No. 4, pp. 532-550, July 1987.