J Math Imaging Vis (2012) 42:76–91 DOI 10.1007/s10851-011-0277-z

Digitally Continuous Multivalued Functions, Morphological Operations and Thinning Algorithms

Carmen Escribano · Antonio Giraldo · María Asunción Sastre

Published online: 30 March 2011 © Springer Science+Business Media, LLC 2011

Abstract In a recent paper (Escribano et al. in Discrete Introduction Geometry for Computer Imagery 2008. Lecture Notes in Computer Science, vol. 4992, pp. 81–92, 2008)wehavein- The notion of continuous is a fundamental concept troduced a notion of continuity in digital spaces which ex- in the study of topological spaces. For dealing with digital tends the usual notion of digital continuity. Our approach, spaces, several approaches to define a reasonable notion of which uses multivalued functions, provides a better frame- have been proposed. The first one goes work to define topological notions, like retractions, in a far back to A. Rosenfeld [19] in 1986. He defined continuous more realistic way than by using just single-valued digitally functions in a way similar to that used for continuous maps continuous functions. in Rn. It turned out that continuous functions agreed with In this work we develop properties of this family of con- functions taking 4-adjacent points into 4-adjacent points. He tinuous functions, now concentrating on morphological op- proved, amongst other results, that a function between digi- erations and thinning algorithms. We show that our notion of tal spaces is continuous if and only if it takes connected sets continuity provides a suitable framework for the basic oper- into connected sets. Independently of Rosenfeld, L. Chen ations in mathematical morphology: erosion, dilation, clos- [5, 6] seems to have developed the same notion of continu- ing, and opening. On the other hand, concerning thinning ity, using the terms immersion, gradually varied operator, algorithms, we give conditions under which the existence of and gradually varied mapping. Chen’s work appeared origi- : −→ \ a retraction F X X D guarantees that D is deletable. nally in Chinese. The converse is not true, in general, although it is in certain More results related to this type of continuity were particular important cases which are at the basis of many proved by L. Boxer in [1] and, more recently, in [2–4]. thinning algorithms. In these papers, he introduced such notions as homeomor- Keywords Digital space · Continuous function · phism, retracts, and homotopies for digitally continuous Mathematical morphology · Simple point · Retraction · functions, applying these notions to define a digital funda- Thinning mental group, digital homotopies, and to compute the fun- damental group of sphere-like digital images. However, as he recognizes in [3], there are some limitations with the ho- motopy equivalences he gets. For example, while all simple closed curves are homeomorphic and hence homotopically C. Escribano · A. Giraldo () · M.A. Sastre equivalent with respect to the Euclidean topology, in the Departamento de Matemática Aplicada, Facultad de Informática, digital case two simple closed curves can be homotopically Universidad Politécnica, Campus de Montegancedo, Boadilla del Monte, 28660 Madrid, Spain equivalent only if they have the same cardinality. e-mail: agiraldo@fi.upm.es A different approach was suggested by V. Kovalevsky C. Escribano in [17], using multivalued functions. This seems reasonable, e-mail: cescribano@fi.upm.es since an expansion such as f(x)= 2x must take 1 pixel to 2 M.A. Sastre pixels if the image of an interval has still to be connected. He e-mail: masastre@fi.upm.es calls a multivalued function continuous if the pre-image of J Math Imaging Vis (2012) 42:76–91 77 an open set is open. He considers, however, that another im- that the deletion of simple points can be completely char- portant class of multivalued functions is what he calls “con- acterized in terms of digitally continuous multivalued func- nectivity preserving mappings.” By its proper definition, the tions, and in Sect. 6 we extend this result to simple pairs. image of a point by a connectivity preserving mapping is In the last sections we characterize thinning algorithms in a connected set. This is not required for merely continuous terms of digitally continuous multivalued functions. Specif- functions. He finally asserts that the substitutes for contin- ically, we show that the existence of an (N ,k)-retraction uous functions in finite spaces are the simple connectivity F : X −→ X \ D guarantees that D is 4-deletable (respec- preserving maps, where a connectivity preserving map f is tively, 8-deletable) whenever D is made of 4-boundary (re- simple if for any x such that f(x)has more than 1 element spectively, 8-simple) points. The converse is not true in gen- then f −1f(x)={x}. However, in this case it would be pos- eral although it holds in certain particular important cases sible to map the center of a 3 × 3 square to the k-boundary which are at the basis of many thinning algorithms. of it leaving the points of the k-boundary fixed, obtaining For information on Digital Topology we recommend the in this way a “continuous” retraction from the square to its survey [15] and the books by Kong and Rosenfeld [16], and k-boundary, something impossible in the continuous realm. by Klette and Rosenfeld [13]. Other results on the discretiza- The multivalued approach to continuity in digital spaces tion of topological notions can be found in [9, 10]. As an has also been used by R. Tsaur and M. Smyth in [23], where illustration of the usefulness of topological results, as those a notion of continuous multifunction for discrete spaces is presented in this paper, in applications, we refer the reader introduced: A multifunction is continuous if and only if it is to [11, 21], where the combination of continuous and digi- “strong” in the sense of taking neighbors into neighbors with tal topological notions has allowed the development of al- respect to the Hausdorff metric. They use this approach to gorithms to solve important problems, such as topological prove some results concerning the existence of fixed points constrained segmentation. for multifunctions. However, although this approach allows more flexibility in the digitization of continuous functions 1 Digital Spaces defined in continuous spaces, it is still a bit restrictive, as shown by the fact that the multivalued function used by them In this section we recall the basic notions of digital topology. to illustrate the convenience of using multivalued functions We consider Zn as model for digital spaces. is not a strong continuous multifunction. In a recent paper [7] the authors presented a theory of Definition 1 Two points in the digital line Z are adjacent if continuity in digital spaces, using multivalued functions, their coordinates differ by a unit. Two points in the digital which extends the one introduced by Rosenfeld and provides plane Z2 are 8-adjacent if they are different and their coor- a framework to define topological notions, like retractions, dinates differ in at most a unit. They are called 4-adjacent in a far more realistic way than by using just single-valued if they are 8-adjacent and differ in exactly one coordinate. digitally continuous functions. In particular, the deletion of Note that a point is 8-adjacent to 8 different points and is simple points, one of the most important processing opera- 4-adjacent to 4 different points. Two points of the digital 3- tions in digital topology, is characterized as a particular kind space Z3 are 26-adjacent if they are different and their coor- of retraction. dinates differ in at most a unit. They are called 18-adjacent In this work we look more deeply into the properties of if they are 26-adjacent and differ in at most two coordinates, this family of continuous functions, now concentrating on and they are called 6-adjacent if they are 26-adjacent and morphological operations and thinning algorithms. differ in exactly one coordinate. In an analogous way, ad- In Sect. 1 we revise the basic notions of digital topology jacency relations are defined in Zn for n ≥ 4, for exam- required throughout the paper. In particular we recall dif- ple, in Z4 there exist 4 analogous adjacency relations: 80- ferent adjacency relations used to model digital spaces. In adjacency, 64-adjacency, 32-adjacency and 8-adjacency. Sect. 2 we revise Rosenfeld’s notion of digitally continuous Given p ∈ Zn and X ⊂ Zn we say that p and X are k- function. In Sect. 3 we introduce the notion of subdivision adjacent if p ∈ X and there exists x ∈ X such that p and x of a topological space used to define continuity for multi- are k-adjacent. n valued functions and show some basic properties concern- Given X1,X2 ⊂ Z we say that X1 and X2 are k-adjacent ing the behavior of digitally continuous multivalued func- if X1 ∩X2 =∅and there exist x1 ∈ X1 and x2 ∈ X2 such that tions under restriction and composition. In Sect. 4 we show x1 and x2 are k-adjacent. that the basic morphological operations of dilation and clos- Alternatively, the adjacency of a point and a set, or the ing are continuous functions. We also show that, although adjacency between two sets, can be defined replacing the the dual operations of erosion and opening cannot be mod- condition X1 ∩ X2 =∅by X1 = X2, or, like, for example, eled as continuous functions, they are so if we consider in [16], without imposing any of those conditions. The re- them defined on the set of white pixels. In Sect. 5 we show sults in the paper and the proofs, with slight modifications, 78 J Math Imaging Vis (2012) 42:76–91

Fig. 3 p is 4-isolated and 8-isolated, q is 4-isolated but not 8-isolated, Fig. 1 N4(p) (left)andN8(p) (right) with labels r is 4-boundary and 8-boundary, s is 4-boundary but 8-interior, t is both 4-interior and 8-interior

