circle segmentation algorithm

circle segmentation algorithm

Applied Mathematics and Computation 205 (2008) 841–848 Contents lists available at ScienceDirect Applied Mathematics and Computation journal homepag...

552KB Sizes 4 Downloads 95 Views

Applied Mathematics and Computation 205 (2008) 841–848

Contents lists available at ScienceDirect

Applied Mathematics and Computation journal homepage: www.elsevier.com/locate/amc

A fast, memory-efficient and parallelizable arc/circle segmentation algorithm Fei Wang *, Zejian Yuan, Nanning Zheng, Yuehu Liu Institute of Artificial Intelligence and Robotics, Xian Jiaotong University, No. 28 Xianning Road, Xi’an 710049, Shaanxi, PR China

a r t i c l e Keywords: Graphics recognition Arc segmentation Discrete curvature

i n f o

a b s t r a c t This paper presents a fast parallelizable arc/circle segmentation method with small memory cost. Firstly the proposed method extracts the edge and skeleton information in image space, records every line fragment in a multi-fork tree as a node which can be processed concurrently. For simplifying the computation, every line fragment is approximated by its piecewise linear polygon (PLG). After that local discrete curvature of each dominant point (DP) on the PLG is calculated and used to estimate the local arc’s existence approximately, the arc’s parameters are calculated simultaneously. Finally the inveracious arcs would be erased according to the results of arc verification and the arc fragments would be jointed by the arc combination and tracking. This proposed method can deal with the edge rupture, intersection and overlapping conditions. Furthermore it requires small memory space and the parallel processing technology can be implemented to make it faster. Ó 2008 Elsevier Inc. All rights reserved.

1. Introduction Arc segmentation is an important aspect in the graphics recognition field because of omnipresent circular/round shapes existing in the real world. In image analysis and understanding, especially for extracting graphic objects from scanned engineering drawings, arc segmentation is a necessity and it has received great attention in the past several decades [1–6,9,10]. Current segmentation methods can be classified into two groups: raster image based and vector image based methods [8]. The first group includes algorithms that implement arc segmentation based on raster images, such as the hough transform (HT) [11,14], Curvature Estimation, statistical and pixel tracking algorithms. Such a kind of methods directly segment arc elements from raster images via pixel-level processing. As a large quantity of pixel data should be processed, these methods are very time-consuming and space-consuming. They are not applicable for actual industrial applications. The second group consists of arc segmentation methods based on vector images, including arc-fitting, circular HT and stepwise arc extension methods. These vector image based methods greatly reduce time–cost and space-complexity greatly by vectorization comparing to the raster image based ones. Currently, arc segmentation is far from satisfying due to some difficulties, such as noise introduced during scanning process and narrow angle, tangency, intersection with other geometry objects in the complex environment, which result in great algorithm complexity. For example, if the circular objects are isolated and have clear edges, they can be recognized fast and the geometry parameters can be predicted accurately and quickly. However, in real world there are so much noise that leads to blurry and coarse edges; and several circular/round objects may overlap each other. All these make arc segmentation become difficult.

* Corresponding author. E-mail address: [email protected] (F. Wang). 0096-3003/$ - see front matter Ó 2008 Elsevier Inc. All rights reserved. doi:10.1016/j.amc.2008.05.129

842

F. Wang et al. / Applied Mathematics and Computation 205 (2008) 841–848

In this paper a novel fast arc/circle segmentation method is presented, which is based on the mechanism of hypothesis generalizing and validating, aiming at solving current problems in the arc/circle detection in engineering drawing understanding field. The rest of this paper is arranged as follows: in Section 2 the image vectorization method and line parameters computation method are discussed. Section 3 describes details of our segmentation algorithm based on arc hypothesizing and validating mechanism. The performance evaluation and comparison will be given in Section 4. Conclusion and future work are achieved in Section 5. 2. Image vectorization and line parameters computation As Fig. 1 illuminates, we make use of the edge and skeleton information to construct vector images, and then compute arc parameters to carry on arc hypothesis and validation. In our proposed method, the arc validation of each arc tiles can be processed separately after arc hypothesis. 2.1. Image vectorization Edges and skeletons can represent object outlines in a simple but very effective way [10]. So in our method we decide to construct the vector image based on edges and skeletons. Firstly, we detect the edges and skeletons of objects in original images, and then use a two-dimension list data structure to record them in memory [12] for fast indexing and convenient computation. In detail, in our method we extract object edges with the Sobel operator and detect skeletons with distance transform (DT) technique. Fig. 2 shows the vectoring process with DT method. After the steps of edge extraction and skeleton detection, we use linear polygonal approximation (LPA) to characterize the object shape [7] and generate the vector image. In Fig. 2c the two end points of the curve with single arrowhead represent two vertexes of the linear polygonal approximation, and the arrow means the two vertexes are connected by a pointer which is convenient for searching and indexing. Another thing which should be explained especially is that we choose the edge or skeleton to describe a line according to its linewidth. Tlinewidth is denoted as a threshold. If a line is wider than Tlinewidth, we should adopt the edge to characterize the line; otherwise the skeleton will be employed.

