28 ALGORITHM FOR CONSTRUCTION OF THICKNESS RASTER A.E.Hmelnov1 1 Institute for System Dynamics and Control Theory SB RAS, 664033 Irkutsk, Lermontov St. 134, (3952)-453-102, [email protected] This report introduces the concept of thickness raster and presents an algorithm for its construction. The thickness raster is constructed using the Euclidean distance raster of a source image. Using the thickness raster the skeletons of uniform areas of the image could also be found. Introduction The distance raster (distance map) is an image, which contains in its pixels the distances from the corresponding points to the nearest object from a given set of objects [1]. A distance transformation is an algorithm for construction of the distance raster from a binary image describing the set of objects. As a result of distance map construction the information about source image is assigned to each pixel, which wasn’t locally available before, i.e. each pixel receives information, which didn’t contain in its fixed neighborhood. By analyzing this information it is possible to implement effectively different image processing algorithms (see [1] for review of applications of distance transformation). This report introduces the concept of thickness raster and presents an algorithm for its construction. As a result of thickness raster construction it becomes known for each pixel, to how significant uniform image part it belongs. By analyzing the thickness raster it is possible to detect the skeleton of the image areas [2], and, in contrast to traditionally used for this purpose morphological analysis [3], the most significant skeleton points are naturally detected here, as a points, which have some (or enough) support in the thickness raster. Problem statement Let us consider the raster image I of the size MxN (width M and height N). The expression I[i,j] denotes the color of j-th pixel in the line i. The distance raster Dt(I) is an image of the same size as I, with the element Dt[i,j] containing the distance to the nearest to the point (i,j) pixel of I, having the color different from I[i,j]. Fig. 1. An example of distance raster It is possible to use various functions as a distance when computing the distance raster. Among them the Euclidean distance is preferable for most part of problems, because this distance is isotropic. Other distances are used mostly to simplify computation of the distance transform. Let us call the thickness raster Wt(I) of a binary image I the image, such that the value of its pixel is the maximal radius of the circle of constant color in I, which covers the pixel. We can consider Dt(I) as an image, such that the value of its pixel is the maximal radius of the circle of constant color in I, centered in the pixel. When defining Wt(I) we check not only 29 the uniform circles centered in the point, but also all the uniform circles, which cover the image point by any their part. So the thickness raster contains information about thickness of the area of constant color in each point of the image I. A simple algorithm for construction of thickness raster Let us denote WI=Wt(I), DI=Dt(I). It is possible to use very simple but inefficient algorithm for construction of WI from DI, which, meanwhile, allows to better understand the definition of Wt(I): 1. 2. 3. 4. Algorithm 1. Construction of thickness raster by circle fill Initialize WI[i,j] := 0; For each image point p=(i,j) do: For each image point q=(k,l), such that D(p,q)<DI[i,j] do: WI[k,l] := max(WI[k,l], DI[i,j]); Thus the algorithm fills the circle of radius DI[i,j] in each image point (i,j), using the raster operation of the maximum of two values (the value of the pixel and the value of the fill color). It should be noted that this algorithm computes an approximation to the true thickness raster, in which the best distance values found could be less than the maximal circle radii, but at most by 0.51/2 pixel, because the algorithm considers only those uniform circles, which are centered in some pixel (and could miss the very best circles, with fractional centers). The improved thickness transform algorithm, which is discussed below, also constructs just the same approximation to the true thickness raster. The time complexity of the simple algorithm is O(M*N*(D2)m) , where (D2)m denotes the mean squared circle radius (the mean squared value of DI elements). An improved algorithm for construction of thickness raster To construct a more effective algorithm we’ll use the data structure, which represents the borders of the circles around each pixel of DI the limit table. The limit table (LT) is an array, which contains for each raster column the list of active circle borders for already visited pixels of DI. The proposed algorithm works in two passes: the first is top-down and from the left to right, the second is bottom-up and from the right to left. The same approach is used in the majority of sequential algorithms for distance transform. Fig. 2. The order of raster processing The two-pass mode allows to check the pixels of a DI pixel influence area after visiting its center. (Рис. 2), thus substantially simplifying the algorithm structure. This way each circle will be completely considered after completing both passes. Algorithm 2. A general structure of each pass 1. For each image row i do: 2. For each image column j do: 3. Add to LT the information about the circle with radius DI[i,j] and center (i,j). 4. D := the first radius in the list of borders of the column j in LT; 5. WI[i,j] := max(WI[i,j], D); 6. If the first border in the column j is limited by i, then remove the border from LT. The information about circle borders is represented by records TLimit, which contain the following fields: Next – the pointer to the next border in the list for the raster column; D – the radius of the circle; 30 L – the raster line, after which the border goes. Each list of column borders is ordered by ascending of L (and, hence, by descending of D). A a A r Fig. 3. Circle overlapping To justify the last statement (that ordering the list by ascending of L means its ordering by descending of D) let us consider the interaction of two circles, which form the influence areas of the corresponding pixels of DI (Fig. 3). The area of intersection of the circles belongs to the influence area of the largest of them. That’s why the influence area of the smaller circle is the part of the circle which emerges from the larger one. Because the algorithm starts to consider each circle just after visiting its center (Fig. 2), the interval, which corresponds to any of the records in the limit table (from the current raster line to the circle border) is completely contained in the circle. The intervals for all the previous records in the list are also contained in the circle for the limit considered, because they have smaller values of L. So, once the previous borders remain in the list, they should have larger values of D, or else they would be covered by the current limit. Let us consider the most complex part of the proposed algorithm – Step 3, which adds circles to the limit table. Let us denote R=DI[i,j]. Algorithm 3. Adding circle information to the limit table 1. Find the range of columns j0…j1 influenced by the circle; 2. For each k from j0 to j1 do: 3 Find the limit line l of the circle in the column k l := i+max {t| D((j,0),(k,t))<R}; In the list LT[j] skip all the borders, having D>R (skip the stronger limits); 5 If there exists the stronger border with Ll then Exit (the added circle is covered by the existing ones in the column); 6 Remove from LT[k] the weaker (D<R) limits having Ll; 7 Add to LT[k] the record for the new border of the level R after the line L or merge with the existing record of the same R and smaller L; Let us make several remarks about effective of implementation of the algorithm steps. The simplest way to execute step 1 is to assign the maximal possible values to the range limits: j0 := j-R; j1 := j+R; But it is possible to substantially reduce the range by taking into account the values of neighbor pixels. Let DI[i,j] = R, and DI[i-1,j] = Q, Q>R, i.e. the immediate neighbor pixel in the column has larger distance to the objects. Let us move the origin of coordinate system to the point (i,j). The points (x,y) of intersection of the circles should satisfy the equations: x2+y2=R2 , x2+(y+1)2=Q2/ Hence y=(Q2-R2-1)/2, x2= R2-((Q2-R2-1)2)/4. The expression for x allows to contract the range of column indices to consider. Let us consider now the case when DI[i,j-1] = Q, Q>R, i.e. the immediate neighbor in the row has larger radius. By replicating the previous considerations after swapping axes we get: x=(Q2-R2-1)/2 . When Q>R and both values are integer, the value of x0, and, hence, j0 = j. In a similar manner we can justify that when the right pixel (i,j+1) has larger radius j1 = j. The numbex of times required to execute all the steps #3 of the loop is estimated by O(R), because it is possible to compute the value of t starting from the value found for the previous step, and the limit value passes the range from 0 to R and back to 0 (at most 2R-1 values to check). The drawback of the algorithm considered is that it requires to check from the very 4 31 beginning for each loop step all the elements of the lists LT[k]. To clear this drawback, we should add some complexity to the algorithm, by adding links between the elements of neighbor lists, which immediately refer to the items of the corresponding level. The record TLimit is extended by adding the following two fields: NextR – the limit in the next column of the same or higher level; NextL – the back (to NextR) link, the limit in the previous column of the same or lower level. After changing the data structure the step 4 of the algorithm will be executed in constant time for most steps of the loop by k. The total number of borders removed from LT on the step 6 is not higher than the number of added borders, which is, in turn, limited by the sum by all circles of the length of the column range influenced by the circle (j1-j0+1)2R+1. Skel(A) = {x | |Arg min yA D(x,y)|>1}. Fig. 5. The skeleton points detected using thickness raster Each center of the circle, which forms the thickness raster (has some pixels, corresponding to them in WI), is a part of the skeleton of the corresponding image area, because the growth of each circle is limited by at least three border points. To detect the skeleton pixels it is required to collect all the pixels of DI, which form WI. Conclusion This report introduces the concept of thickness raster of binary image and presents an algorithm for its construction. Computation of thickness raster can be used as a constituent part of complex image analysis and processing algorithms. Fig. 4. An example of thickness raster (for the distance raster from Fig. 1). Thus, by considering the total time required to execute all the steps of the loop, it may be inferred that the time complexity of the proposed algorithm is estimated by O(M*N*(D)m) , where (D)m denotes the mean value of circle radius (mean value of the element of DI). The skeletons of the image areas The skeleton of an area A is the geometric locus of points, which have more than one projection to the border of A. References 1. O. Cuisenaire. Distance transformations: fast algorithms and applications to medical image processing // Ph.D. Thesis, UCL, Louvain-la-Neuve, Belgium October 1999. 2. M. van Eede, D. Macrini, A. Telea, C. Sminchisescu, S. Dickinson. Canonical Skeletons for Shape Matching // Proceedings, International Conference on Pattern Recognition (ICPR), Hong Kong, August, 2006. 3. Zhanrong Li, Jianqing Zhang. Image Segmentation Based on Inscribed circle // 18th International Conference on Pattern Recognition (ICPR'06) pp. 247-250.
© Copyright 2026 Paperzz