Fig. 2 A set with three 4-connected components and two 8-connected components are still valid in both cases. However, in the context of this paper, it is more natural to require adjacent sets to be dis- Fig. 4 Left: 4-boundary (dark) and 4-interior (light)ofaset.Right: joint. The reason is that we will replace points by subdivi- 8-boundary (dark) and 8-interior (light) of the same set sions of them (see Fig. 9). Since one point is not adjacent to itself, the set obtained after subdividing it, should not be Using these notions we can define the k-interior (respec- adjacent to itself. Therefore, adjacent sets should be at least tively, k-boundary of X) as the set of points of X which are different. Moreover, if we consider a set {x,y} formed by k-interior (respectively, k-boundary) points of X. two non-adjacent points, then {x} and {x,y} are not adja- cent sets in any definition and, hence, the sets obtained after subdividing them, although different and satisfying the def- inition in [16], should not be adjacent to each other. 2 Digitally Continuous Single-Valued Functions In this section we revise the notion of digitally continuous Definition 2 If p ∈ Z2 we define N (p) and N (p) as in 4 8 function and some of its properties. Fig. 1, i.e., N4(p) is the set of points 4-adjacent to p, while N (p) is the set of points 8-adjacent to p, also denoted sim- 8 Definition 5 Let f : X ⊂ Zm −→ Zn be a function between ply as N (p). 3 digital spaces with adjacency relations k and k , respectively. In Z there are three kinds of neighborhood: N (p), 6 According to [2, 19], f is (k, k )-continuous if and only if f N (p), and N (p). 18 26 sends k-adjacent points to the same point or to k -adjacent points. When m = n and k = k , f is said to be just k- Definition 3 k P Z2 k ∈{, } A -path in ( 4 8 ) from the continuous. = point q0 to the point qr is a of points P We will say that f : X ⊂ Zm −→ Zn is continuous if it

q0,q1,q2,...,qr such that qi is k-adjacent to qi+1,for is (k, k )-continuous and the adjacencies k and k are under- ∈{ − } = every i 0, 1, 2,...,r 1 .Ifq0 qr then it is called a stood. closed path. ⊂ Z2 AsetX is k-connected if for every pair of points Examples of digitally k-continuous functions are the of X there exists a k-path contained in X joining them. identity, any , translations f(z)= z +r,in- k X k A -connected component of is a maximal -connected versions f(z1,z2) = (z2,z1),....Another example is given set (see Fig. 2). by the following function taking a hollow square S5 to a Zn ≥ Analogous definitions can be given for , n 3. smaller one S3. The function which takes the corners of S5 to the corre- ⊂ Z2 ∈{ } ∈ Definition 4 Given X , k 4, 8 and p X,wesay, sponding corners of S3, and the points between two corners according to [16], that: of S5 to the point between the corresponding corners of S3, is digitally k-continuous for k ∈{4, 8} (see Fig. 5). However, (i) p is a k-isolated point of X if Nk(p) ∩ X =∅, for k ∈{4, 8}, there is not a digitally k-continuous function (ii) p is a k-interior point of X if N¯(p) ⊂ X, k from S to S taking a to A, b to B, c to C and d to D, since (iii) p is a k-boundary point of X if N¯(p) ∩ (Z2 \ X) = ∅, 3 5 k then it would not be possible to define the image of the rest ¯ = = ¯ = = where k 4ifk 8, k 8ifk 4 (this notation will of the points in such a way that k-adjacent points of S3 are be used throughout the paper). We denote by ∂kX the k- taken to the same point or to k-adjacent points of S5 (see boundary of X (see Figs. 3 and 4). Fig. 6). Note that a point is k-interior if and only if it is not a In [19] Rosenfeld stated and proved several results about k-boundary point. digitally continuous functions related to operations with J Math Imaging Vis (2012) 42:76–91 79

Fig. 5 There exists a continuous function f taking A to a, B to b, C Fig. 8 The outer k-boundary of an annulus is not a digital k-retract to c and D to d

In this section we show how it is possible to define a no- tion of continuity for multivalued functions in such a way that the limitations discussed above of digitally continuous single valued functions are alleviated (see Proposition 2). The definitions and results in this section were first intro- duced in [7]. Fig. 6 There is not a continuous function f taking a to A, b to B, c to C and d to D Definition 6 The first subdivision of Zn is formed by the set n z1 z2 zn n Z = , ,..., | (z ,z ,...,zn) ∈ Z 1 3 3 3 1 2 n : : Zn −→ Zn and the 3 1 function i 1 given by z z z i 1 , 2 ,..., n = (z ,z ,...,z ) 3 3 3 1 2 n Fig. 7 The k-boundary of a square is not a digital k-retract Zn where (z1,z2,...,zn) is the point in which is closest to ( z1 , z2 ,..., zn ) continuous functions, intermediate values property, almost- 3 3 3 in the Euclidean metric. Zn fixed point theorem, Lipschitz conditions, one-to-oneness, The r-th subdivision of is formed by the set etc. Boxer [1–3] expanded this notion to digital homeomor- n z1 z2 zn n Z = , ,..., | (z ,z ,...,zn) ∈ Z phisms, retractions, extensions, homotopies, digital funda- r 3r 3r 3r 1 2 mental group, induced homomorphisms, etc. (see also [12] and the 3nr : 1 function i : Zn −→ Zn given by and [14] for previous related results). r r In particular, Boxer proved in [1] that the k-boundary of z1 z2 zn ir , ,..., = (z ,z ,...,z ) a digital square is not a digital k-retract (see Definition 9)of 3r 3r 3r 1 2 n the square. where (z ,z ,...,z ) is the point in Zn which is closest to However, the same techniques used to prove this fact can 1 2 n ( z1 , z2 ,..., zn ) in the Euclidean metric. be used to prove that neither is the outer k-boundary of an 3r 3r 3r Moreover, if we consider in Zn a k-adjacency , annulus a k-retract of the annulus. we can consider in Zn the induced adjacency relation, i.e., Note that Fig. 7 agrees with what happens if we consider r z z 2 z1 z2 zn 1 2 zn the sets as of R . However, Fig. 8 does not agree, ( 3r , 3r ,..., 3r ) and ( 3r , 3r ,..., 3r ) are k-adjacent if and 2 since in R , the outer k-boundary, or the outer half, of an only if (z1,z2,...,zn) is k-adjacent to (z1,z2,...,zn). annulus, is a digital k-retract of the annulus. Proposition 1 ir is k-continuous as a function between dig- ital spaces. 3 Digitally Continuous Multivalued Functions Definition 7 Given X ⊂ Zn,ther-th subdivision of X is the = −1 As noted in the previous section, given a hollow 3×3-square set Xr ir (X). S3 and a hollow 5 × 5-square S5,fork ∈{4, 8}, there is not a k-continuous function between them, which takes the cor- Intuitively, if we consider X made of pixels (respectively, ners of S3 to the corresponding corners of the S5. voxels), the rth subdivision of X consists in replacing each r r The point here is that no matter how we define the image pixel with 9 pixels (respectively, 27 voxels) and the func- of the rest of the points, connectedness would not be pre- tion ir is like an inclusion in the geometric sense (see Fig. 9). served. However, we would preserve connectedness if we ⊂ Zn : −→ could define the image of each point between two corners Remark 1 Given X, Y , any function f Xr Y S induces in an immediate way a multivalued function F : of 3 as the whole set of points between the corresponding X −→ Y where F(x)= −1 f(x ). corners of S5, i.e., using multivalued functions. x ∈ir (x) 80 J Math Imaging Vis (2012) 42:76–91

Fig. 10 Labels of N (p) and i−1(p)

Fig. 9 A digital set (left) and its first subdivision (right)

Definition 8 Consider X, Y ⊂ Zn. A multivalued function F : X −→ Y is said to be a (k, k )-continuous multival- 4 Morphological Operators as Digitally Continuous ued function if it is induced by a (k, k )-continuous (single- Multivalued Functions valued) function from Xr to Y for some r ∈ N. In this section we consider the basic operations in mathe- In the following remark we state some properties of dig- matical morphology: dilation, erosion, closing, and opening itally continuous multivalued functions proved in [7]. For operators (see [22] for their definitions). We will denote by more results and details the reader is referred to [7]. Dk(X), Ek(X), Ck(X), Ok(X), respectively, the dilation, erosion, closing, and opening of a digital set X in Z2,us- Remark 2 Any single-valued digitally continuous func- ing as a structuring element the set formed by a point and its tion is continuous as a multivalued function. In particular, k-neighbors. any constant function is continuous as a multivalued func- We will show that these operators can be modeled as dig- : −→ ⊂ Z2 tion. Moreover, if F X Y (X, Y )isa(k, k )- itally continuous multivalued functions, which we will de- continuous multivalued function, then: note, respectively, by Dk, Ek, Ck, Ok. Note that, then, the