Fig. 1. The flowchart of our proposed method.

Fig. 2. Skeleton image and list data structure: (a) two arcs in the original image; (b) after vectorization the two arcs can be described as two skeletons in the vector image; (c) two-dimension list data structure in the computer’s RAM to presents the two skeletons.

F. Wang et al. / Applied Mathematics and Computation 205 (2008) 841–848

843

Fig. 3. Linewidth computation method. Gray part is the original line, black broken-line means the skeleton, point Pij is a pixel on the skeleton, LPij denotes the linewidth at point Pij.

2.2. Local slope and linewidth computation Edge and skeleton image can be regarded as a collection of polygons which is composed of many short straight lines. Any straight line has two important attributes: line-slope and linewidth. In our proposed method we compute the slope and width of every short straight line as the line’s features. In Fig. 3, we denote the points in the ith line as Pi = {Pijjj = 1, . . ., N}.  þ  The width on point Pij can be expressed as LPij ¼ Lþ ij þ Lij þ 1, where the Lij and Lij stand for the partly width of point Pij on different perpendicular directions, respectively. The constant 1 means the self-width of skeleton. Thereby the ith linewidth P can be expressed as linewidthi ¼ N1 j2½1;N LPij . 3. Local arc hypothesis 3.1. Local arc segmentation and hypothesis Under ideal conditions, the arc/circle in plane geometry has the following characters: (1) each edge of the arc/circle’s linear polygonal approximation should have the same length and the polygon should have regular form; (2) the curvatures of each point in the arc/circle edge should be an constant; (3) the number of the approximate polygon’s edges should be larger than threshold Tedge_num. In this paper the threshold Tedge_num is initialized with 3. Assume that the sequence of approximate polygon’s edge is (k1,k2, . . ., kh) and the vertex sequence is (v1, v2, . . ., vm). According to the three characters of arc/circle in plane geometry above, we hypothesize that vectors meeting the following criteria are considered arc/circle: Condition A: The approximate polygon’s edge number should be greater than or equal to 3,

T edge

num

¼ 3:

ð1Þ

Condition B: The length of each approximate polygon’s edge should be equal to each other,

Lenðki Þ ¼ Lenðkiþ1 Þ

i ¼ 1; 2; . . . ; h  1:

ð2Þ

Condition C: Define Curva(vi) as the curvature of vi, where the vi is the ith vertex of approximate polygon. Then any two vertexes’ curvatures should be the same. That is

Curvaðvi Þ ¼ Curvaðvj Þ

i; j ¼ 1; 2; . . . ; m  1:

ð3Þ

The method we adopt to calculate the Curva(vi) is THE-CHIN algorithm described in [13], in which k is initialized with 5 experientially. Based on the three conditions above, we search the sub-skeletons and label them as arc hypotheses which

Fig. 4. Label sub-skeleton as arc hypothesis.

844

F. Wang et al. / Applied Mathematics and Computation 205 (2008) 841–848

