Page 118 -
P. 118
92 Chapter 3 ■ Digital Morphology
Not only is this true, but because dilation is commutative, a dilation can also
be considered to be the union of all translations of the structuring element by
all pixels in the image:
(EQ 3.10)
A ⊕ B = ∪ (B) a
a ∈ A
This gives a clue concerning a possible implementation for the dilation
operator. Think of the structuring element as a template, and move it over the
image. When the origin of the structuring element aligns with a black pixel in
the image all the image pixels that correspond to black pixels in the structuring
element are marked, and will later be changed to black. After the entire image
has been swept by the structuring element, the dilation calculation is complete.
Normally the dilation is not computed in place — that is, where the result is
copied over top of the original image. A third image, initially all white, is used
to store the dilation while it is being computed.
3.3.2 Implementing Binary Dilation
The general implementation of dilation for bi-level images consists of two
parts: a program that creates a dilated image given an input image and a
structuring element, and a function that will do the same but that can be called
from another function, and allow dilation to be incorporated into a larger
imaging program. The program, which will be called BinDil, reads the names
of three files from standard input:
BinDil
Enter input image filename: squares.pbm
Enter structuring element filename: simple.pbm
Enter output filename: xx.pbm
whereupon the following output is created:
PBM file class 1 size 3 columns x 3 rows Max=1
BinDil: Perform a binary dilation on image ˝ squares.pbm˝
Structuring element is:
==============================================
Structuring element 3x3 origin at (1,1)
1 1 1
1 1 1
1 1 1
==============================================
PBM file class 1 size 10 columns x 10 rows Max=1
All three arguments are filenames:
squares.pbm is the name of the image file that contains the image to be
dilated.