(i) F(x)is k -connected, for every x ∈ X. notation Dk(X) will not only indicate the image of X under (ii) If x and y are k-adjacent points of X, then F(x)∪F(y) the function Dk, but also the set that is the k-dilation of X. is a k -connected of Y . Note, however, that these two sets agree. The same can be (iii) F takes k-connected sets to k -connected sets. said for the other operators.

(iv) If X ⊂ X then F |X : X −→ Y is a (k, k )-continuous We start the section with a theorem which shows how the multivalued function. dilation operator can be modeled by a continuous multival- ued function. Moreover, the composition of continuous multivalued func- tions is a continuous multivalued function. 2 Theorem 1 Given X ⊂ Z , the multivalued functions Dk : ⊂ Z2 ⊂ X −→ Dk(X) given by Dk(x) = Nk(x) ∪{x}, k = 4, 8, are Definition 9 Let X and Y X. We say that Y is ¯ a k-retract of X if there exists a k-continuous multivalued digitally k and k-continuous. function F : X −→ Y (a multivalued k-retraction) such that F(y)={y} if y ∈ Y . Proof Consider the first subdivision of X and the points of − If moreover F(x)⊂ N (x) for every x ∈ X \ Y ,wesay i 1(p) and those in N (p) labeled as in Fig. 10. that F is a multivalued (N ,k)-retraction. Then D8 is induced by the function d8 given by d8(Pi) = pi if i = 0, and d8(P0) = p, while D4 is induced by the The following results are given in [7]. function d4 given by d4(Pi) = pi if i ∈{2, 4, 6, 8} and d4(Pi) = p if i ∈{0, 1, 3, 5, 7}. It is immediate to check that ¯ Proposition 2 The following holds: Dk is k and k-continuous. 

(i) The k-boundary ∂kX of a square X, with nonempty in- terior, is not a k-retract of X. The erosion operation cannot be adequately modeled as a digitally continuous multivalued function on the set of black (ii) The outer k-boundary ∂kX of an annulus X is a k- retract of X. pixels since it can transform a connected set into a discon- nected set, or even delete it (for example, the erosion of a Result (ii) solves one of the problems presented when us- curve is the empty set and, in general, the erosion of two ing single-valued functions (see Fig. 8). discs connected by a curve would be the disconnected union In the rest of the paper we show how this notion of dig- of two smaller discs). However, since the erosion of a set ital continuity also allows us to characterize basic morpho- agrees with the dilation of its complement, the erosion op- logical operations as dilation and closing, or thinning algo- erator can be modeled by a continuous multivalued function rithms. on the set of white pixels. J Math Imaging Vis (2012) 42:76–91 81

2 2 2 Corollary 1 Given X ⊂ Z , the multivalued function Ek : Corollary 3 Given X ⊂ Z and p ∈ Z k-adjacent to X, 2 2 Z \ X −→ Z , given by Ek(x) = Nk(x) ∪{x} is digitally k then F : X −→ X ∪{p} given by and k¯-continuous. x if x is not k-adjacent to p, F(x)= Although the erosion operation cannot be modeled as a {x,p} if x is k-adjacent to p digitally continuous multivalued function on the set of black pixels, when combined with the dilation we obtain the clos- is a digitally k-continuous multivalued function. ing operation which can be modeled a digitally continuous multivalued function. Recall, as noted at the beginning of Corollary 4 Given X ⊂ Z2 and a structuring element B the section, that Ck(X) will not only indicate the image of (see [22]) containing the origin and contained in a 3 × 3 X under the multivalued function Ck, but also the set that is square, then the dilation of X by B can be modeled as a the k-closing (a k-dilation composed with a k-erosion) of X. digitally 8-continuous multivalued function.

⊂ Z2 : Theorem 2 Given X , the multivalued function Ck Corollary 5 Given X ⊂ Z2 and given Y ⊂ Z2, k-connected −→ ={ } ∈ \ X Ck(X), given by Ck(x) x for every x X ∂kX and k-adjacent to X, there exists a surjective digitally con- = { }∪N ∩ ∈ and Ck(x) ( x k(x)) Ck(X) for every x ∂kX, is tinuous multivalued function F : X −→ X ∪ Y such that digitally k-continuous. F(x)={x} if x is not k-adjacent to Y .

Proof With the notation of Theorem 1, Ck is induced by Proof Since Y is k-connected and k-adjacent to X, there : −1 −→ ck i (X) Ck(X) given by exists an ordering p ,p ,...,p of the points of Y (where 1 2 n the pi need not be pairwise distinct) such that p1 is k- pi if i = 0 and pi ∈ Ck(X), ck(Pi) = adjacent to X and pi is k-adjacent to (or contained in) p if i = 0ori = 0 and pi ∈ Ck(X). X ∪{p1,p2,...,pi−1}, for every i ∈{2, 3,...,n}. Consider F1 : X −→ X ∪{p1} given by It is immediate to check that Ck is k-continuous.  x if x is not k-adjacent to p , As it happens in the case of the erosion, the opening oper- 1 F1(x) = ation (erosion composed with dilation) cannot be adequately {x,p1} if x is k-adjacent to p1 modeled as a digitally continuous multivalued function on the set of black pixels (the same examples used for the ero- which is a digitally continuous multivalued function. For ∈{ } ∪ sion also work for the opening). However, since the opening every i 2, 3,...,n such that pi is k-adjacent to X { } of a set agrees with the closing of its complement [22], the p1,p2,...,pi−1 , consider k-opening operator can be modeled by a k-continuous mul- : ∪{ }−→ ∪{ } tivalued function on the set of white pixels. Fi X p1,p2,...,pi−1 X p1,p2,...,pi given by Corollary 2 Given X ⊂ Z2, the k-opening (k-erosion + k- dilation) operation on X can be modeled as a digitally k- x if x is not k-adjacent to pi, continuous multivalued function O : Z2 \ X −→ Z2 on the F (x) = k i { } set of white pixels. x,pi if x is k-adjacent to pi

