621-630. [RM89] [SK76] Roenfeld, A. and Melter, R. A., Digital geometry, The Mathematical Intelligencer, vol. 11, No. 3, 1989, pp. 69-72. Sklanky, J. and Kibler, D. F., A theory of nonuniformly digitized binary picture, IEEE Tranaction Sytem, Man & Cybernetic, vol. SMC-6, Sept.,1976, pp.637-647. - 16 -
which p=b wa entered); ele advance the current pixel p to the next clockwie pixel in M(b). end while End While the Moore-neighborhood contour tracing algorithm will work correctly on the example of Fig. 5 whether the pixel marked S i black or not, it i not guaranteed to work correctly on all 8-connected pattern. It i left a an exercie for the reader to find uitable counter-example. However, performance can again be improved by waiting to encounter the tarting pixel for a third time. Thee algorithm are ueful neverthele, particularly in mot practical ituation where the thickne of the pattern i much greater than one pixel. In uch ituation counter-example are much harder to find. A more eriou drawback i that if the pattern P ha hole the contour tracing algorithm decribed above only deliver the outer boundary of P and not the boundarie of the hole. Such would be the cae for example for pattern uch a the letter O, P, B, Q, D and R. In order to make precie tatement about the ituation in which thee algorithm are guaranteed to compute the entire boundary of connected et care mut be taken in defining the connectivity of the background and the hole [RM89], [Ro79]. A pecial cae of interet i the that when not only the pattern i 4-connected but the background (et of white pixel) i alo 4-connected. It i left a an exercie for the reader to determine if the Moore-neighborhood contour tracing algorithm will work correctly on uch image. Finally we mention that the contour tracing algorithm decribed above are inherently equential and a mitake made early in the game tay or amplifie the problem later on. One can attribute the weaknee of thee algorithm to their equential nature although their weaknee may be overcome by additional equential procedure. However, we hall ee in later chapter that with parallel algorithm we can avoid uch problem in a impler and more elegant manner. 4. Reference [De72] [De70] [FT83] [GS87] [Po40] [Ro79] Deutch, E. S., Thinning algorithm on rectangular, hexagonal, and triangular array, Communication of the ACM, vol. 15, No. 9, Sept. 1972, pp. 827-837. Deutch, E. S., On parallel operation on hexagonal array, IEEE Tran. Computer, vol. C-19, Oct. 1970, pp. 982-983. Feje Toth, New reult in the theory of packing and covering, in Convexity and It Application, P. M. Gruber and J. M. Will, ed., Birkhauer, Bael, 1983, pp. 318-359. Grunbaum, B. and Shephard, G. C., Tiling and Pattern, W. H. Freeman and Co., 1987. Polachek, H., The tructure of the honeycomb, Scripta Mathematica, vol. 7, 1940, pp. 87-98. Roenfeld, A., Digital topology, American Mathematical Monthly, vol. 86, 1979, pp. - 15 -
S S Fig. 6 Searching for the next black contour pixel in Moore-neighborhood contour tracing. Fig. 5 Square tracing an 8-connected pattern. rent pixel p i black, the Moore neighborhood of p i examined in a clockwie manner tarting with the pixel from which p wa entered and advancing pixel by pixel until a new black pixel in P i encountered a illutrated in Fig. 6. The algorithm i decribed more preciely below. ALGORITHM Moore-Neighborhood-Tracing Input: A quare teellation T containing a connected component P of black cell. Output: A equence B (b 1, b 2,..., b k ) of boundary pixel. Begin {Initialization: find a pixel in P, initialize B, define M(p) to be the Moore neighborhood of the current pixel p} 1. Set B to be empty. 2. From bottom to top and left to right can the cell of T until a pixel of P i found (until the current pixel p= i a black pixel of P), inert in B. Let b denote the current boundary point, i.e., b=. 3. Backtrack (move the current pixel to the pixel from which wa entered) and advance the current pixel p being examined to the next clockwie pixel in M(b). while p i not equal to do if p i black, inert p in B, et b=p and backtrack (move the current pixel to the pixel from - 14 -
p Fig. 4 A pixel in a quare teellation and it eight-neighbor. Update p. ele turn right (viit the right adjacent pixel of p); Update p. end while End Note: The notion of left and right in the above algorithm i not to be interpreted with repect to the page or the reader but rather with repect to the direction of entering the current pixel during the execution of the can. Fig. 5 how an example of how the quare tracing algorithm tarting at the pixel marked S produce a equence of boundary pixel in the cae P i 8-connected. It would be nice to be able to prove that Algorithm Square-Tracing alway work correctly, i.e., that for all connected pattern it extract the entire et of boundary pixel a defined above. Unfortunately thi i not the cae. Note that in Fig. 5 the 8-connected pattern conit of two eparate 4-connected component, i.e., two 4-connected component that are not 4-connected to each other. If the black pixel marked S were marked white intead then the algorithm would only trace one of the 4-connected component of P. Since there are imple procedure for converting 8-connected pattern to 4-connected one without appreciably changing their hape it would be nice to be able to prove that the quare tracing algorithm alway work correctly at leat for 4-connected pattern. It i left a an exercie for the reader to provide an example of a 4-connected pattern that i not completely contour traced either by the quare tracing algorithm. However, there are way of modifying the algorithm to obtain an increae in the chance that the algorithm will terminate correctly in practice. For example one may try to make the algorithm continue executing when S i encountered for the econd time to determine if an un-explored portion of P i dicovered and terminate only after S i encountered again for the third time. More popular modification of Algorithm Square-Tracing to handle 8-connected pattern dicard the left-turn-right-turn rule altogether. One uch procedure i known a Moore-neighborhood tracing. The eight neighbor of a pixel hown in Fig. 4 are alo referred to in the literature a the Moore neighborhood of a pixel. In the Moore neighborhood tracing algorithm, when the cur- - 13 -
p Fig. 3 A pixel in a hexagonal teellation and it ix neighbor. ueful definition of border point which are intimately related to the boundary. We ay that a black pixel of P i a 4-border point if at leat one of it 4-neighbor i white. We ay that a black pixel of P i an 8-border point if at leat one of it 8-neighbor i white. One particularly imple procedure for contour tracing connected component of binary picture i called quare-tracing and i decribed below. The idea i to imagine you are a bug crawling along the black and white boundary pixel and making 90 degree turn to the left or right with repect to the direction in which you are pointing at any one given moment depending on what the color of the pixel you are tanding i. ALGORITHM Square-Tracing Input: A quare teellation T containing a connected component P of black cell. Output: A equence B (b 1, b 2,..., b k ) of boundary pixel. Begin {find a pixel in P and initialize B} 1. Set B to be empty. 2. From bottom to top and left to right can the cell of T until a pixel of P i found (until the current pixel p being examined i the black tarting pixel of P). Inert in B. Turn left (viit the left adjacent pixel of p). Update p. while p not equal to do if the current pixel p i black inert p in B and turn left (viit the left adjacent pixel of p); - 12 -
f f p f each type of teellation T we can define an object or pattern in T a a connected component of black pixel. Thu one of the firt tage in a pattern recognition ytem i to actually find all the object in the digitized field of view T. Conider for example an hexagonal teellation T and let P denote the et of pixel in T that are black. We ay that two pixel in T are neighbor if they hare an edge in common. We ay that P i connected (or a connected component) if for every pair of pixel p i, p j in P there exit a equence of pixel p i,..., p j uch that (1) it i contained in P and (2) every pair of pixel adjacent in the equence are neighbor of each other. We can obtain analogou definition of connectivity for quare array. However, becaue we now have two different type of neighbor we obtain two different type of connectivity. Accordingly let P be a et of black pixel in a quare teellation T. We ay that P i 4-connected (or a 4-connected component) if for every pair of pixel p i, p j in P there exit a equence of pixel p i,..., p j uch that (1) it i contained in P and (2) every pair of pixel adjacent in the equence are 4-neighbor of each other. Similarly, We ay that P i 8-connected (or an 8-connected component) if for every pair of pixel p i, p j in P there exit a equence of pixel p i,..., p j uch that (1) it i contained in P and (2) every pair of pixel adjacent in the equence are 8-neighbor of each other. Obviouly a 4-connected pattern i an 8- connected pattern but not vice-vera. 3. Contour Tracing Fig. 2 A pixel in a triangular teellation and it three type of neighbor. One method of finding and analyzing the connected component of T i to can T in ome manner until a border pixel of a component P i found and ubequently to trace the boundary of P until the entire boundary i obtained. The boundary thu obtained can be tored a a doublylinked circular lit of pixel or a a polygon of the boundary of the pixel in quetion. Such procedure are generally termed contour tracing. There i frequently no tandard formal definition given of the boundary of a connected pattern. In practice the boundary i what eem appropriate a the boundary to human and algorithm are judged in accordance to how well they agree with human perception. However in order to make more precie tatement about our algorithm there are two - 11 -
Triangular Hexagonal Square view the reulting grid a a graph, all the node in thi graph have degree ix wherea the degree are four and three in quare and hexagonal teellation, repectively. More importantly however are the neighborhood propertie of a ingle pixel. Conider the pixel marked black in Fig. 2 and call it p. The neighborhood of p i defined a the et of pixel that interect p. We ee that p ha 12 neighbor and thee can be claified into three group: thoe that have an edge in common with p (hown haded in Fig. 2), and thoe that only have a point in common. Of the latter we can ditinguih between thoe that are facing a vertex of p (marked f) and thoe that are kewed with a vertex of p (marked ). The complicated nature of thi ituation and it complicating effect on the reulting image proceing algorithm deigned to work on uch teellation make thi type of teellation un-attractive although much reearch wa done on all three type of teellation during the early day of pattern recognition [De72]. 1.2 Hexagonal Teellation From the point of view of the neighborhood propertie of a ingle pixel, the hexagonal teellation i the mot elegant a can be een from Fig. 3 where a black pixel p i hown urrounded by it ix neighbor. All the ix neighbor belong to the ame equivalence cla in the ene that they hare one edge with p. Beide their ue in image proceing hexagonal array are notoriouly preent in nature ingularly evident in the honeycomb of the bee. A a reult many facinating mathematical propertie of thee teellation and their 3-dimenional relative have been the ubject of invetigation for two thouand year [Po40]. 1.3 Square Teellation Square teellation are the mot widely ued in practice. Fig. 4 illutrate a black pixel p and it neighborhood. We ee that p ha 8 neighbor and thee can be claified into two group: thoe that have an edge in common with p (hown haded in Fig. 4), and thoe that only have a point in common. The haded group are called the 4-neighbor of p wherea the totality of neighbor i called the 8-neighborhood of p. Thu a 4-neighbor i an 8-neighbor but not vice-vera. 2. Connectivity Fig. 1 Illutrating the three type of regular teellation. One of the mot important concept in image proceing i the notion of connectivity, In - 10 -
CHAPTER 2 GRIDS, CONNECTIVITY AND CONTOUR TRACING Godfried Touaint ABSTRACT Thi chapter introduce the three baic type of grid ued to repreent a digital pattern: triangular, hexagonal and quare. The notion of 4-connectedne and 8-connectedne are defined and their impact on tracing the boundary of a digital pattern i analyzed. 1. Teellation A teellation of the plane i eentially a partitioning of the plane into region. Typical example of bounded region that form teellation are a quilted bedpread and a tiled bathroom floor. There exit coniderable variation in the terminology of teellation. In the mathematical literature the word tiling and moaic are often ued and one alo encounter the word paving and parqueting [GS87]. More formally we ay that a planar teellation T i a countable family of cloed et T = {T 1, T 2,...} which cover the plane without gap or overlap. A in a well contructed bathroom floor we would not want ome tile to be miing (gap) or to be lying on top of other (overlap). More preciely, the union of all the et T 1, T 2,... (alo referred to a cell) contitute the entire plane and the interection of the interior of every pair of cell i empty. It i ueful to define two related notion here. A packing i a family of et which ha no overlapping. A covering i a family of et that ha no gap. Clearly, a teellation i both a packing and a covering. Furthermore, when the object of interet i not the entire plane but a ubet of it a for example a imple polygon then the term teellation i replaced by partition. Covering and packing of the plane are of interet to mathematician and a good urvey on recent reult in thi area can be found in [FT83]. Partition and other covering of polygon, on the other hand, are very ueful in computer cience and will be of interet when we tudy feature extraction and the meaurement of hape. Here we are intereted in teellation a model for the repreentation of digital image and therefore it i convenient to let all the cell (pixel in thi context) be the ame hape and ize. Such teellation are termed monohedral. Thi mean that every pixel in T i congruent either directly or reflectively to one fixed hape T called the prototile or protocell. Thi i of coure not a neceary condition for obtaining effective computer viion ytem. The teellation induced by the ditribution of rod and cone in the retina of our eye are certainly not monohedral. Some reearch ha alo been done on image proceing algorithm on non-monohedral teellation [SK76]. However, our primary concern i with a retricted verion of monohedral teellation. If we alo init that each cell be a regular polygon, i.e., a polygon with all it ide and angle equal, then we obtain the o-called regular teellation. It turn out that there exit only three different type of uch teellation: triangular, hexagonal and quare a illutrated in Fig. 1. 1.1 Triangular Teellation Triangular teellation are the mot complicated of the three in ome ene. For one, if we - 9 -