The Number of Gaps in Binary Pictures Valentin E. Brimkov1 , Angelo Maimone2 , Giorgio Nordo2 , Reneta P. Barneva3 , and Reinhard Klette4 1
Mathematics Department, SUNY Buffalo State College, Buffalo, NY 14222, USA
[email protected] 2 Dipartimento di Matematica, Universit` a di Messina, 98166 Messina, Italy {angelo.maimone, giorgio.nordo}@unime.it 3 Department of Computer Science, SUNY Fredonia, Fredonia, NY 14063, USA
[email protected] 4 CITR Tamaki, University of Auckland, Building 731, Auckland, New Zealand
[email protected]
Abstract. This paper identifies the total number of gaps of object pixels in a binary picture, which solves an open problem in 2D digital geometry (or combinatorial topology of binary pictures). We obtain a formula for the total number of gaps as a function of the number of object pixels (grid squares), vertices (corners of grid squares), holes, connected components, and 2 × 2 squares of pixels. It can be used to test a binary picture (or just one region: e.g., a digital curve) for gap-freeness. Keywords: digital geometry, 2D binary pictures, gaps, gap-freeness.
1
Introduction
This paper identifies the total number of gaps of object pixels in a 2D binary picture, which are defined in analogy to the topological concept of tunnels. Tunnels in topology are rather counted than identified; the number of tunnels is a topological invariant. In 2D or 3D binary pictures, gaps have been defined based on separability properties, and the total number of gaps is also a property characterizing the “topological” structure of a binary picture. Gaps in 3D binary pictures have also been studied in the context of rendering voxelized scenes [5]. Arising questions are, for example, as follows: is a binary picture gap-free or it has gaps of certain type. This is particularly interesting when dealing with digital curves or surfaces in image analysis and geometric modeling. With this in mind, our objective was to obtain a formula for the total number of gaps based on basic parameters of a 2D binary picture (such as the number of object pixels, vertices, holes, or connected components). Results of this kind belong to the area of combinatorial topology, which originated with the Descartes-Euler formula α2 − α1 + α0 = 2 that (in its first occurrence) combined the number of vertices (α0 ), edges (α1 ), and facets (α2 ) of a convex polyhedron. For results in combinatorial topology in the context of image analysis, see Chapters 4 and 6 in [7]. G. Bebis et al. (Eds.): ISVC 2005, LNCS 3804, pp. 35–42, 2005. c Springer-Verlag Berlin Heidelberg 2005
36
V.E. Brimkov et al.
The main result of this paper is the formula g = v − 2(p + c − h) + b, where g is the number of gaps, v the number of vertices, p the number of pixels, h the number of holes, c the number of connected components, and b the number of 2-blocks (i.e., 2 × 2 pixels squares) of all object pixels in a binary picture. This equality implies corollaries for the important cases of simple digital curves, simple digital arcs, or for the general case of digital curves. The next section introduces basic notions and notations. Section 3 presents our main results, including a proof, and we conclude in Section 4.
2 2.1
Preliminaries Basic Definitions
In this section we recall some basic notions of digital geometry following [7]. The reader is also referred to [1, 2, 8, 11, 15]. A regular orthogonal grid subdivides R2 into unit squares called pixels, that are centered at the points of Z2 . A unit square is a 2-cell (note: “2” as “twodimensional”), whose frontier contains four 1-cells (edges) and four 0-cells (vertices). Two non-identical pixels are called 0-adjacent iff they share a vertex, and 1-adjacent iff they share an edge. We identify a binary picture S with its finite set of object pixels (e.g., all those having value 1 in the picture). We use 0-adjacency for object pixels, and 1-adjacency for non-object pixels. It is known that this corresponds to a topology on binary pictures, where 0-adjacency defines closed sets, and 1-adjacency defines open sets [7]. In the following definitions, we have k = 0 or k = 1. A k-path in S is a sequence of pixels from S such that every two consecutive pixels on the path are k-adjacent. Two pixels of a digital object S are k-connected (in S) iff there is a k-path in S between them. A subset G of S is k-connected iff there is a k-path connecting any two pixels of G. The maximal (by inclusion) k-connected subsets of a binary picture S are called k-components of S. Components are nonempty, and distinct k-components are disjoint. Let M be a subset of a binary picture S. If S \ M is not k-connected then the set M is said to be k-separating in S. Now let M be a finite set of pixels that is k-separating in Z2 (note: k = 0 or k = 1). The infinite 1-component of Z2 \ M is called the background component of M , while the other (finite) 1-components of S \ M are called 1-holes of M (see Fig. 1). Let a set M of pixels be 1-separating but not 0-separating in a digital object S. Then M is said to have 0-gaps (see Fig. 1a, top-left). For a set M of pixels that is not separating in another set of pixels we can identify a gap with a vertex that is incident with two and only two pixels of M , and it is the only common point of these two pixels (see Fig. 1a, top-right). A digital object without any 0-gaps is called gap-free (Fig. 1a, bottom). 2.2
Pixel Language
To facilitate the further description, below we present a simple graphical language (similar to Venn diagrams in set theory), which we call the pixel language.
The Number of Gaps in Binary Pictures
(a)
(b)
37
(c)
Fig. 1. (a) Top: digital curves with 0-gaps. Bottom: gap-free digital curves. Both ‘0’s define one 1-hole each. (b) A general digital curve with three 1-holes. (c) Pixel language configuration (top) representing two different digital pictures (middle, bottom).
This language is defined by different configurations of pixels, where in each of them there will be a key pixel, highlighted in grey, whose neighborhood is studied. For illustrations, see Figures 1c,2,3, and 4. A few rules define the graphical pixel language. 0-adjacent pixels of the key pixel will be drawn with normal continuous lines. Pixels that may or may not exist in a configuration will be drawn with dashed lines. Any subset of such pixels (in particular, no one or all of them) may belong to the configuration or may be missing. Sometimes (i) at least, (ii) at most, or (iii) exactly one (or more) of these pixels will have to exist in a configuration. In order to keep our pixel language simple, we will prefer to add relevant explanations in the text rather than to introduce further special graphical markings. Positions of pixels that are excluded from the configuration will be marked by ×. Additionally to these standard rules, sometimes we also assign labels to pixels for a more detailed analysis of certain possibilities. The existence of a path in a binary picture which connects two pixels in a configuration and does not intersect or “touch” other pixels from it is marked by connecting both pixels with an arc (as in some cases of Figures 3 and 4; see also Fig. 1c).
3 3.1
Gap Formulas Total Number of Gaps in a Binary Picture
Theorem 1. Consider a finite set D ⊂ Z2 , which contains p pixels, v vertices, h 1-holes, c 0-connected components, and b 2-blocks. Let g be the number of 0-gaps of D. Then we have the following: g = v − 2(p + c − h) + b.
(1)
38
V.E. Brimkov et al.
Proof. We use induction on the number of pixels. The statement is obviously true for a set consisting of a single pixel. We have p = 1, v = 4, c = 1, and h = b = g = 0; those values satisfy formula (1). Assume that the statement is true for a set composed of p pixels, where p ≥ 1. We will show that it is then true for any set composed by p = p + 1 pixels. Consider such a set D and remove an arbitrary pixel P from it. Then D = D − {P } is a set of p pixels to which the induction hypothesis applies. Let the number of its vertices, 0-components, 1-holes, 2-blocks, and 0-gaps be v, c, h, b, and g, respectively. Then g = v − 2(p + c − h) + b. We will see how adding pixel P to D can influence this last equality. We aim to show that g = v − 2(p + c − h ) + b ,
(2)
where p = p+1, v , c , h , b , and g are the counts of pixels, vertices, 0-components, 1-holes, 2-blocks, and 0-gaps of D , respectively. In doing so, we distinguish between 43 essentially different configurations which we group into 10 cases, some of which involve subcases1 . We analyze all of them with the help of illustrations using our pixel language. For the sake of better readability of the paper, we display the illustrations within Figures 2, 3, and 4, where labels of subfigures match the numeration of the cases considered below. Everywhere, pixel P is in dark grey. We outline the main points of the proof. For full details we have to refer to a forthcoming full length paper. Remember that throughout we have p = p + 1. Upon adding P to D, for the other parameters v , c , h , b , and g we may have various possibilities. Depending on how the parameters c, h, and b change, we distinguish the 10 basic cases. For the first two we also indicate how v and g change, while for the remaining eight cases this trivial operation is skipped for brevity. Case 1. c, h, and b do not change. The only possible configurations under these conditions are displayed in Fig. 2. We have c = c, h = h, and b = b. In Case 1a we have v = v+2 and g = g. In Case 1b, v = v+3 and g = g +1. In Case 1c, v = v + 1 and g = g − 1. In Case 1d, v = v and g = g − 2. Case 2. h and b do not change, while c increases by 1. Obviously, adding P to D can increase the number of components of D = D ∪ {P } only if P is disjoint from D. Then c will increase by 1, while h, b, as well as g will not change (see Fig. 2 (2)). We have v = v + 4, c = c + 1, h = h, b = b, and g = g. Case 3. h and b do not change, while c decreases by 1, 2, or 3. The possible configurations are displayed in Fig. 2. We have h = h and b = b. In Case 3a we have c = c − 1, which is possible for the seven configurations displayed in Fig. 2 (3a). In Case 3b we have c = c−2. The possible configurations are given in Fig. 2 (3b). In Case 3c we have c = c − 3 (Fig. 2 (3c)). 1
Note that any configuration containing dashed pixel(s) and/or path(s), actually represents a number of different configurations, one for each possibility, as all of them feature analogous characterization.
The Number of Gaps in Binary Pictures
(1a)
(1b)
(1c)
(1d)
39
(2)
1
(3a)
(3b)
(3c)
(4)
Fig. 2. Illustrations to the proof of Theorem 1. Cases 1, 2, 3, and 4.
(5a)
(6a)
(6b)
(5b)
(6c)
(5c)
(7)
Fig. 3. Illustrations to the proof of Theorem 1. Cases 5, 6, and 7.
Case 4. b and c do not change, while h decreases by 1. The only possible configuration is displayed in Fig. 2 (4). We have h = h + 1, c = c, and b = b. Case 5. c and b do not change, while h increases by 1, 2, or 3. The possible configurations are displayed in Fig. 3. We have c = c and b = b. In Case 5a we have h = h + 1, for which there are seven possible configurations displayed in Fig. 3 (5a). In Case 5b we have h = h + 2, which is possible for the four configurations displayed in Fig. 3 (5b). In Case 5c we have h = h + 3, which may occur in the configuration in Fig. 3 (5c). Note that if the dashed path is missing, three new 1-holes may appear in a hole-free component, while if the dashed path exists, an existing 1-hole is partitioned into four 1-holes. (In both cases v = v and g = g + 4.)
40
V.E. Brimkov et al.
(8a)
(8b)
(8c)
(8d)
1 1 1
1 (9)
(10a)
2 (10b)
(10c)
Fig. 4. Illustrations to the proof of Theorem 1. Cases 8, 9, and 10.
Case 6. c and h do not change, while b increases by 1 or 2. In the former case there are two possible configurations displayed in Fig. 3 (6a,b). We have c = c, h = h, and b = b + 1. In the latter case, we have the configuration displayed in Fig. 3 (6c). We have c = c, h = h, and b = b + 2. Case 7. c does not change, while h and b increase by 1. The only possible configuration is displayed in Fig. 3 (7). We have h = h + 1, b = b + 1, and c = c. Case 8. c does not change, h decreases by 1, and b increases by 1,2,3, or 4. The possible configurations are displayed in Fig. 4. We have c = c and h = h − 1. In Case 8a we have b = b + 1 (Fig. 4 (8a)); in Case 8b we have b = b + 2 (Fig. 4 (8b)); In Case 8c we have b = b + 3 (Fig. 4 (8c)); and in Case 8d we have b = b + 4 (Fig. 4 (8d)). Case 9. h does not change, while b increases by 1 and c decreases by 1. The only possible configuration is displayed in Fig. 4 (9). Note that before adding P to D, the pixel marked by 1 is not connected to the component to which the other pixels of the configuration belong. We have h = h, b = b + 1, and c = c − 1. Case 10. b does not change, while h increases by 1 and c decreases by 1 (Case 10a), or h increases by 1 and c decreases by 2 (Case 10b), or h increases by 2 and c decreases by 1 (Case 10c). The two possible configurations for Case 10a are displayed in Fig. 4 (10a). Case 10b features the configuration displayed in Fig. 4 (10b), and Case 10c the ones in Fig. 4 (10c). Note that in all figures differently numbered pixels belong to different components that are not connected to the pixel P . Having all possible cases determined, simple substitution in (2) for the respective values of h , b , and c , as well as for v and g show that this last equality holds in all cases. It is easy to realize that the considered cases are the only possible (up to certain symmetries). Simple reasoning reveals that adding a pixel to D can
The Number of Gaps in Binary Pictures
41
neither result in decreasing b, nor in increasing both h and c, nor in increasing both b and c, nor in decreasing h and changing c. This completes the proof of the theorem. Corollary 1. Let M be a gap-free finite set of pixels. Then v−2(p+c−h)+b = 0. 3.2
Gaps in Curves
A digital curve admits various equivalent definitions [3]. One of them is the following. A simple digital k-curve is a set ρ = {c1 , c2 , . . . , cl } of pixels that satisfy the following two axioms: (A1) ci is k-adjacent to cj iff i = j±1(modulo l), and (B1) ρ is one-dimensional with respect to k-adjacency, for k = 0 (Fig. 1a, top-left) or k = 1 (Fig. 1a, bottom-left). To get acquainted with the classical definition of dimension of a digital object the reader is referred to [10]. For further developments and various results see [3, 7] and the bibliography therein. For example, we have the following: Fact 1. Let M be a finite set of pixels which is one-dimensional with respect to adjacency k ∈ {0, 1}. Then M does not contain any 2-block. Any connected subset of a digital simple k-curve is a simple digital k-arc (Fig. 1a, right). More in general, by analogy to the classical definition of a curve in the plane2 , a digital curve can be defined as a set of pixels that is connected and one-dimensional with respect to k-adjacency (see Fig. 1b). Applied to digital curves, Theorem 1 and Fact 1 imply the following: Corollary If M is If M is If M is If M is If M is
4
2. Let M be a general digital curve. Then g = v − 2(p + 1 − h). gap-free, then v = 2(p + 1 − h). a simple digital arc, then g = v − 2(p + 1). a simple gap-free digital arc, then v = 2(p + 1). a simple digital curve, then g = v − 2p. a simple gap-free digital curve, then v = 2p.
Conclusions
In this paper we derived a formula for the total number of gaps in a binary picture, which contributes to combinatorial topology in the context of image analysis, pattern recognition, or geometric modeling. In particular, it can be used to test a binary picture (e.g., a digital curve) for existence of gaps. As already mentioned, the number of gaps characterizes the topological structure of a binary picture. The parameters involved (i.e., g, v, p, c, h and b) are either locally defined (namely, g, v, p, b) or global topological values (h and c). Quantitative interrelationships between local and global properties are of potential value in 2
A curve in R2 is a one-dimensional continuum, where continuum is any nonempty subset in a given topological space that is compact and topologically connected [9, 14].
42
V.E. Brimkov et al.
property-based image analysis. The identification of gaps is of particular interest when characterizing different ways of defining digital surfaces (2D manifolds) in 3D imaging, e.g., if they exclude the existence of gaps or not (see [4]). In 2D, this corresponds to the question whether a way of defining borders (see [7]) ensures gap-freeness of a digital picture. Work in progress is pursuing extension of the given results to higher dimensions.
Acknowledgements The authors thank the three anonymous referees for their useful comments.
References 1. Brimkov, V.E., E. Andres, and R.P. Barneva, Object discretizations in higher dimensions, Pattern Recognition Letters 23 (2002) 623–636 2. Brimkov, V.E., R.P. Barneva, and Ph. Nehlig, Minimally thin discrete triangulations, In: Volume Graphics, A. Kaufman, R. Yagel, M. Chen (Eds.), Chapter 3, Springer Verlag, 2000, pp. 51-70 3. Brimkov, V.E. and R. Klette, Curves, hypersurfaces, and good pairs of adjacency relations, Lecture Notes in Computer Science No 3322, Springer Verlag (2004) 270– 284 4. Chen, Li, Discrete Surfaces and Manifolds, Scientific & Practical Computing, 2004 5. Cohen-Or, D. and A. Kaufman, 3D line voxelization and connectivity control, IEEE Computer Graphics and Applications 17 (6) (1997) 80–87 6. Kaufman, A., D. Cohen, and R. Yagel, Volume graphics, IEEE Computer 26(7) (1993) 51–64 7. Klette, R. and A. Rosenfeld, Digital Geometry - Geometric Methods for Digital Picture Analysis, Morgan Kaufmann, San Francisco, 2004 8. Kong, T.Y., Digital topology, In: Davis, L.S., editor. Foundations of Image Understanding, Kluwer, Boston, Massachusetts, 2001, pp. 33–71 9. Menger, K., Kurventheorie, Teubner, Leipzig, Germany, 1932 10. Mylopoulos, J.P. and T. Pavlidis, On the topological properties of quantized spaces. I. The notion of dimension, J. ACM 18 (1971.) 239–246 11. Pavlidis, T, Algorithms for Graphics and Image Processing, Computer Science Press, Rockville, MD, 1982 12. Rosenfeld, A., Arcs and curves in digital pictures, Journal of the ACM 18 (1973) 81–87 13. Rosenfeld, A., Adjacency in digital pictures, Information and Control 26 (1974) 24–33 ¨ 14. Urysohn, P., Uber die allgemeinen Cantorischen Kurven, Annual meeting, Deutsche Mathematiker Vereinigung, Marbourg, Germany, 1923 15. Voss, K., Discrete Images, Objects, and Functions in Zn , Springer Verlag, Berlin, 1993