Theorems 1 and 2 are particular cases of the following which is also is a digitally continuous multivalued function, ∪{ } result: while, if pi is contained in X p1,p2,...,pi−1 , we con- sider Theorem 3 Given X ⊂ Z2, every multivalued function F : 2 Fi : X ∪{p1,p2,...,pi−1}−→X ∪{p1,p2,...,pi}, X −→ Z such that x ∈ F(x)⊂ Nk(x) ∪{x} for every x ∈ X, is a digitally k-continuous multivalued function. such that Fi is the identity. Then, since the composition of digitally continuous mul- Proof Consider the first subdivision of X and the points of −1 N tivalued functions is a digitally continuous multivalued func- i (p) and those in (p) labeled as in Fig. 10. Then F is = ◦ : −1 −→ tion (see Remark 2), the multivalued function F Fn induced by f i (X) F(X)given by ◦ ···◦ ◦ Fn−1 F2 F1 satisfies the conclusion of the corol-  pi if i = 0 and pi ∈ F(x), lary. f(Pi) = p if i = 0ori = 0 and p ∈ F(x). i We end this section with a result which, although a conse- which is a continuous function.  quence of the previous result, is better stated and proved in 82 J Math Imaging Vis (2012) 42:76–91 terms of notions and properties of mathematical morphol- Theorem 4 Let X ⊂ Z2. A point p ∈ X is k-simpleifitis ogy. It is based on the fact that a morphological operation a k-boundary point of X and the number of k-connected with a large structuring element can be decomposed into components of N (p) ∩ X which are k-adjacent to p is equal a sequence of operations with smaller structuring elements to 1. [22], and, on the other hand, that the composition of digitally continuous multivalued functions is a digitally continuous The following theorem was proved in [7, 8] where two multivalued function. different algorithms were given. The differences in the algo- rithms in these papers are basically two: in the second one Corollary 6 Given X ⊂ Z2, and a rectangular structuring we only require consideration of the first subdivision of X element B centered at the origin and containing it, then the (and not the second as happened in the first one), and we ob- dilation of X by B can be modeled as digitally continuous tain smaller images for the deleted simple points. Although multivalued function. we state the result for k-connected sets, this is not a loss of generality because for a general set X it would be applied Proof A dilation with a rectangular structuring element of to the connected component containing the simple point we sides 2m + 1 and 2n + 1 pixels is equivalent to a dilation want to delete. with a horizontal line of 2m+1 pixels followed by a dilation Theorem 5 Let X ⊂ Z2 be k-connected and consider with a vertical line of 2n + 1 pixels. On the other hand, a di- p ∈ X. Suppose that there exists a k-continuous multivalued lation with a horizontal (respectively, vertical line) of 2m+1 function F : X −→ X \{p} such that F(x)={x} if x = p (respectively, 2n + 1) pixels is equivalent to a sequence of and F(p)⊂ N (p). Then p is a k-simple point. m (respectively, n) dilations with a horizontal (respectively, The converse is true under the following conditions: vertical) line of 3 pixels. (See, for example, [22, p. 640]). In the particular case of a dilation by a square of width (a) for k = 8 it is always true and, moreover, we can impose 2n+1 pixels, this can be more easily done with n successive that F(p)⊂ N4(p) whenever p is not 4-isolated, dilations with a 3 × 3 square. (b) for k = 4 it is true if and only if p is not 8-interior to X. The result follows from the fact that the composition of digitally continuous multivalued functions is a digitally con- Proof The proof of this result can be found in [8]. However, tinuous multivalued function.  since it rests on an argument that we will use throughout the paper, we reproduce here the proof of the direct implication. Suppose that F is induced by fr : Xr −→ X. Then f (x) = i (x) for every x ∈ X such that i (x) = p. 5 Continuous Multivalued Functions and Deletion of r r r r Suppose that p is not k-simple. We have two possibili- Simple Points ties: p is a k-boundary point with at least two different k- connected components of N (p) ∩ X which are k-adjacent It may seem that the family of continuous multivalued func- to p,orp is an interior point. tions could be too broad, therefore not having good prop- In the first case, let A and B be any two such compo- erties. In this section we show that this is not the case. We ∈ −1 −1 nents. Consider any xr ir (p) k-adjacent to ir (A). Then show, in particular, that the existence of a k-continuous mul- x = fr (xr ) must be k-adjacent to A or contained in A (since tivalued function from a set X to X \{p} which leaves in- F(A) = A), and since A is a k-connected component of \{ } variant X p is closely related to p being a k-simple point N (p) ∩ X,wehavefr (xr ) ∈ A. On the other hand, there of X. ∈ −1 −1 also exists yr ir (p) k-adjacent to ir (B) and, hence, ⊂ Z2 ⊂ = Let X and D X. D is called k-deletable (k fr (yr ) = y ∈ B. Consider 4, 8) in X if its deletion does not change the topology of X { = = }⊂ −1 in the sense that after deleting D: z0 xr ,z1,z2m,...,zm−1,zm yr ir (p)

–nok-connected component of X vanishes or is split into such that, for every i = 1, 2,...,m, zi is k-adjacent to zi−1. multiple components, Then –nok¯-connected hole in X is created or is merged with the background or with another such hole. {fr (z0) = x,fr (z1), fr (z2),...,fr (zm−1), fr (zm) = y} ¯ ¯ Here, as noted in Sect. 1, k = 4ifk = 8 and k = 8ifk = 4. is a k-path in N (p) ∩ X from x to y. Contradiction. Let X ⊂ Z2. A point p ∈ X is called k-simple (k = 4, 8) For the case of p interior and the converse implication we in X (see [15]) if {p} is k-deletable in X. refer the reader to [8], although, as an illustration, we show A k-simple point can be locally detected by the following how to construct F in two particular cases, giving alternative characterization [20]: constructions to those in [7, 8]. J Math Imaging Vis (2012) 42:76–91 83

Fig. 11 F1 (left), F2 (center)andF3 (right) multivalued 4-continuous Fig. 14 F1 (left), F2 (center)andF3 (right) multivalued 8-continuous functions deleting a 4-simple point functions deleting an 8-simple point

Fig. 12 The 4-continuous Fig. 15 An 8-continuous single single valued function f1 valued function f1 inducing F1 inducing F1

The function F1 has the property that the image of p has the smallest possible number of points, while the function F3 on the right has the largest possible size. To see why F1 is 8-continuous we consider the first sub- −1 division X1 of X and we divide i1 (p) in groups and define f1 as shown by the arrows in Fig. 15. For the two other functions F2 and F3, the same groups Fig. 13 Left: A single valued function f inducing F . Right: A single 2 2 of Fig. 13, for the case k = 4, are still valid. This ends the valued function f3 inducing F3 proof of the theorem. 

∈ N ∩ = If p X is a 4-simple point such that (p) X Since the composition of k-continuous multivalued func- { } p1,p3,p4,p5,p6,p7,p8 ,weshowinFig.11 three differ- tions is a k-continuous multivalued function, we have the = ent 4-continuous multivalued functions such that F(x) x following result [7]: if x = p (the image of p is defined by the arrows). The function F1 on the left has the property that the im- 2 n Corollary 7 Let X ⊂ Z be k-connected, D ={pi} , age of p has the smallest possible number of points. The i=1 Y = X \ D, such that p1 is k-simple in X and is not an function F3 on the right, on the other hand, has the largest 8-interior point of X, and for 2 ≤ i ≤ n we have pi is k- possible size. In general, it is possible to prove, in a sim- − simple in X \ i 1 {p } and is not an 8-interior point of ilar way as in [7, 8], that the function which assigns to a j=1 j \ i−1 { } k-simple point p the whole (and unique) k-connected com- X j=1 pj . Then there exists a k-continuous multival- ponents of N (p) ∩ Xk-adjacent to p is k-continuous (as it ued k-retraction from X to Y . happens with F3). On the other hand, it is possible to con- struct an algorithm to obtain the image of p with the smallest Remark 3 The converse is not true since any constant func- possible number of points (like F1). tion is continuous but not all sets (for example, digital sim- To see why F1 is 4-continuous we consider the first sub- ple closed curves like the ones in Fig. 5) can be reduced by a division X1 of X and f1 : X1 −→ X such that f1(x ) = x sequential deletion of simple points to a single point. How- ∈ −1 = for every x i1 (x), x p, and such that f1 is defined in ever, in Sect. 7 we give a partial converse result using the −1 notion of (N ,k)-retraction. i1 (p) as shown by the arrows in Fig. 12. For the functions F2 and F3 we have to consider the sec- −1 N ∩ ond subdivision X2 of X,dividei2 (p) in groups and define Remark 4 It is easy to see that if (p) X is as in Fig. 11, −1 p f2 and f3 in the points of i2 (p) as shown by the arrows in although is 4-simple and 8-simple, any single-valued Fig. 13. function f : X −→ X \{p}, such that f(x)= x if x = p, If we consider now p as an 8-simple point, then we show cannot be neither 4-continuous nor 8-continuous, hence an in Fig. 14 three different 8-continuous multivalued functions analog of Theorem 5 does not hold for Rosenfeld’s digitally such that F(x)= x if x = p. continuous single-valued functions. 84 J Math Imaging Vis (2012) 42:76–91

Fig. 16 A non-deletable pair of Fig. 17 Labels of the points in k-simple points (k = 4, 8) N (p, q)

