COMPUTER
GRAPHICS
AND
IMAGE
PROCESSING
19,265-280
(1982)
On the Topology Preservation Property of Local Parallel Operations SATORU KAWAI Department
of Information Science, Faculty of Science, University of Tokyo, Tokyo I1 3, Japan
Received July 7, 198 I ; revised August 17, 198 1 Quasi-preservation of topological structures of binary pictures by a group of parallel local operations is considered. The topology is defined in terms of adjacency among binary components. Parallel local operations treated here are allowed to alter the topology only by deleting simply connected components. They also are required to annihilate all components except for the background. The window for these operations is 2 X 2, and is asymmetric with respect to the point whose value is to be calculated at the next step of operation. The group of operations are obtained by determining the necessary and sufficient conditions for a parallel operation to satisfy the quasi-preservation property thus defined. Some other considerations are also given. I. INTRODUCTION
The purpose of this paper is to determine the conditions for parallel operations on binary pictures to have a topology preservation property. There are a variety of definitions of topology of binary pictures which are subsets of the whole set of lattice points in two-dimensional space. Binary pictures themselves are usually represented by a characteristic function whose domain is the set of lattice points and whose range is the set of binary values {not included, included}. We will use 0 for “not included” and 1 for “included,” respectively, in what follows. In terms of characteristic functions, a parallel operation is a mapping from a function to another function, the values of the latter on all lattice points being determined from those of the former. For practical purposes, the mapping is defined locally, i.e., the new value of a point is calculated from those which are “near” the point. The set of “unit distance” points is usually employed. One of the simplest topologies considered in the field of binary picture processing is that defined by the adjacency tree [4]. The nodes of the tree correspond to connected l- or O-components of the picture. The possibly infinite component of the background of the picture corresponds to the root of the adjacency tree. Two nodes in the tree are connected if the corresponding two components are adjacent. Note that we only have a rooted graph from the above definitions, and that we need a proof that the graph is actually a tree [4]. Some local parallel operations are known to preserve the topology of pictures in terms of the adjacency tree [2,3,5-S]. Repeated application of those which are called shrinking operations changes a binary picture from its original form into the final form in which any single deletion of point from some component alters the structure of the adjacency tree. Shrinking operations usually use symmetric windows for the local calculation in order to fulfill the requirement that the picture should be shrunk as evenly as possible. 265 0146-664X/82/070265-16$02.00/0 Copyright 8 1982 by Academic Press, Inc. All rights of reproduction in any form reserved.
266
SATORU
KAWAI
The local operations considered here are different from the usual shrinking operations in that an asymmetric window is used instead of a symmetric one, though the former is included in the latter. The point whose new value is to be calculated is located on the rim rather than at the center of the window. An interesting operation of this type was studied by Levialdi [l]. This operation, which we will call the L-operation, also preserves the adjacency tree of a picture except for the annihilation of single-point components. Given a component with holes, repeated application of the L-operation shrinks the holes as well as the components. After the holes in a component are shrunk to single points, and are then annihilated, the component itself is shrunk to a single point, and then annihilated. By this mechanism, the L-operation shrinks and annihilates any nonbackground component. The adjacency tree is gradually simplified by the deletion of single-point nodes until only the background node (the root) remains. In this paper, we determine the group of parallel operations which use the same window, and do the equivalent job of the L-operation. The topology preservation mentioned above is formalized in terms of the components and the relations among them. The group of operations is obtained by determining the necessary and sufficient conditions for an operation to be equivalent to the L-operation in terms of the topology preservation property thus defined. 2. DEFINITIONS
Let I X I be the set of pairs of integers. A point is a member of this set, denoted by the form (i, j). The four points
(i, j - l), (i, j + l), (i - 1, j), (i + 1,j) are called the 4neighbors 4-neighbors and
of the point p = (i, j). The &neighbors of p are the
(i - 1, j - l), (i - 1, j + l), (i + 1, j - l), (i + 1, j + 1). The 4(8)-neighbors of p are called 4(8)-adjacent to p. Two subsets S, and S, of I X I are 4(8)-adjacent if and only if there exist two points s, E S, and s2 E S, such that s, is 4(8)-adjacent to s2. The concepts of path, connectedness, and component are defined in the conventional way for both 4 and 8 cormectivities [3]. We suppose, in this paper, that one and only one component in any picture is infinite in size. This special component is called the background. We use Cconnectivity for l-components and 8-connectivity for O-components in this paper though the two connectivities may of course be interchanged. A 0- or l-component is called singular when it consists of only one point. A singular l-component is an isolated ‘1’ in the sea of ‘O’s’, and a singular O-component is a hole of minimum size in a l-component. In what follows we will use point names, such as p, q, and r, as variable names which represent the values of the characteristic function at the corresponding points. We define our parallel operations by binary functions (g) of 4-arguments as follows: Ujj
tg(“jj9
Ui,j+lt
ui+l,j3
ui+l,j+l),
where uii = (i, j). This formula says that the new value of a point is determined
TOPOLOGY
PRESERVATION
BY PARALLEL
I(i.
OPERATIONS
267
J
(i,
j)
j+l)
i
I
;c--------; (i+l,
(i+l,
j)
j+l)
FIG. I. Window of the local operation.
from the old values of the four points on the unit square at the “top-left corner” of which the point is located (Fig. 1). Let p* denote the value of p after a single application of the g operation, e.g., aij
*
=
daijT
(li,
j+lY
ai+l,j’
‘i+l,j+l).
Components in the picture are, in general, affected by the application of operations. It may sometimes be difficult to determine the identity of components before and after the operations. We introduce a kind of correspondence to identify which set after the operation corresponds to which before. Given a l-component C, we first define the following three sets: cO={p~pEC,p*=l}, c- = {p Ip E c, p* = O}, C+={PIP~C,P*=l,~4(p)nC#~},
where “4(‘ij)
The new set corresponding
=
Iai+l,
j’
‘i,
j+ll*
to the old C is defined as
c* = co u c+ . It is worth noting l-to-l. There are Components may within the picture
that the correspondence between C and C* is in general not cases in which components are split, merged, and annihilated. be increased in size as well as decreased, or may drift to and fro frame. Even the creation of new components may occur. For a
SATORU KAWAI
268
O-component D, we similarly define the following sets: Do=
{p(pED,p*=O},
D-=
{plpED,p*=
D+=
{pIp~D,p*=O,cw,(p)nD#cp},
I},
D* = Do U D+.
3. THE L-OPERATION
The cardinality
AND THE L-CONDITION
of the 4-argument binary functions is 224 = 65536,
which is also the number of possible different operations in our case. Some trivial operations such as identity, all-clear, and simple shifting are included in this variety. In what follows, we will denote an operation y by the set of 24 = 16 values
where g(aij,ai,j+I~ai+I,j~ai+~,j+*)isdenotedbY
g,, wherek = aij + 2ai,j+l
+ 4ai+,,j
+ 8ai+l,j+l*
A suffix k of a g-value g, is the weighted sum of the 4 inputs within the window (Fig. 2). Each suffix value specifies a certain input pattern. For example, gi1 = 0 means that when the pattern in the window is 1 0 the new value of the top-left
1 1
comer point is 0. By specifying the 16 g-values 1-2
I
I
4-8
0
0
1
0
0
0
0
0
-
0 -
-
FIG.
l-
*--.
1
0
0
1
1
1
1
1
1
1
1
1
-
-
-
-
-
13
14
2. Weights for g-notation and corresponding suffix values.
15
-
TOPOLOGY
PRESERVATION
BY
PARALLEL
OPERATIONS
(go,..., g,,), a specific parallel operation is identified. operation is denoted as go = g, = . . . 1 g,, = 0,
269
For example, the identity
g,=g3=...=g,5=l, and the left-shift operation is denoted as g, = g, = g, = g, = g, = g, = g,, otherwise gk = 1. The L-operation denoted as
mentioned
=
g,,
=
0,
in the previous section is nearly a majority function,
g, = g, = g, = g, = g, = g, = g, = g,, = g,, = ‘3 g, = g, = g, = g,, = g,, = g14 = g15 = 1. With the function g defined as above, the L-operation condition which we call the L-condition [6]:
satisfies the following
Ll : The adjacency tree of the picture is not altered by a single application of the operation in question, except for the changes due to L2. L2: A simply connected component may be annihilated by the operation.
background
(a)
background I
(b) FIG. 3. Deletion merged into C,.
of a leaf with
merging.
(a) Before
the operation.
(b) After
the operation.
C, has been
270
SATORU
KAWAI
L3: The “lifetimes” of all components except for the background are finite, i.e., all nonbackground components should be annihilated by applying the operation sufficiently many times. Simply connected components correspond to the leaves of the adjacency tree. Subconditions Ll and L3 imply, therefore, that the repeated application of an operation which satisfies the L-condition shrinks the adjacency tree from its leaves until only the root (background) remains. Nevertheless, subcondition L2 is essential because there are cases in which deletions of leaves are performed in other ways, as exemplified in Fig. 3. It would be worthwhile to note that Ll characterizes the conventional shrinking algorithms and that the identity operation satisfies both Ll and L2. 4. NECESSARY
CONDITIONS
We will use several “test patterns” in order to obtain the set of subconditions of the necessary condition for an operation, defined by a set of g-values, to satisfy the L-condition. Condition NI Since no new components are permitted to be created (implied by Ll and L2), it is seen that
go = 0, gI5 -- 1. Supposing go = 1, for example, the all-0 picture would be converted to all-l picture and a possibly infinite new l-component would be created. Condition N2 From subcondition
L3, it is seen that
g, = 0, g,,
=
1.
Supposing g, = 1, for example, the pattern which includes only one singular l-component would never be converted to the uniform background even if various subpatterns were created above and to the right of the original point. Note that condition N 1 has already been used here. Condition N3 From the test pattern with an isolated point (TP-1, shown in Fig. 4(a)), we obtain g,
= 1
or g,
=
o
and either
g,=O
or
g,=O.
Otherwise, the original singular component would be divided into two.
TOPOLOGY
PRESERVATION
BY PARALLEL
271
OPERATIONS
'8
'4
'
92
O
0
0
0
0
0
'8
'4
'8
g6
'
92
O
g8
g4
'
92
99
94
0
92
O
(a)
0
(b)
0
0
0
0
0
0
10
0
0
0
0
0
0
0
0
0
0
0
0
1
1110
0
1
0
0
1
0
0
0
0
0
'8
'4
'8
'4
'
92
0
92
0
0
0
912
912
912
O
O
0
1
93
1
95
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
10
Cd)
(e) FIG. 4. Test patterns for necessary conditions. Configurations before and after the operation are shown. (a) TP- I isolated point pattern. (b) TP-2. diagonal pattern- I. (c) TP-3 . diagonal pattern-2. (d) TP-4 two separated points. (c) TP-5.. long horizontal component.
Condition N4 From TP-2 in Fig. 4(b) with two singular l-components S-adjacent, it is seen that
which are diagonally
g, = 0. This is because g, = 1 implies the merging of the two components into one. From the same reasoning as above and with TP-3, we obtain g9
= 0
and either g, = 0
or
g, = 0.
Remember that we use 4-adjacency for l-components.
212
SATORU
KAWAI
Condition NS From TP-4 in which two singular l-components are separated horizontally, obtain g, = 0 or g, = 0.
we
Otherwise (if g, = g, = l), the two components would be merged into one. By rotating TP-4 90°, we obtain the similar condition g, = 0
or
g, = 0.
Condition N6 From N3 and N5, it is seen that only one of g,, g,, and g, may be 1. And we can further proceed to state that g, = g, = g, = 0. Suppose that one of them is 1. Then singular components would travel forever, never being annihilated. Condition N7 By inverting the “polarity” following two conditions:
of TP-4 and from its rotated version, we obtain the
g,, = 1 or g,,=O
and
= g,, = 1;
g,
= 1
g,,
or g,,=O
and
= g,, = 1.
g7
These two conditions imply that only one of g,, g,,, and gr3 may be 0. Then, as in the case of N6, it is seen that g7=g11
=g13
=
1.
Condition N8 From TP-5 in Fig. 4(e), we obtain g, = 1
or
g12
= 1.
Otherwise (g3 = g ,2 = 0) the component in the pattern would be divided into two. By inverting the polarity of TP-5, we similarly obtain g, = 0
or
g,2
= 0.
TOPOLOGY
PRESERVATION
BY PARALLEL
OPERATIONS
213
These two conditions imply that g3+g,*=
1.
Similarly (by a rotation of 90”) it is seen that g,+g,o=
1.
Condition N8 terminates the chain of subconditions. We summarize these subconditions as follows. PROPOSITION1. If an operation y satisfies the L-condition, of y must be as follows:
the “set-of-g”
notation
g,=O,k=0,1,2,4,6,8,9 = 1, k = 7,11,13,14,15, g3+g,2=
1,
g5+g10=
1.
Proposition 1 says that only four operations are possible that satisfy the L-condition. The L-operation is, of course, one of them. 5. SUFFICIENT
CONDITIONS
In this section, we prove that if an operation y satisfies the conditions described in Proposition 1, y also satisfies the L-condition. Such an operation y is assumed throughout this section when we mention Co, C+ , C- , C* and so on. We first consider the relatively simple subconditions L2 and L3 of the L-condition. PROPOSITION2. tion of y.
A nonsingular component S is not annihilated by a single applica-
Proof. Since S is a nonsingular component, there are two 4-adjacent points s and t in S. If s* = 1 or t* = 1 or both, S* is seen to be nonempty. Suppose next that s = t = 0. If s* and t* are horizontally adjacent, the new value of the left point of
them (say s) is one of g,, g,, g,,, and g,, (see Fig. 5). Of these values, only g, can be U
s 7 l-----
t=
0 > l--
0 ) 1
FIG.
---
I
1
5. Proof figure for Proposition 2.
214
SATORU
KAWAI
0. Then from N8 it is seen that g12
Let
=
1.
u be the point above s. Then u* is one of g,2, g,3, g,,, and g,,, i.e., U* = 1. Since ~4b)nS~~
it is seen that u E S*, i.e.,
The case when s and i are vertically adjacent is similarly treated using the condition g, + g,, = 1. Since multiply connected components are obviously nonsingular, Proposition 2 says that y satisfies subcondition L2. PROPOSITION 3. Given a picture, there exists an integer n such that all components except for the background are erased by applying y at most n times.
Proof: Suppose that we have at least one l-component in the O-background. The case of a l-background can be treated analogously. Let R be the minimal rectangle which surrounds the non-background area. Let a and b be the i-values of the top and bottom edges of R, respectively, and c and d be the j-values of the left and right edges of R, respectively (see Fig. 6). We wiIl denote the values of a, b, c, and dafter k applications of y by ak, b,, ck, and d,, respectively (k 10). (1) If g, = 1 and g,, = 0, it is seen that
akz aOy
for
k=0,1,2
,....
Suppose next that we have a run of l’s of length m (> 0) on the bottom edge (i = 6) of R. This run is shortened by y to length m - 1 by deleting the rightmost point in it. Thus it is seen that the run will be annihilated by m applications of y. Considering the fact that the maximum length of the runs on the bottom edge is do-c,+
j=c i=a
i
--
J r 1,
j=d
I
I
= beFIG.
6.
Surrounding
rectangle.
TOPOLOGY
PRESERVATION
BY
PARALLEL
OPERATIONS
275
it is seen that for
b, < b,,
k = d, - co + 1) . . . .
(2) If g, = 0 and g,, = 1, on the other hand, it is seen that k=0,1,2
b, I b, - k,
,... .
As for a, it is seen that ak > a, - k,
1,
k=d,-c,+
from the same reasoning as above. From (1) and (2), we can conclude that b,-a,sb,-a,-
1,
d,-c,Sdo-co-
1,
wherek=d,-c,+ 1. Similarly, we have
wherer=b,-a,+ 1. These two inequalities imply that R is collapsed to an empty set by applying y at least (b, - a, + l)(&, - co + 1) times.
(More precise evaluations would of course be possible.) Regarding Ll, all of the following subconditions must be examined [6, 71: (1) If S is a nonsingular component, S* is a connected component. (2) If S, and S, are different nonsingular components, S: and S,* are disjoint and not adjacent. (3) If C and D are nonsingular l- and O-components, respectively, and if C is adjacent to D, then C* is adjacent to D*. In what follows, we only give a rough sketch of the proofs of the Lemmas because of the combinatorial nature of the complete proof procedures. Lemmas for O-components and l-components must be treated separately because different connectivities are used for each of them. LEMMA 1. Given a l-component C, let xyzw be a 4-path in which two points may coincide, and which satisfies the following conditions: x E c*, ifx E C+
and
y, z, w E c, y E cthen
Then there is a 4-path in one of the forms xu3u*u,zw, xu,.zw,
XUg4IW,
Y E 44.
276
SATORU
KAWAI
or xw,
such that u, E c*, and in case u, E Ci , ifz E C- (in thefirstandsecondfornw), if w E C- (in the thirdform),
z E aq(u,)
w E a4( u,).
Proof. The case y E Co is obvious. Suppose that y E C- , and let us name the neighborhood of y as c ba d’ d Y P P’ e’ e r q q’ e”r’ 9” CASE 1. p = r = 0. It is seen in this case that x f3 C+ since, if x E C+ , x may either be b of d both of which cannot be in C+ . Then, x E Co and z E C imply that c E c*. The required path is
xcz and z( = b or d ) E a4( c) is satisfied. CASE 2. p= l,q=r=o. Since y E C- , it is seen that g, = 0, g,, = 1, and then b E C*. The required path is constructed from the following facts: (i) If p E Co (either x or z), it is seen that p’, q’ E C, and then a E C* from g,, = 1. (ii) If x E C+ , x may only be b. (iii) If z E C- and z = p, the following two cases exist: w = p’. In this case a E C* is seen. w = a. Paths without z are obtained in this case. (iv) If d E C, it is seen that c E C*. Regarding the ‘(Y’ condition after the path conversion, we only have to be sure that the case b = z E C- and p = x never occurs. LEMMA 2.
Given a nonsingular l-component C, C* is a connected l-component.
Proof Let x and y be two points in C*. If x, y E Co, we can convert the 4-path in C connecting x and y into the new 4-path in C* by repeated application of Lemma 1. Note that if we suppose z E Co in Lemma 1, we can obtain the new 4-path regardless of the presence of the fourth point w. If either x or y or both are in
TOPOLOGY
PRESERVATION
BY PARALLEL
OPERATIONS
277
7. Path creation in C.
FIG.
Ci , on the other hand, we start from the 4-path in C between the point x’ (ory’) in q(x) n C and y, or vice versa (Fig. 7). Then we can safely use Lemma 1 for the path conversion because, at the “x-edge” of the original path, x’ E q(x) is satisfied even if x’ E C- . The only one case which is not covered by Lemma 1 is that the original 4-path is xpy and x, y E Cf . It is easy to treat this case. LEMMA 3. Given a O-component D, let xyz be an g-path in which two points may coincide, and which satisfies the following conditions: xED*, ifx E D+ where
and
%@i,)
Y, z E D,
Y E D-3
= @,+,,,+,I
Y E 44
” ‘YdaJ.
Then there is an g-path of the form XII,.
. . u,z
(n = 0,1,2,
or 3)
such that u, E D*, if u, E Df
and
zED-
then
z E 44
Proof Omitted. It is worth noting that the fourth point (w) in Lemma 1 is unnecessary for 8-connectivity. LEMMA 4. Proof.
Given a nonsingular O-component D, D* is a connected O-component.
Analogous to Lemma 2.
LEMMA 5. If C, and C, are different, nonsingular l-components, C: and C,* are disjoint and not adjacent.
278
SATORU
KAWAI
If we suppose that either
Proof
cpn
c,+ z+,
CT f-l c2” ##I, or
cl+nc;z+ holds, we can easily show the contradicting
result
c, = c,. The same is true if we suppose that there exist two points x E Cf and y E C,* such that x and y are 4-adjacent. LEMMA 6. If D, and D2 are different, nonsingular O-components, 0: and 0: disjoint and not adjacent.
Proof.
are
Omitted.
LEMMA 7. If a l-component C and a O-component D are adjacent and if both are nonsingular, C* and D* are adjacent.
Prooj We use the fact that, if C is adjacent to D, either C surrounds D or D surrounds C. This is proved in [4]. CASE 1. C surrounds D. Let y be the uppermost of the leftmost point of the C border of D. We denote the neighborhood of y as c b dy e r
a P q.
Then it is seen that b, c, d, e E C, c E C*, and at least one of a, p, q, and r belongs to D.
If y E Do and one of b or d (say b) is in C- , it is seen that b E D+ and C* is adjacent to D* through the c-b point pair. If y E D- , it is seen that (i) if p = q = r = 1, a E D and then b E Df is derived from g, = 0; (ii) if p = q = 1 and r = 0, g,, = 1 and then d E D’ is derived from g, = 0; (iii) if p = 0, q = r = 1, b E D+ is similarly derived. In any case, C* is seen to be adjacent to D* through the c-b (or c-d) point pair. CASE 2. D surrounds C. Similarly, let y be the uppermost of the leftmost points of the D border of C. Using the same naming of points as in Case 1, it is seen that b, d E D, c E D*, and at least one ofp and r belongs to C.
If y E Co and one of b or d (say b) is in D- , it is seen that b E D+ . If y E C- , it is seen that (i) if p = 1 and q = r = 0, g,* = 1 and then b E Ct is derived; (ii) if r = 1 and q = p = 0, g,, = 1 and then d E C+ is derived. In any case, D* is seen to be adjacent to C* though the c-b (or c-d) point pair. As a result of this chain of Lemmas, we can show the following proposition.
TOPOLOGY PRESERVATIONBY PARALLEL OPERATIONS PROPOSITION4.
279
Operation y satisfies subcondition Ll of the L-condition.
With Propositions 1 through 4, we can complete the proof of the following theorem which is the main purpose of this paper. THEOREM. The necessary and sufficient condition for a parallel operation y on the square lattice to satisfy the L-condition is that y is one of four varieties of operations,
denoted in the “set-of-g”
as k = 0,1,2,4,6,8,9
g, = O,
k = 7,11,13,14,15
= 1, and g,
+
g,,
=
1,
g,
+
g,o
=
1.
.l-l... .
(1)
L-operation
FIG. 8. Four kinds of L-condition g3 = g,o = 1, $75 = g12 = 0. (3) g5 =
812
(g3
. .
.
= g5
. .
=
1,
original pattern
.rr. . 910
= 912
=
O)
shinkings. (I) L-operation (go = g5 = = I, g, = g,o = 0. (4) 810 = g12 = 1, g, =
1, g10= g12= 0). (2) g5 = 0.
280
SATORU 6. CONCLUDING
KAWAI REMARKS
From our theorem it is seen that there are only four varieties of parallel operations within a 2 X 2 window which satisfy the L-condition. Of these four, the L-operation (g,=g,= 1 an d g,, = g,, = 0) is characterized by the “stability” of the minimal surrounding rectangle R used in the proof of Proposition 3. In fact, in the L-operation, it can be proved that every component must shrink to the top-left corner point of its own R. In Fig. 8, we show the ways of shrinking of a small pattern by those four operations. The asymmetry of the values of the g’s (g6 = g, = 0) originates from the dual connectivity scheme. If we adopt 4-connectivity for the O-component and 8-connectivity for the l-component as in the original paper on the L-operation, we obtain instead the condition g, = g, = 1. REFERENCES 1. S. Levialdi, On shrinking binary picture patterns, Comm. ACM 15, 1972, 7-10. 2. C. V. Kameswara Rao, P. E. Danielsson, and B. Kruse, Checking connectivity preservation properties of some types of picture processing operations, Computer Graphics and Image Processing 8, 1978, 299-309. 3. A. Rosenfeld, Connectivity in digital pictures, J. Assoc. Comput. Mach. 17, 1970, 146- 160. 4. A. Rosenfeld, Adjacency in digital pictures, Inform. Conrr. 26, 1974, 24-33. 5. A. Rosenfeld, A characterization of parallel thinning algorithms, Inform. Contr. 29, 1975, 286-291. 6. A. Rosenfeld, Picture Languages, Academic Press, New York, 1979. 7. R. Stefanelli and A. Rosenfeld, Some parallel thinning algorithms for digital pictures. J. Assoc. Comput. Mach. 18, 1971, 255-264. 8. S. Yokoi, J. I. Toriwaki, and T. Fukumura, An analysis of topological properties of digitized binary pictures using local features, Computer Graphics and Image Processing 4, 1975, 63-73.