satisfy the condition A, B and C at the same time. Fig. 4 shows that the sub-skeleton Pi P j is labelled as an arc hypothesis arcðPi Pj Þ. 3.2. Arc verification While labelling a sub-skeleton as an arc hypothesis, the arcs’ parameters, such as radius, center, start-angle and end-angles, could be calculated. According to the theorems of plane geometry we learn that the perpendicular bisector of any chord should across its circle center. So abstractly we can get the center of an arc by calculating the coordinate of the perpendicular bisector’s intersection. However, due to heavy noise, the perpendicular bisectors may not intersect on the center point of circle. Actually, we employ a round region Ccenter, center region showed in Fig. 5, to denote the region in which the center may exist. In Fig. 5, the arc hypothesis’ radius is presented as Rradius 2 [RMIN,RMAX], in which RMIN and RMAX are the possible minimal and maximal value of the radius range. 3.2.1. Arc parameters computation The edges of the approximate polygon can be regarded as the arc/circle’s chords because the vertexes overlap on the arc/ circle’s skeleton. Assume that the chords sequence of an arc can be presented as H = {hiji = 1, 2, . . ., K}, and the coordinates of two end points and line-slope of any chord are known. According to plane geometry theorem we can get the expression of any chord’s perpendicular bisector. After that the intersections of any two perpendicular bisectors C = {ci} can be figured out. Denote the barycenter of the C as c0 , then

r 0 ¼ MAXðlenðc0 ; ci ÞÞ

Dr ¼

K 1X linewidthi ; K i¼1

where K means the number of chords. The region Ccenter can be defined as a round whose center is c0 and radius is rc, where rc = r0 + Dr. If we denote R0 as

R0 ¼

K 1X distanceðc0 ; hi Þ; K i¼1

it will represents the average distance from c0 to every vertex of the linear polygonal approximation, where the Distance(c0 ,hi) means the Euclidean distance between c0 and hi; if we order the RMIN and RMAX, respectively as:

RMIN ¼ R0  Dr RMAX ¼ R0 þ Dr; where the R0 can be regarded as the possible radii. Until now both the center region Ccenter and radius range Rradius are computable. In fact we employ a kind of coarse-to-fine method to gain the arc center and radius, from center region and radius range to real center and radius. We propose an improved CHT method, called LCHT (local circle hough transform) to calculate the

Fig. 5. Center region and radius range computation.

845

F. Wang et al. / Applied Mathematics and Computation 205 (2008) 841–848

real arc parameters. We use the original image data to implement CHT method to vote arc parameters [15]. We improve the computing efficiency enormously by making use of the radius range Rradius to decrease the size of accumulation matrix and taking advantage of the center region Ccenter to limit the searching area. The details of this part will be discussed in Section 4. 3.2.2. Arc combination, tracking and verification During the scanning and pre-processing, some noises may be introduced into the scanned image, which probably break the arcs [10]. In this instance combination should be done to recover the integrated arc if some small arcs have similar arc parameters, center and radius. Assume that linewidthm denotes the mth arc’s linewidth, riarc and rjarc denotes ith and jth arc’s radii, respectively, ðxiarc ; yiarc Þ denotes the center coordinate of ith and jth arc. If ith and jth arcs satisfy the following condition D, E, F and G, we consider that these two arc should be combined. j linewidthi þlinewidthj r i þr and r ¼ arc 2 arc , combination qualifications are: Firstly order linewidth ¼ 2 Condition D: Linewidth difference

jlinewidthi  linewidthj j 6 MINðlinewidthi ; linewidthj Þ:

ð4Þ

Condition E:

Drarc 6 linewidth; jriarc

where Dr arc ¼ Condition F:

DC arc 6



rjarc j

ð5Þ is the difference between ith and jth arc’s radius.

pffiffiffi 2  linewidth

ð6Þ

qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi where DC arc ¼ ðxiarc  xjarc Þ2 þ ðyiarc  yjarc Þ2 is the distance between two centers of ith and jth arc. Condition G:

! linewidth P D/ P 0 4  arcsin r

ð7Þ

where D/ ¼ j/iend  /jstart j is the rotate angle between ith and jth arc, /iend and /jstart is the end-angle of ith arc and start-angle of jth arc, respectively.

Fig. 6. The process of arc tracking.

Table 1 Image information of test samples Image

S_1.bmp

S_2.bmp

S_3.bmp

Size (pixel  pixel) Storage (MB)

1240  1020 1.19

2115  2807 5.77

2997  2084 5.98

846

F. Wang et al. / Applied Mathematics and Computation 205 (2008) 841–848