6 Continuous Multivalued Functions and Deletion of Simple Pairs Suppose that {p,q} is not a k-simple pair. Then we have It is interesting to note that the ideas in Theorem 5 can be two possibilities: there are at least two different k-connected also applied to pairs of 4-adjacent points whose simultane- components of N (p, q) ∩ X which are k-adjacent to {p,q}, ous deletion does not change the k-topology. Such points, or p and q are both k-interior points. called k-simple pairs, are essential to verify the corrected- In the first case, let A and B be any two such compo- ∈ −1 { } −1 ness of parallel thinning algorithms and are locally charac- nents. Consider any xr ir ( p,q )k-adjacent to ir (A). terized as follows: Then x = fr (xr ) must be k-adjacent to A or contained in A pair {p,q} of 4-adjacent points of X is a k-simple pair A (since F(A)= A), and since A is a k-connected compo- if and only if at least one of them is not a k-interior point nent of N (p) ∩ X, then fr (xr ) ∈ A. Similarly, there exists N ∩ ∈ −1 { } −1 = and the number of k-components of (p, q) X that are k- yr ir ( p,q )k-adjacent to ir (B) and, hence, fr (yr ) adjacent to {p,q} is 1, where N (p, q) = (N (p) ∪ N (q)) \ y ∈ B. Consider {p,q}. = = ⊂ −1 { } It is well known that a set formed by two 4-adjacent k- z0 xr ,z1,z2,...,zm−1,zm yr ir ( p,q ) simple points does not need to be a k-simple pair (e.g., see = Fig. 16). such that zi is k-adjacent to zi−1 for i 1, 2,...,m. Then On the other hand, a k-simple pair does not need to be { = = }⊂N ∩ composed of k-simple points. However, if {p,q} is a k- fr (z0) x,fr (z1),...,fr (zm) y (p, q) X simple pair, then we can order them in such a way that one is a k-path in N (p, q) ∩ X from x to y. Contradiction. of them, say p,isak-simple point in X, and q is a k-simple point in X \{p}. This result, that we will use later, is a con- Suppose now that p and q are k interior points. Denote N ⊂ sequence of the following more general result [18]: the points in (p, q) X as in Fig. 17. Define G : N (p) ∪{p}−→N (p, q) ∪{p,q} and H : N ∪{ }−→N ∪{ } Theorem 6 ([18]) The deletion of a subset D of X does (p, q) p,q (p) p , 8 and 4-continuous mul- ={ } { } = not change the k-topology of X if and only if there is an tivalued functions given by G(p) p,q , H( p,q ) p ={ }n and the following tables ordering of the points of D, D pi i=1, such that p1 is ≤ ≤ a k-simple point of X and, for 2 i n, pi is a k-simple \ i−1 { } point of X j=1 pj . xp1 p10 p9 p2 p8 p3 qp7 G(x) p1 p10 p9 {p2,p3}{p7,p8} p4 p5 p6 In the following theorem we show that the deletion of a k-simple pair can be modeled as a digitally k-continuous { }{ } multivalued function. xp1 p10 p9 p2,p3 p7,p8 p4 p5 p6 H(x) p1 p10 p9 p2 p8 p3 qp7 Theorem 7 Let X ⊂ Z2 be k-connected and consider a pair {p,q}⊂X of 4-adjacent points of X. Suppose that there i.e. G (respectively, H ) takes the left vertical side of N (p)∪ exists a k-continuous multivalued function F : X −→ X \ {p} (respectively, N (p, q) ∪{p,q}) to the left vertical side {p,q} such that F(x)={x} if x ∈ {p,q}, F(p)∪ F(q)⊂ of N (p, q)∪{p,q} (respectively, N (p)∪{p}), the right ver- N (p, q). Then {p,q} is a k-simple pair. tical side to the right vertical side, and the middle vertical The converse is true under the following conditions: part to the middle vertical part, the latter in a 1 : 2 (respec- (a) for k = 8 it is always true and, moreover, we can impose tively, 2 : 1) way. : N ∪{ }−→N ∪{ } that F({p,q}) ⊂ N4(p, q) = (N4(p) ∪ N4(q)) \{p,q} Then HFG (p) p (p) p is a k-continuous whenever {p,q} is not a 4-connected component of X, multivalued function such that HFG(x) ={x} if x = p and (b) for k = 4 it is true if and only if p or q is not 8-interior HFG(p) ⊂ N (p). Therefore, by Theorem 5, p would be to X. a k-simple point and this is a contradiction because p is a k-interior point. Proof To prove the first assertion, suppose that F is induced We prove now the converse statement. by fr : Xr −→ X. Then fr (x) = ir (x) for every x ∈ Xr such Suppose first that k = 8. If {p,q} is an 8-simple pair, that ir (x) ∈ {p,q}. then, by Theorem 6, we can order them in such a way that J Math Imaging Vis (2012) 42:76–91 85

Fig. 18 A4-simplepairof 8-interior points

Fig. 19 There exists (N , 4)-retraction but there is not a 4-connected component of N (p) ∩ (X \ D) 4-adjacent to p one of them, say p, is an 8-simple point, and q is an 8- Before proving Theorem 8 we prove a Lemma which will simple point in X \{p}. Since p is 8-simple, by Theo- be used in its proof and that of Theorem 9. Its proof is very rem 5, there exists an 8-continuous multivalued function F1 : similar to that of the direct implication of Theorem 5. When X −→ X \{p} such that F1(x) ={x} if x = p and F1(p) ⊂ applying it to prove Theorem 8 note that the function F in N : −→ \{ } N4(p). Since q is 8-simple in X \{p}, then there exists an 8- the theorem is an ( ,k)-retraction F X X p,q . continuous multivalued function F2 : X \{p}−→X \{p,q} ⊂ Z2 ⊂ such that F2(x) ={x} if x = q and F2(q) ⊂ N4(q). Then Lemma 1 Consider X k-connected and D X such that there exists an (N ,k)-retraction F : X −→ X \ D the composition F = F2F1 satisfies the statement of the the- . ∈ orem. Then, for any p D, there is at most one k-connected com- N ∩ \ Suppose now that k = 4. If {p,q} is a 4-simple pair we ponent of (p) (X D) k-adjacent to p and, moreover, if can distinguish three cases: there is one, it must contain F(p).

(a) Neither p nor q is 8-interior. In this case the proof is Proof Suppose that F is induced by fr : Xr −→ X \ D. similar to that for k = 8. Then fr (x) = ir (x) for every x ∈ Xr such that ir (x) ∈ (b) Just one of them, say p, is 8-interior. Then q must be X \ D. 8-simple and the proof above is again valid. Suppose that there are two different k-connected com- (c) Both p and q are 8-interior. Then (see Fig. 18) {p2,p3, ponents A and B of N (p) ∩ (X \ D) which are k-adjacent ∈ −1 −1 p5,p7,p8,p10}⊂X. But, since {p,q} is a 4-simple to p. Consider any xr ir (p) k-adjacent to ir (A). Then pair, there is only one 4-connected component of x = fr (xr ) must be k-adjacent to A or contained in A N (p, q) ∩ X 4-adjacent to {p,q}. This implies that (since F(A) = A), and since A is a k-connected compo- N (p, q) ∩ X must be as in Fig. 18 (or a rotation or a nent of N (p) ∩ X, then fr (xr ) ∈ A. Similarly, there also ∈ −1 −1 ∈ symmetry of it). exists yr ir (p) k-adjacent to ir (B) with fr (yr ) B. Suppose that there exists a 4-continuous multivalued But then F(p)⊂ N (p) is a k-connected set which would N ∩ \ function F : X −→ X \{p,q} such that F(x)={x} if connect A and B in (p) (X D). Contradiction. There- x ∈ {p,q} and F(p)∪ F(q)⊂ N (p, q) ∩ X, and sup- fore, there exists at most one k-connected component of N (p) ∩ (X \ D) k-adjacent to p. pose that F is induced by fr : Xr −→ X. Then, since f (x) = p for every x ∈ X such that i (x) = p ,if We show finally that, if there is a k-connected com- r i r r i N ∩ \ we consider the upper rightmost point x ∈ i−1(q),itis ponent of (p) (X D) k-adjacent to p then it must r contain F(p).LetA be such a k-connected component of not possible to define fr (x) in such a way that fr is 4- N (p) ∩ (X \ D) F(p)⊂ X \ D F(A)= A continuous. . Then and must be k adjacent and, hence, F(p)⊂ A.  This ends the proof of the theorem.  The example of Fig. 19 shows that the existence of an Observe that in the theorem above we do not require that (N ,k)-retraction F : X −→ X \ D does not guarantee, for F(p)⊂ N (p) or F(q)⊂ N (q),asin(N ,k)-retractions. If k = 4, the existence of a k-connected component of N (p) ∩ we consider this additional requirement we obtain the fol- (X \ D) k-adjacent to p. lowing result: Lemma 1 will be used in several parts of the paper in different situations in which we have an (N ,k)-retraction : −→ \ Theorem 8 Let X ⊂ Z2 be k-connected and consider a pair F X X D, because this imposes restrictions on the {p,q}⊂X of 4-adjacent points of X. Suppose that there neighborhood of a point in D. Some of those situations are exists a k-continuous multivalued function F : X −→ X \ shown in the following corollary. {p,q} such that F(x) ={x} if x ∈ {p,q}, F(p) ⊂ N (p), Corollary 8 Consider X ⊂ Z2 k-connected and D ⊂ X F(q)⊂ N (q) and F(p) (respectively, F(q)) k-adjacent to such that there exists an (N ,k)-retraction F : X −→ X \D. p (respectively, q). Then {p,q} is a k-simple pair and both Consider p ∈ D. Then: p and q are k-simple points. The converse is true if and only if neither p nor q is 8- (i) All points of X \Dk-adjacent to p must be k-connected interior to X. in N (p) ∩ X to those of F(p). 86 J Math Imaging Vis (2012) 42:76–91

