
Mathematical Morphology 291
In the right-hand grid, we have
X
0
= {p}, X
1
= {p, 1}, X
2
= {p, 1, 2}, . . .
Note that the u se of the cross-shaped structuring element means that we never cross the
boundary.
Connected Components
We use a very similar algorithm to fill a connected comp onent; we use the cross-shaped
structuring element for 4-connected components, and the square structuring element for
8-connected components. Starting with a pixel p, we fill up the rest of the component by
creating a sequence of sets
X
0
= {p}, X
1
, X
2
, . . .
such that
X
n
= (X
n−1
⊕ B) ∩A
until X
k
= X
k−1
. Figure 10.25 shows an example.
2 1 2
1
p
1
2 1 2
Using the cross
p
1 1 1
1 1
1 1 1
2
3
3
34
4 4 4