After the two arcs are combined into a big one, the new radius, center, start-angle and end-angle should be recalculated and the calculating formula can be denoted as follows:

Fig. 7. The samples and experiment’s results. (a–c) are the samples: S_1.bmp, S_2.bmp and S_3.bmp. The data in Table 1 show the basic information about these samples. (d–f) are the results of our proposed method. In (d) we can see that all of arcs are detected. But in (e) there are some arcs omitted and in (f) there are some false detections. (g) is the corresponding part of combination of (b) and (e), the green arcs are the detection results. A part of (f) is shown in (h), we also combine the detection result with the original image (c), the same as above, the green curves are the detection results. The short straight line means the arcs’ radii and the ends of straight line mean the centers of arcs (For interpretation of the references to colour in this figure legend, the reader is referred to the web version of this article.).

847

F. Wang et al. / Applied Mathematics and Computation 205 (2008) 841–848

rnew ¼ r C new ¼

xiarc þ xjarc yiarc þ yjarc ; 2 2

/start

¼ MINð/istart ; /jstart Þ

/end

new new

¼

ð8Þ

!

ð9Þ ð10Þ

MAXð/iend ; /jend Þ

ð11Þ /istart

/jstart ,

where the new start-angle /start_new should be updated by the small one between and and the new end-angle /end_new should be updated by the maximum one between /iend and /jend shown as Fig. 6. Sometimes an arc may be detected incompletely, which may be caused by excessive intersections or noises. After the arc combination we will take advantage of the new parameters to track the arc so that we can discover the little tiles owned by the same arc. For example, as in Fig. 6, one circle is separated into tow arcs and one short tile. Firstly we employ the arc combination method to joint ARC1 and ARC2 as a new longer arc ARCnew. But the Tile1 failed to be combined. Then we will track the Arcnew in two directions: DIR1 and DIR2. rnew and Cnew are the new radius and center of ARCnew. And a Sstep degrees rotation is executed as shown in Fig. 6. If one black pixels can be found along the direction DIR1, such as m0 , we consider there is an arc tile. Then we will calculate the black pixels percentage Bpercent in window W1, whose width and height are both equal to the linewidth of ARCnew. If the Bpercent P 0.5 we consider that the m0 point belongs to the arc. Consequently the arc’s parameter should be updated because of a new point found. This arc tracking will not stop until either the black pixel can not be found or the Bpercent < 0.5. The last step in this section is to validate the arc parameters. The major method is to take advantage of the arc parameters to figure out the arcs’ point collections and map the points back to the original image to validate the arc’s facticity. If the percentage of points in collection corresponding to these of the same arcs in the original image is greater than the threshold Tverify, we assume that the arc is a real one, otherwise it is an unreal one. Samples and experiment’s results are shown in Fig. 7. We initialize the Tverify with 0.75 in our proposed method. 4. Experiments and performance evaluation The classical CHT method allocates memory for the accumulative matrix at the beginning and memory size depends on the image size and radius range.

MemCHT ¼ widthorg  heightorg  ðM þ 1Þ  size ofðintegerÞ;

ð12Þ

where the M is the amount of possible radius, the constant 1 represents the memory space for original image. In our proposed method, one arc-detection module just processes one arc segment, and the memory cost is

Memproposed ¼ ½width  height þ K  ð8Dr  r 2c Þ  size ofðintegerÞ:

ð13Þ

where the K denotes the number of arc-detection modules as showed in Fig. 1. The data in Table 2 also illuminate total cost time by the proposed method and CHT method, respectively. Our proposed method shrinks the parameter space to a little range for accelerating the computation speed, and its benefits include: (1) Decreasing the input data. The image skeleton we deal with is just 1/linewidth times of original data. And we take advantage of the parallel technology to make sure that anytime only a part of data is input into the arc-detection which is the most time-consuming part; (2) Reducing the searching range of radius. This method computes every possible radius in a limited range Rrange; (3) Reducing the searching area of center. We know that in CHT method the maximum point of the accumulative matrix corresponds to the center of circle. That means every point of the matrix should be searched. If the original image’s width and height are widthorg and heightorg, respectively, then we must search widthorg  heightorg  M points. In our proposed method, we just search the points in the center region Ccenter, so we just need to search 2Dr  pr2c points for each arc segment, where Dr = RMAX  RMIN. Compared with CHT, the proposed method has the following advantages: lower resource cost; higher processing speed; parallel processing and easiness for hardware implementation.