(ii) If p ∈ D ∩ ∂ X is not k-simple, there exists d ∈ Dk- Fig. 20 An 8-simple pair of k 8-simple points adjacent to p which cannot be connected to F(p) by a k-path in N (p) ∩ X.

Proof (i) is an immediate consequence of Lemma 1.To proof (ii) consider p ∈ D ∩ ∂kX, such that p is not k-simple. Then there are at least two different k-connected compo- nents A and B of N (p)∩X which are k-adjacent to p. Con- sider x ∈ A and y ∈ Bkadjacent to p. Then, by Lemma 1, one of them, say x, must belong to D.Now,ify ∈ X \ D, by Lemma 1, F(p)⊂ B and x ∈ D cannot be connected to F(p) by a k-path in N (p) ∩ X. On the other hand, if both x,y ∈ D, since F(p)⊂ N (p) ∩ X is k-connected, then ei- ∩ =∅ ∩ =∅ ∩ =∅ ther F(p) A or F(p) B .IfF(p) A , Fig. 21 First subdivision of an 8-simple pair of 8-simple points then x ∈ D cannot be connected to F(p) by a k-path in N (p) ∩ X; and if F(p)∩ B =∅, then y ∈ D cannot be con- nected to F(p)by a k-path in N (p) ∩ X.  Then the multivalued function F defined by F(x)={x} if x ∈ {p,q} and Proof of Theorem 8 By Theorem 7, {p,q} is a k-simple pair. ⎧ We show now that p and q must be k-simple points. Suppose ⎨{p7} if p8 ∈ X, = { } ∈ ∈ that p is not k-simple. We have two possibilities: p is a k- F(p) ⎩ p8 if p8 X, p1 X, boundary point or p is a k-interior point. {p8,p10} if p1 ∈ X, Suppose first that p is a k-boundary point. Consider rk- {p7} if p4 ∈ X, adjacent to p such that r ∈ F(p) (this implies that r = q). F(q)= {p5,p7} if p4 ∈ X, Since p is not k-simple, by Theorem 4, there exists s ∈ X, k-adjacent to p, which can not be connected to r by a k- is 8-continuous. path in N (p) ∩ X. Suppose that s = q. Then there are two To see this consider the first subdivision of X labeled as different k-connected components of N (p)∩(X \{p,q})k- in Fig. 21. adjacent to p, which is impossible by Lemma 1. Therefore Then we define f , that induces F , according to the fol- s = q and, as a consequence, F(p) and q lie in different k- lowing table: connected components of N (p) ∩ X. This is a contradiction because F(p)∪ F(q) ⊂ N (p, q) ∩ X is k-connected and ∈ = = = ∈ must be k-adjacent to q. p8 Xf(A)f(B) f(C) p7 p4 X = = = Suppose now that p is a k-interior point and denote f(D) f(E) f(G) p7 p ∈ Xf(A)= f(B)= f(C)= p the points in N (p, q) as in Fig. 17. Then, for k = 4, 8 8 p1 ∈ Xf(D)= f(E)= f(G)= p7 X ⊃{p1,p2,p3,p7,p8,p9,p10}. Since F(q)⊂ N (q) is 4- p1 ∈ Xf(A)= p10,f(B)= f(C)= p8 connected and p3 and p7 are 4-adjacent to (or contained in) f(D)= f(E)= f(G)= p7 F(q), then {p4,p5,p6}⊂F(q)⊂ X. Then q will also be ∈ = = = ∈ a 4-interior point and hence {p,q} could not be a 4-simple p8 Xf(A)f(B) f(C) p7 p4 X = = = pair. Contradiction. f(D) f(E) p7,f(G) p5 p8 ∈ Xf(A)= f(B)= f(C)= p8 Analogously, if k = 8 then X ⊃{p2,p8,p10}. Since p1 ∈ Xf(D)= f(E)= p7,f(G)= p5 F(q)⊂ N (q) is 8-connected and p2 and p8 are 8-adjacent p ∈ Xf(A)= p ,f(B)= f(C)= p to (or contained in) F(q), then {p ,p ,p }⊂F(q) ⊂ X. 1 10 8 3 5 7 f(D)= f(E)= p ,f(G)= p But this implies that q is also an 8-interior point of X and 7 5 hence {p,q} could not be an 8-simple pair. Contradiction. The proof of the converse implication is constructive and Observe that f(p) has to be 8-adjacent to p, and f(q) has similar to that of Theorem 5. to be 8-adjacent to q. For k = 8, we have to take into account the fact that an On the other hand, a 4-simple pair of 4-simple points 8-simple pair of 8-simple points, neither of them 8-interior, (neither of them 8-interior) must be (up to rotation or sym- must be (up to rotation or symmetry) as in Fig. 20, where metry) as in Fig. 22, where the white squared points can (or the white squared points can (or not) belong to X. not) belong to X. J Math Imaging Vis (2012) 42:76–91 87

Fig. 22 A4-simplepair{p,q} Fig. 25 A k-deletable set not of 4-simple points (neither defining an (N ,k)-retraction 8-interior)

Fig. 26 p not 4-simple without x ∈ X \ D 4-adjacent to p Fig. 23 A4-simplepairof 4-simple points (one 8-interior)

≤ ≤ simple point of X and, for 2 i n, pi is a k-simple point Fig. 24 There exists \ i−1 { } (N , 4)-retraction but q is not of X j=0 pj . Therefore, by Corollary 7, there exists a 4-simple k-retraction F : X −→ X \ D. However, a k-deletable set does not define in general an (N ,k)-retraction, as shown by the example in Fig. 25. Then the multivalued function F defined by F(x)={x} In [8] we gave some partial results related to some well- if x ∈ {p,q} and known strategies to guarantee the preservation of topology under parallel deletion of simple points. {p } if p ∈ X, = 8 10 In this section we address the reciprocal question, i.e., F(p) N {p8,p9} if p10 ∈ X, we give conditions under which the existence of an ( ,k)- : −→ \ retraction F X X D guarantees that D is k-deletable. {p7} if p5 ∈ X, In particular, we prove the following result: F(q)= {p ,p } if p ∈ X, 6 7 5 Theorem 9 Consider X ⊂ Z2 k-connected and let D be is 4-continuous, as can be proved in a similar way as for a subset of the k-boundary of X such that there exists an k = 8, and F(p)(respectively, F(q)) is 4-adjacent to p (re- (N ,k)-retraction F : X −→ X \ D. Then: spectively, q). 1. If k = 4, then D is 4-deletable. Finally, if one of the points is 8-interior, as in Fig. 23, 2. If k = 8 and F(p)⊂ N (p) for every p ∈ D, then D is where the white squared points can (or not) belong to X, 4 8-deletable and made of 8-simple points. then it is not possible to define F in a consistent way be- cause, if we consider any subdivision X of X and any f r r Proof We will prove first that the hypothesis of the theorem inducing F , then the image of the point at the north-west −1 guarantees the existence of a point of D which is k-simple corner in ir (q) should be p3 or p4. Then the image of the −1 in X. point at the north-east corner in i (p) should be p3, p4 or r Consider first the case k = 4. Consider any p ∈ D.Ifp is p5, but it only could be p3 since F(p)⊂ N (p). Moreover, since F(p) must be connected, we must have F(p)={p }. k-simple in X we are done. Suppose that p is not k-simple in 3 \ But this contradicts the fact that F(p) must be 4-adjacent X. Then, we have two possibilities: p is 4-adjacent to X D, to p (and also that the image of the point at the south-west or p is not. − \ corner of i 1(p) should be p , p or p ). This completes Suppose p is not 4-adjacent to X D. Then F(p) is a r 8 9 10 N ∩ \ the proof of the theorem.  4-connected subset of (p) (X D) that is 8-adjacent but not 4-adjacent to p,soF(p) must be a single point. Hence The example of Fig. 24 shows that, without imposing the F(p)={x}⊂X \ D is 8-adjacent but not 4-adjacent to p. condition that F(p)∪{p} and F(q)∪{q} k-connected, the Since p is not 4-simple, by Theorem 4, there exists d ∈ X 4- existence of an (N ,k)-retraction F : X −→ X \{p,q}, with adjacent to p which cannot be connected to x by a 4-path in {p,q} a simple pair, does not imply, for k = 4, that p and q N (p)∩X. In fact, d ∈ D, because if d ∈ X\D, then F(p)= are both 4-simple points of X. {x} and F(d)={d} would not be 4-adjacent. Therefore p, x and d must be situated, up to rotation or symmetry, as in Fig. 26, where the white squared points can (or not) belong 7 (N ,k)-Retractions and k-Deletable Sets to X. Then it is not possible to define F(d)⊂ N (d), such that D k X If is -deletable in , by Theorem 6, there is an order- F(p)∪ F(d) ⊃{x} is 4-connected, because N4(p) ∩ X \ ={ }n ing of the points of D, D pi i=1, such that p1 is a k- D =∅. Contradiction. 88 J Math Imaging Vis (2012) 42:76–91

Fig. 27 p not 4-simple with x ∈ X \ D 4-adjacent to p Fig. 28 p not 8-simple such that F(p)⊂ N4(p)

Therefore, there is x ∈ X \ D 4-adjacent to p. This point Therefore, we have proved that the existence of an x may not be in F(p) but, by Corollary 8 (i), it must be (N ,k)-retraction in the conditions of the theorem guaran- 4-connected in N (p) ∩ X to F(p). Moreover, since p is tees, for k = 4, the existence of at least a 4-simple point in not 4-simple, then, by Corollary 8 (ii), there exists d ∈ D D, and, for k = 8, that all points of D are 8-simple. 4-adjacent to p which cannot be connected to x by a 4-path To prove that D is k-deletable we use induction on the in N (p) ∩ X. Therefore p, x and d must be situated, up to rotation or symmetry, in one of the configurations of Fig. 27, cardinal of D. where the white squared points can (or not) belong to X. If D consists of just one point, then the result is immedi- In the case on the left, we have the following: F(p)∪ ate by Theorem 5 and the definition of a k-simple point. ∈ F(d) is 4-connected. Then F(d) ∪{d} can not be 4- If D consists of more than one point, consider p Dk- = \{ } connected (if it were, d would be connected to x by a 4-path simple. Then, we can delete it obtaining X X p and = \{ } in N (p) ∩ X). Therefore, the only possibility for F(d) is D D p and, since p is k-simple in X, after deleting it one of the points to the north or to the south of p. Hence from X: \ the point to the north or to the south of p must be in X D, –nok-connected component of X vanishes or is split in so the situation shown on the left reduces to that on the several components, right. –nok¯-connected hole in X is created or is merged with the For the case on the right, again F(p) ∪ F(d) is 4- background or with another such hole. connected but F(d)∪{d} can not be 4-connected. There- fore, F(d) must be equal to x or to the point to the south On the other hand, since F |X : X −→ X \ D = X \ D of p. Consider the points r to the right of d and s to the is still an (N ,k)-retraction, by the induction hypothesis, D south of d. Suppose that F(d)={x}. Then neither r nor s is k-deletable in X , i.e., after deleting D from X : can belong to X, because if either of them were in X, then its image under F should be 4-adjacent to (or contain) x, –nok-connected component of X vanishes or is split in which is impossible, since F is an (N ,k)-retraction. There- several components, ¯ fore d is 4-simple. On the other hand, if F(d)is equal to the –nok-connected hole in X is created or is merged with the point to the south of p, then s ∈ X (if s ∈ X, then d would background or with another such hole. be 4-connected to F(d), and hence to F(p), and hence to Therefore, after deleting D ={p}∪D from X: x,inN (p) ∩ X). Neither is r ∈ X, because if r ∈ X, then F(r)∪ F(d) should be 4-connected, which is impossible, –nok-connected component of X vanishes or is split in since F is an (N ,k)-retraction. Therefore, d is also 4-simple several components, in this case. –nok¯-connected hole in X is created or is merged with the Suppose now that k = 8 and F(p)⊂ N4(p) for all p ∈ background or with another such hole, D. Suppose, for some p ∈ D, that p is not 8-simple in X. i.e., D = D ∪{p} is k-deletable in X. This ends the proof Then, by Corollary 8 (ii), there exists d ∈ N (p) ∩ D which  cannot be connected to F(p) by an 8-path in N (p) ∩ X. of the theorem. Since p is an 8-boundary point and F(p)⊂ N4(p), F(p)is formed by at most three points. Moreover, if it was formed The proof of the previous results depends on the exis- by three points, then d would be connected to F(p) by a tence of a simple point in D. path in N (p) ∩ X. The example on the left of Fig. 29 (see also Fig. 24) Therefore F(p)is formed by one or two points and, since shows that, in the hypothesis of the theorem, for k = 4, not d cannot be connected to F(p) by a path in N (p) ∩ X,we all the points need to be simple. have (up to rotation or symmetry) only three possibilities for On the other hand, the example on the right shows that F(p)and d displayed in Fig. 28. for k = 8 the result is no longer true if we do not require Since p and d are 8-adjacent, then F(p)∪ F(d)must be that F(p)⊂ N4(p). The reason is that in this case, not all 8-connected, but this is impossible without connecting F(p) points of D have to be 8-simple. If we add this condition to and d by an 8-path in N (p) ∩ X. Contradiction. Theorem 9 we obtain the following result: J Math Imaging Vis (2012) 42:76–91 89

Fig. 31 p,q ∈ D 8-simple in X, q not 8-simple in X \{p} with N Fig. 29 There exists ( ,k)-retraction and: D 4-deletable but not all x,y ∈ X in different 8-connected components of N (q) ∩ (X \{p}) points of D are 4-simple (left), D is not 8-deletable (right)

For the figure on the left, F(p)∪ F(x)and F(p)∪ F(y) cannot both be 8-connected, since F is an (N , 8)-retraction. For the figure on the right, since F(p)∪ F(q)must be 8- connected, either F(p)={y} or F(q)={x}.ButifF(p)= {y}, then F(p)∪F(x)cannot be 8-connected, and if F(q)= {x}, then F(q)∪ F(y)cannot be 8-connected. Fig. 30 p,q ∈ D 8-simple in X, q not 8-simple in X \{p} with In every case we get a contradiction. Hence, for every x,y ∈ X in different 8-connected components of N (q) ∩ (X \{p}) p ∈ D, q is 8-simple in X \{p}. Now, the result follows, as in Theorem 9, using induction Theorem 10 Consider X ⊂ Z2 and let D be a set of on the cardinal of D, as follows: k-simple points of X such that there exists an (N ,k)- If D consists of just one point, then the result is immedi- retraction F : X −→ X \ D. Then D is k-deletable. ate. If D consists of more than one point, consider any 8- ∈ = Proof For k = 4 it is an immediate consequence of the pre- simple point p D. Then, we can delete it obtaining X X \{p} and D = D \{p} such that D is a set of 8-simple vious theorem. = ∈ points of X such that F |X : X −→ X \ D = X \ D is still For k 8, we will prove that if we delete any p D, then \{ } \{ } an (N , 8)-retraction. Therefore, by induction hypothesis, D the points of D p are 8-simple points of X p . Consider any p ∈ D. Suppose that, after deleting p, there is 8-deletable in X and, by an argument similar to that of = ∪{ } exists q ∈ D \{p} which is not 8-simple in X \{p}. Then, Theorem 9, D D p is 8-deletable in X.  q is an 8-boundary point of X such that, before deleting p, This ends the proof of the theorem. the number of 8-connected components of N (q) ∩ X which Remark 5 Alternatively, Theorem 10 can be proved show- were 8-adjacent to q was equal to 1 and, after deleting p ing that if D is a set of 8-simple points of X such that there the number of 8-connected components of N (q) ∩ X \{p} exists an (N , 8)-retraction F : X −→ X \ D, then D sat- is different from one. If that number were 0 this would im- isfies Ronse sufficient conditions for a set D ⊂ X to be 8- ply that p is the only point 8-adjacent to q, but then F(p) deletable in X (see, for example, [13]), which can be stated and q would be in two different 8-connected components of as follows: N (p) ∩ X, which is impossible because p is 8-simple. Therefore, p and q are 8-adjacent points such that there R1. All points of D are 8-simple. are two 8-connected components of N (q)∩(X \{p}) which R2. For every two 4-adjacent points p,q ∈ D, {p,q} is an are 8-adjacent to q. Moreover, if p and q were 8-adjacent 8-simple pair. but not 4-adjacent, the deletion of p would not affect the 8- R3. D does not contain any 8-component of X formed by connectivity of N (q) ∩ X. This is due to the fact that the 2, 3, or 4 mutually 8-adjacent points. deletion of a corner point of an 8-connected component of However, for k = 4, if D is a set of 4-simple points of X N ∩ (q) X can not split it in two components. such that there exists an (N , 4)-retraction F : X −→ X \ D, Therefore p and q are situated (up to rotation or sym- even though that we have seen that D is 4-deletable, D does ∈ metry) as in Fig. 30, where x,y X are points in different not necessarily have to satisfy Ronse conditions, which for 8-connected components of N (q) ∩ (X \{p}). k = 4 can be stated as follows: In the figure on the left, the point to the left of p cannot belong to X because p cannot be an 8-interior point of X. R1. All points of D are 4-simple. ∈ On the other hand, if in the figure on the right, either of the R2. For every two 8-adjacent points p,q D, p (respec- \{ } \{ } points south of p or north of q were in X then its analy- tively, q)is4-simpleinX q (respectively, X p ). sis would reduce to the case on the left. Therefore, we can The reason is that a deletable set D ⊂ X may have points suppose that neither of them belongs to X. Therefore, p, with the local configuration (up to symmetry) of Fig. 32, q, x and y are situated (up to rotation or symmetry) as in where p,q,s ∈ D, t ∈ X \ D and the white squared points Fig. 31. can (or not) belong to X. 90 J Math Imaging Vis (2012) 42:76–91