Table 2 Comparison of performance of our proposed method with CHT Image

Memory cost (our method) (MB)

Memory cost (CHT) (MB)

Total time (our method) (s)

Total time (CHT) (s)

S_1.bmp S_2.bmp S_3.bmp

2.76 36 49

120 570 630

1.75 34 73

83 155 180

848

F. Wang et al. / Applied Mathematics and Computation 205 (2008) 841–848

5. Conclusion and future work The outline of our proposed method is as follows: firstly, employ the edge extraction, DT and LPA algorithms to simplify data collection; secondly, calculate the discrete curvature of the polygon vertexes based on the plane geometry features and the arithmetic characters of arcs; thirdly, assuming some arcs exist in part image according to the features of vertex curvatures, apply the LCHT algorithm to compute the parameters of arcs; finally, make use of the arc parameters to calculate the arc’s point coordinates and map the points back to the original image to validate the arc’s facticity. As the analysis mentioned above, the proposed method can improve the processing effectively and reduce the necessary memory cost in arc detection. But it is not stable in case of the distortion of skeleton on the junction places, which can be regarded as a kind of noises reducing the detection accuracy. In future work, we plan to improve the skeletonizing method to obtain better skeleton image and utilize special windows to process the junction regions. At the same time we want to adopt multi-level zoom method to detect arcs with large different radius scale dynamically. Acknowledgements This work was supported partly by national key project funded of NSF (Project No.: 60021302) and national key project of scientific and technical supporting programs of China (Project No.: 2006BAK31B04). References [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]

D.H. Ballard, Generalizing the hough transform to detect arbitrary shapes, Pattern Recognition 13 (1981) 111–122. I. Amir, Algorithm for finding the center of circular fiducials, Computer Vision, Graphics, Image Process 49 (1990) 398–406. L. Moura, R. Kitney, A direct method for least-squares circle fitting, Computer Physics Communication 64 (1991) 57–63. V.F. Leavers, The dynamic generalized hough transform: its relationship to the probabilistic hough transforms and an application to the concurrent detection of circles and ellipses, Computer Vision, Graphics, Image Understanding 56 (1992) 381–398. C. Ho, L. Chen, A fast ellipse/circle detector using geometric symmetry, Pattern Recognition 28 (1995) 117–124. R.I. Debled-Rennesson, J.P. Salmon, L. Wendling, A new method to detect arcs and segments from curvature profiles, in: Proceedings of 18th International Conference on Pattern Recognition, vol. 3, 2006, pp. 387–390. P.L. Rosin, Techniques for assessing polygonal approximations of curves, IEEE Transactions on Pattern Analysis and Machine Intelligence 19 (1997) 659–666. J.Q. Song, R.L. Michael, S.J. Cai, Effective multi-resolution arc segmentation: algorithms and performance evaluation, IEEE Transactions on Pattern Analysis and Machine Intelligence 26 (2004) 1491–1506. P. Dosch, G. Masini, K. Tomber, Improving arc detection in graphics recognition, in: Proceedings of 15th International Conference on Pattern Recognition, vol. 2, 2000, pp. 243–246. W. Liu, D. Dori, Incremental arc segmentation algorithm and its evaluation, IEEE Transactions on Pattern Analysis and Machine Intelligence 20 (1998) 424–431. D.H. Ballard, Generalizing the hough transform to detect arbitrary shapes, Pattern Recognition 13 (1981) 111–122. K. Tombre, C. Ah-Soon, P. Dosch, G. Masini, S. Tabonne, Stable and robust vectorization: how to make the right choices, Graphics Recognition 1941 (2000) 3–18. C.H. Teh, R.T. Chin, On the detection of dominant points on digital curves, IEEE Transactions on Pattern Analysis and Machine Intelligence 11 (1989) 859–872. D. Dori, Vector-based arc segmentation in the machine drawing understanding system environment, IEEE Transactions on Pattern Analysis and Machine Intelligence 17 (1995) 1057–1068. J. Lllingworth, J. Kitter, A survey of the hough transform. Computer vision, Graphics and Image Processing 44 (1988) 87–116.