{ } Fig. 32 p,q does not satisfy References Ronse conditions for k = 4

1. Boxer, L.: Digitally continuous functions. Pattern Recognit. Lett. 15, 833–839 (1994) 2. Boxer, L.: A classical construction for the digital fundamental group. J. Math. Imaging Vis. 10, 51–62 (1999) In this case, the pair {p,q} does not satisfy Ronse condi- 3. Boxer, L.: Properties of digital homotopy. J. Math. Imaging Vis. \{ } 22, 19–26 (2005) tions because q is not 4-simple in X p . 4. Boxer, L.: Homotopy properties of sphere-like digital images. J. Math. Imaging Vis. 24, 167–175 (2006) 5. Chen, L.: Gradually varied surface and its optimal uniform ap- 8 Conclusions and Future Work proximation. Proc. SPIE 2182, 300–307 (1994) 6. Chen, L.: Discrete Surfaces and : A Theory of Digital- We have presented in this paper a theory of continuity in Discrete Geometry and Topology. Scientific and Practical Com- puting, Rockville (2004) digital spaces, using multivalued functions, which extends 7. Escribano, C., Giraldo, A., Sastre, M.A.: Digitally continuous the one introduced by Rosenfeld and provides a framework multivalued functions. In: Coeurjolly, D., Sivignon, I., Tougne, to define topological notions in a far more realistic way than L., Dupont, F. (eds.) Discrete Geometry for Computer Imagery by using just single-valued digitally continuous functions. 2008. Lecture Notes in Computer Science, vol. 4992, pp. 81–92. Springer, Berlin (2008) In particular, we have shown that the basic morphological 8. Escribano, C., Giraldo, A., Sastre, M.A.: Thinning algorithms operations of dilation and closing are continuous functions as multivalued N -retractions. In: Brlek, S., Reutenauer, C., and that, although the dual operations of erosion and open- Provençal, X. (eds.) Discrete Geometry for Computer Imagery ing cannot be modeled as continuous functions on the set of 2009. Lecture Notes in Computer Science, vol. 5810, pp. 275– black pixels, they are so if we consider them defined on the 287. Springer, Berlin (2009) 9. Giraldo, A., Gross, A., Latecki, L.J.: Digitizations preserving set of white pixels. shape. Pattern Recognit. 32, 365–376 (1999) On the other hand, the deletion of simple points and 10. Giraldo, A., Sanjurjo, J.M.R.: Density and finiteness. A discrete simple pairs can be completely characterized in terms of approach to shape. Topol. Appl. 76, 61–77 (1997) digitally continuous multivalued functions. This fact has 11. Han, X., Xu, C., Prince, J.: A topology preserving level set been used to characterize thinning algorithms in terms of method for geometric deformable models. IEEE Trans. Pattern 25 digitally continuous multivalued functions. We have shown Anal. Mach. Intell. (6), 755–768 (2003) N : −→ \ 12. Khalimsky, E.: Topological structures in computer science. J. that the existence of an ( ,k)-retraction F X X D Appl. Math. Simul. 1, 25–40 (1987) guarantees that D is 4-deletable (respectively, 8-deletable) 13. Klette, R., Rosenfeld, A.: Digital Geometry. Elsevier, Amsterdam whenever D is made of 4-boundary (respectively, 8-simple) (2004) points. The converse is not true in general although it holds 14. Kong, T.Y.: A digital fundamental group. Comput. Graph. 13, in certain particular important cases which are at the basis 159–166 (1989) 15. Kong, T.Y., Rosenfeld, A.: Digital topology: introduction and sur- of many thinning algorithms. vey. Comput. Vis. Graph. Image Process. 48, 357–393 (1989) The notion and main properties of a digitally continuous 16. Kong, T.Y., Rosenfeld, A. (eds.): Topological Algorithms for Dig- multivalued function are presented for any dimension. The ital Image Processing. Elsevier, Amsterdam (1996) results on retractions at the end of Sect. 3 are stated for Z2, 17. Kovalevsky, V.: A new concept for digital geometry. In: Ying-Lie, since their main role is that of justification of the appropri- O., et al. (eds.) Shape in Picture. Proc. of the NATO Advanced Re- search Workshop, Driebergen, The Netherlands, 1992. Computer ateness of our notion of continuity, although they are easily and Systems Sciences, vol. 126. Springer, Berlin (1994) extendable to higher dimension. The same is true for the re- 18. Ronse, C.: A topological characterization of thinning. Theor. sults on mathematical morphology. Several of the results in Comput. Sci. 43, 31–41 (1988) this paper may be regarded as tools for thinning algorithms 19. Rosenfeld, A.: Continuous functions in digital pictures. Pattern for images in Z2. We are working on analogous results for Recognit. Lett. 4, 177–184 (1986) images in Z3. 20. Rosenfeld, A.: Digital topology. Am. Math. Mon. 86(8), 621–630 (1979) Finally, we are also working on the design of new parallel 21. Ségonne, F.: Active contours under topology control-genus pre- thinning algorithms based on the previous construction of an serving level sets. Int. J. Comput. Vis. 79(2), 107–117 (2008) (N ,k)-retraction. 22. Soille, P.: Morphological operators. In: Jähne, B., et al. (eds.) Sig- nal Processing and Pattern Recognition. Handbook of Computer Acknowledgements The authors thank the referees for helpful com- Vision and Applications, vol. 2, pp. 627–682. Academic Press, ments and suggestions which have helped to improve the final version San Diego (1999) of the paper. 23. Tsaur, R., Smyth, M.B.: “Continuous” multifunctions in discrete Antonio Giraldo has been supported by Ministerio de Ciencia e In- spaces with applications to fixed point theory. In: Bertrand, G., et novación (MICINN MTM2006–0825 and MTM2009-07030). All au- al. (eds.) Digital and Image Geometry: Advanced Lectures. Lec- thors have been supported by Comunidad Autónoma de Madrid and ture Notes in Computer Science, vol. 2243, pp. 75–88. Springer, Universidad Po litécnica de Madrid (UPM-CAM Q061010133). New York (2001) J Math Imaging Vis (2012) 42:76–91 91

Carmen Escribano received a Ba- María Asunción Sastre received a chelor’s degree in Mathematics from Bachelor’s degree in Mathematics the Autonoma University of Madrid from the Complutense University of (Spain)), and she is currently doing Madrid (Spain), and a Ph.D. De- her Ph.D. at the Technical Univer- gree from the Technical University sity of Madrid (Spain). She is cur- of Madrid (Spain). She is currently a rently a lecturer at the Computer senior lecturer at the Computer Sci- Science School of the Technical ence School of the Technical Uni- University of Madrid. Her current versity of Madrid. Her current re- research interests include Orthog- search interests include Orthogonal onal , Operator The- Polynomials, Fractal Geometry and ory, Fractal Geometry and Digital Digital Topology and applications. Topology and applications.

Antonio Giraldo received a Bach- elor’s degree in Mathematics, and a Ph.D. Degree in Mathematics from the Complutense University of Madrid (Spain). He is currently an associate professor, and past chair, of the Applied Mathematics De- partment, at the Computer Science School of the Technical University of Madrid. His current research in- terests include Topology and it ap- plications to Digital Images and Dy- namical Systems, and also Orthog- onal Polynomials.