Convex hull properties and algorithms

Convex hull properties and algorithms

Applied Mathematics and Computation 216 (2010) 3209–3218 Contents lists available at ScienceDirect Applied Mathematics and Computation journal homep...

518KB Sizes 1 Downloads 130 Views

Applied Mathematics and Computation 216 (2010) 3209–3218

Contents lists available at ScienceDirect

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

Convex hull properties and algorithms Xianquan Zhang a, Zhenjun Tang a,*, Jinhui Yu b, Mingming Guo a, Lianyuan Jiang a a b

Department of Computer Science, Guangxi Normal University, 15 YuCai Road, Guilin 541004, PR China State Key Laboratory of CAD&CG, Zhejiang University, Hangzhou 310027, PR China

a r t i c l e

i n f o

Keywords: Convex hull Extreme points Point set Computational geometry

a b s t r a c t Convex hull (CH) is widely used in computer graphic, image processing, CAD/CAM, and pattern recognition. We investigate CH properties and derive new properties: (1) CH vertices’ coordinates monotonically increase or decrease, (2) The edge slopes monotonically decrease. Using these properties, we proposed two algorithms, i.e., CH algorithm for planar point set, and CH algorithm for two available CHs. The main ideas of the proposed algorithms are as follows. A planar point set is divided into several subsets by the extreme points, and vertices in these subsets are then separately calculated. During the computation, the CH properties are used to eliminate concave points. This can reduce the computational cost and then improves the speed. Our first algorithm can extract CH with Oðn log nÞ time, which is the lower bound of planar CH extraction, and the second algorithm can obtain CH with Oðm þ nÞ time at the worst case. Crown Copyright Ó 2010 Published by Elsevier Inc. All rights reserved.

1. Introduction Convex hull (CH) is a central problem in various applications of computational geometry, such as Vornoi diagram construction, triangulation computation, etc. It can be applied to computer graphic [1], image processing [2,3], CAD/CAM, and pattern recognition [4–6]. CH of a planar point set S is defined as the intersection of all the half-planes containing S. The shape of CH is a polygon whose vertices belong to S. Many efforts have been devoted to develop CH algorithms for planar point set. In 1970, Chand and Kapur [7] initially proposed a CH algorithm with O(n2) time by constructing the borders of CH according to the geometric properties of S. Another algorithm with O(mn) time was given by Jarvis [8], where m is the CH vertex number. Both of them have a high time complexity. Graham [9] provided a solution to compute the CH of a finite linear set in a 2D plane. He determined the point with minimal y-coordinate and calculated the angles between the horizontal line and the lines connecting the determined point and other points. According to the sorted angles, vertices are obtained. The divide-and-conquer method [10] was also applied to CH extraction. Point set was divided into two roughly equal-sized subsets. Their CHs were recursively computed respectively, and the entire CH was obtained by merging those two CHs. Zhou [11] proved that the time complexity of computing the planar CH of line sets is O(nlogn). He transformed the line segments into a simple polygonal line and then extracted the CH of the polygonal line to obtain the desired CH. Cui et al. [12] studied the relations between the CH and sorting, and then proposed an algorithm based on sorting. Jin et al. [13] combined the sorting algorithm and the CH algorithm for simple polygons to extract CH of planar point set. In another study, Chan [14] used point pairs to calculate the line slopes and determine the median values of these slopes, then divided the point set into two parts by median values and recursively computed the CH. He gave another algorithm which partitioned the point set and then computed the CH of each group, respectively. The entire CH was finally obtained by computing the union of the polygons. Brönnimann et al. [15] investigated the storage space * Corresponding author. E-mail address: [email protected] (Z. Tang). 0096-3003/$ - see front matter Crown Copyright Ó 2010 Published by Elsevier Inc. All rights reserved. doi:10.1016/j.amc.2010.04.044

3210

X. Zhang et al. / Applied Mathematics and Computation 216 (2010) 3209–3218

of CH algorithms, and then improved Chan’s work [14] to obtain the algorithm reaching the lower bound of time complexity. Exploiting a parallel computational model EREW PRAM, Chen et al. [16] proposed a parallel robust method for CH extraction. 2 As for dynamic planar CH, Overmars and Leeuwen [17] provided a solution that used Oðlog nÞ time per update operation and maintained a leaf-linked balanced search tree of the vertices on the CH in clockwise order. Chan [18] gave a construction for 1þe the fully dynamic problem with Oðlog nÞ amortized time for updates (for any constant e > 0), and O(logn) time for extreme point queries. In another work, Brodal and Jacob [19] presented a data structure that maintained a finite set of n points in the plane under insertion and deletion of points in amortized O(logn) time per operation. In [20], Yao proved that O(nlogn) time is the lower bound of computing the CH of planar point set. As for general-dimension CHs, Barber et al. [21] designed a practical algorithm combining the two-dimensional Quickhull algorithm with the general-dimension Beneath–Beyond algorithm. Recently, Sirakov [22] proposed a new active convex hull model (ACHM) based on the geometric heat differential equations. Since ACHM is invariant with respect to the number of pixels enveloped by the CH, it is more effective than the conventional CH algorithms in application to images. In this paper, we investigate the CH properties and derive some new properties. Using these properties, we design two CH algorithms. The rest of the paper is organized as follows. In Section 2, the CH properties are investigated. The proposed CH algorithms for planar point set and two available CHs are described in Sections 3 and 4, respectively. Conclusions and future works are presented in Section 5. 2. CH Properties Let Q = {q1, q2, . . . , qN} be a point set of CH vertices, where the coordinates of qi are (xi, yi). CH is a polygon having the following properties. For an edge qiqi+1, all other points lie on one side of the straight line through qi and qi+1. Any line segment connecting two arbitrary nonadjacent points is in the interior of the polygon, the interior angle is less than 180°, etc. In this section, we investigate vertex monotonicity and slope properties of CH edges. A definition about the vertices with maximum or minimum coordinates is as follows. Definition 1. CH vertices with maximum/minimum x-coordinate or y-coordinate are called CH extreme points. Obviously, there are at most two vertices with minimum x-coordinate in Q, where the point with maximum y-coordinate is labeled as QxY, and the other is named Qxy. Likewise, there are at most two vertices with maximum x-coordinate in Q, where the point with maximum y-coordinate is labeled as QXY, and the other is named QXy. There are at most two vertices with minimum y-coordinate, where the point with maximum x-coordinate is labeled as QyX, and the other is named Qyx. There are at most two vertices with maximum y-coordinate, where the point with maximum x-coordinate is labeled as QYX, and the other is named QYx. Thus, there are at most 8 extreme points in a CH. Clearly, there exists the case that a vertex simultaneously satisfies the properties of several extreme points. In other words, the number of extreme points may be smaller than 8. For example, Fig. 1(a) is a CH with eight different extreme points, and (b) is a CH with four extreme points. In this paper, the CH vertices are numbered in clockwise direction from QxY = q1.   xi > xiþ1 xi < xiþ1 or ,P Definition 2. Let P = {pi(xi, yi), i = 1, 2, . . . , n} be a planar point set. If all points’ coordinates satisfy y < y yi > yiþ1 i iþ1   xi > xiþ1 xi < xiþ1 or , P is the monotonic is the monotonic increasing ordered point set. If their coordinates satisfy yi > yiþ1 yi < yiþ1 decreasing ordered point set. The monotonic increasing/decreasing ordered point sets are both called monotonic ordered point sets. Once the extreme points are available, the CH vertex set Q can be divided into four subsets, i.e., Q1, Q2, Q3, and Q4, as follows. Let f(b, A, B) = 0 be an equation of the straight line through points A and B, where b is an active point on the straight line. Thus, if QxY – QYx, Q1 = {qijf(qi, QxY, QYx) P 0, qi 2 Q}. Otherwise, Q1 = {QxY}. Likewise, if QYX – QXY, Q2 = {qijf(qi, QYX, QXY) P 0,

QYx

QxY

QYX = QXY = QXy

QYx

QYX

QXY

Qxy

QXy

Qyx

QyX

(a)

QxY = Qxy = Qyx

(b) Fig. 1. The extreme points of CH.

QyX

3211

X. Zhang et al. / Applied Mathematics and Computation 216 (2010) 3209–3218

qi 2 Q}. Otherwise, Q2 = {QYX}. If QXy – QyX, Q3 = {qijf(qi, QXy, QyX) 6 0, qi 2 Q}. Otherwise, Q3 = {QyX}. Q4 = {qijf(qi, Qyx, Qxy) 6 0, qi 2 Q}. Otherwise, Q4 = {Qxy}. A theorem about the subsets is as follows.

If

Qyx – Qxy,

Theorem 1. In the CH vertex set Q, the subsets Q1 (when QxY – QYx) and Q3 (when QXy – QyX) are monotonic increasing ordered point sets, while the subsets Q2 (when QYX – QXY) and Q4 (when Qyx – Qxy) are monotonic decreasing ordered point sets. Proof. Let Q1 be {q1, q2, . . . , qn}, and the coordinates of qi be (xi, yi). Thus, q1 = QxY, and qn = QYx. Since QxY – QYx, n P 2. Obviously, the theorem is correct if n = 2. Consider the case n > 2. Suppose that the coordinates of q1, q2, . . . , qi increase progressively, and the coordinates of qi+1 are smaller than those of qi. Thus, qi+1 is under the straight line y = yi. Clearly, qi+1 has two possible positions. One is above the straight line qi1 qi , the other is below qi1 qi . CH properties indicate that all vertices lie on one side of qi1 qi except qi1 and qi. Since q1 and qn are below qi1 qi , qi+1 can’t be above qi1 qi . It means that qi+1 must be below qi1 qi , as shown in Fig. 2. In this case, qi1 and qn are on different sides of qi qiþ1 . This contradicts with the fact that they are both CH vertices. So the coordinates of q1, q2, . . . , qnincrease progressively, and Q1 is a monotonic increasing ordered point set. Similar proofs can be applied to other subsets. h Theorem 2. Let qi1, qi, qi+1 (i = 2, 3,. . . , N  1) be CH vertices, and the slopes of edges qi1 qi and qi qiþ1 be sl(qi1, qi) and sl(qi, qi+1) respectively, where qi isn’t an extreme point. Thus, sl(qi1, qi) > sl(qi, qi+1). Proof. As qi is not an extreme point, qi1, qi and qi+1 belong to one of the subsets Q1, Q2, Q3, and Q4. Take Q1 for example. Let the coordinates of qi be (xi, yi), and ai be the angle between edge qi1 qi and x-axis, as shown in Fig. 3. As Q1 is a monotonic y y increasing ordered point set, tanðai Þ ¼ xiþ1 xi > 0. Thus, 0 < ai < p/2. Since every exterior angle of a triangle is equal to the sum iþ1 i of two non adjacent angles, ai > ai+1. So tan (ai) > tan (ai+1). This means that the slope of edge connecting adjacent points of Q1 decreases progressively. Similar proofs can be applied to other subsets. h Using the above properties, we can eliminate those points which are not CH vertices during the computation. This can reduce the computational cost and then improve the speed. 3. Proposed CH algorithm for planar point set The proposed CH algorithm for planar point set is composed of two steps. In the first step, we compute extreme points of the planar point set. In the second step, we exploit them to divide the point set into several subsets, and then calculate vertices of the subsets by using the CH properties.

qn = QYx

qi

y = yi qi+1

qi−1

q1 = QxY Fig. 2. Vertex monotonicity.

QYx

y

qi

qi +1

qi −1

α i +1

QxY

αi

x Fig. 3. Decreasing slopes.

3212

X. Zhang et al. / Applied Mathematics and Computation 216 (2010) 3209–3218

3.1. Compute extreme points of the planar point set Definition 3. In a planar point set, the points with maximum/minimum x-coordinate or y-coordinate are called extreme points of the planar point set. Theorem 3. The CH extreme points are extreme points of the planar point set forming the CH. Proof. Suppose that the CH vertices of a planar point are q1, q2, . . . , qn. If Qxy – QxY, the straight line through Qxy and QxY is parallel to the y-axis. Thus, the line segment connecting Qxy and QxY is a CH edge. According to CH properties, elements of the planar point set are on the right side of the straight line through Qxy and QxY or lie on the line segment connecting Qxy and QxY. So the x-coordinates of Qxy and QxY are minimal in the planar point set. If Qxy = QxY, the x-coordinate of Qxy is the smallest one among those of CH vertices. By CH properties, the x-coordinate of Qxy is the smallest one among those of the points forming the CH. Therefore, Qxy and QxY are two extreme points of the planar point set, whose x-coordinates are minimal. Similar proofs can be applied to other extreme points. Let P = {p1, p2, . . . , pM} be a planar point set. The extreme points of P can be extracted as follows. Collect those points with minimum x-coordinates to form a subset, where the point with minimum y-coordinate is Qxy while the point with maximum y-coordinate is QxY. Likewise, find those points with maximum x-coordinates to form a subset, where the point with minimum y-coordinate is QXy while the point with maximum y-coordinate is QXY. Collect those points with minimum ycoordinates to form a subset, where the point with minimum x-coordinate is Qyx while the point with maximum xcoordinate is QyX. Calculate those points with maximum y-coordinates to form a subset, where the point with minimum xcoordinate is QYx while the point with maximum x-coordinate is QYX. h 3.2. Vertex computation 3.2.1. Monotonic ordered point set generation Having obtained CH extreme points of the planar point set, we divide P = {p1, p2, . . . , pM} into four subsets, i.e., P1, P2, P3, and P4, as follows. If QxY – QYx, P1 = {pijf(pi, QxY, QYx) > 0, pi 2 P} [ {QxY} [ {QYx}. Otherwise, P1 = {QxY}. Likewise, if QYX – QXY, P2 = {pijf(pi, QYX, QXY) > 0, pi 2 P} [ {QYX} [ {QXY}. Otherwise, P2 = {QYX}. If QXy – QyX, P3 = {pijf(pi, QXy, QyX) < 0, pi 2 P} [ {QXy} [ {QyX}. Otherwise, P3 = {QyX}. If Qyx – Qxy, P4 = {pijf(pi, Qyx, Qxy) < 0, pi 2 P} [ {Qyx} [ {Qxy}. Otherwise,P4 = {Qxy}. For every Pi (i = 1, 2, 3, 4) with a cardinality greater than 1, Ti in ascending order is computed using heap algorithm. Take T1 generation for example. Obviously, except QxY and QYx, other vertices of P1 are all above the straight line through QxY and QYx. Theorem 1 shows that the coordinates of vertices in Q1increase progressively. Thus, we sort the points of P1 to make their coordinates ordered. During the computation, those points are eliminated whose coordinates don’t satisfy the constraint condition. This is achieved as follows. Take those points’ x-coordinates as keys and sort them by heapsort algorithm. After swapping the root, we need to redetermine the sorted points. If the rear point’s y-coordinate is smaller than that of the front point, remove the rear point (Theorem 1 shows that it isn’t a CH vertex). Repeat the operation until all the rear points’ y-coordinates are greater than those of their front points. This guarantees that points’ y-coordinates increase progressively. Detailed steps are as follows. STEP 1: Construct a maximum heap from P1 = {p1,i(x1,i, y1,i), i = 1, 2, . . . , K} with the points’ x-coordinates as the keys. Exchange the root (Its x-coordinate is maximal) with p1,K. Let j = 1, and s = K. STEP 2: IF (j > K) the sorting is done, and goto STEP 6. Construct a new heap from another point set consisting of the former K  j elements.

QYx

QYx

QxY

QxY

(a) Original points

(b) The sorted result

Fig. 4. Point set before and after sorting.

X. Zhang et al. / Applied Mathematics and Computation 216 (2010) 3209–3218

3213

Exchange the root with p1,Kj. s + 1, and goto STEP 3. IF (y1,Kj P y1,s) r p1,Kj, and goto STEP 5. ELSE s s  1, p1,s p1,Kj, s K, and goto STEP 5. STEP 3: IF (r > K) p1,k IF (y1,Kj P y1,r) goto STEP 4. //remove the next point p1,Kj, s r  1, and goto STEP 5. //the coordinates of the rear points are in order ELSE p1,r1 STEP 4: r r + 1, and goto STEP 3. STEP 5: j j + 1, and goto STEP 2. STEP 6: The sorted points range from p1,s to p1,K. Let T1 = {t1,1, t1,2, . . . , t1,L} be the sorted result of P1, where t1,1 = Qxy, and tL = QYx. An example about T1 generation is shown in Fig. 4, where (a) is P1 and (b) is T1. Likewise, T2, T3, and T4 can be extracted using the similar methods. In T2, points’ x-coordinates increase progressively, and y-coordinates decrease progressively. In T3, both the x-coordinates and y-coordinates decrease progressively. In T4, the xcoordinates decrease, while y-coordinates increase. 3.2.2. Calculate CH vertices based on the monotonic ordered point set Theorem 4. Let Qi (i = 1, 2, 3, 4) be {qm, qm+1, . . . , qn}, and p be a received point satisfying that {qm, qm+1, . . . , qn, p} is a monotonic ordered point set. Thus, qm, qm+1, . . . , qk, p are CH vertices if qk (k 6 n) is a CH vertex. Proof. Take Q1 for example. Since{qm, qm+1, . . . , qn, p} is a monotonic ordered point set, p is an extreme point of {qm, qm+1, . . . , qn, p}. Thus, p is a CH vertex. Suppose that qk (k 6 n) is the CH vertex whose suffix value is maximum among those of the new CH vertices extracted from {qm, qm+1, . . . , qn}, and qk and p are adjacent CH vertices. If qj (j < k) isn’t a CH vertex, p and qm, qm+1, . . . , qj1, qj+2, . . . , qn are on the different side of straight line qj qjþ1 . So p and qk are on the different side of straight line qj qjþ1 . Fig. 5 shows the position of p. (If p is below the straight line qj qjþ1 , p and qm, qm+1, . . . , qj1, qj+2, . . . , qn are on the same side. In this case, qj is a CH vertex. It contradicts with the hypothesis.) Therefore, according to CH properties, qk isn’t a CH vertex. This contradicts with the hypothesis. So qm, qm+1, . . . , qk, p are the CH vertices of {qm, qm+1, . . . , qn, p}. Similar proofs can be given to other subsets. Obviously, vertex computation in a monotonic ordered set can start from an extreme point. Theorem 2 shows that if the ordered points are CH vertices, the slopes of edges connecting these ordered points monotonically decrease. If the slopes of adjacent edges (in clockwise order) don’t satisfy this, the point connecting the two edges is a concave point. Then remove it and backtrack until finding out a vertex of the temporary CH by Theorem 4. Take Q1 for example. Similar steps can be applied to Q2, Q3, and Q4. Let T1 = {t1, t2, . . . , tL} be a monotonic ordered point set extracted from P1, and the slope of straight line ti t iþ1 (i = 1, 2, . . . , L  1) be sl(ti, ti+1), where t1 = QxY and tL = QYx. Obviously, t1 is a CH vertex. Thus, start from t2 and construct temporary CH. If all points of the temporary CH are the final CH vertices, sl(ti1, ti) > sl(ti, ti+1). If ti satisfies sl(ti1, ti) 6 sl(ti, ti+1), as shown in Fig. 6, it isn’t a CH vertex. Backtracking is then performed to eliminate concave points by using Theorem 4. Determine those points one by one until encountering tL. Detailed steps are as follows. STEP 1: Let T1 = {ti(xi, yi), i = 1, 2, . . . , L} be the monotonic point set, where t1 = QxY, q1 = t1, i = 2, and j = 2. STEP 2: IF (i = = L) goto STEP 6. IF (sl(qj1, ti) 6 sl(ti, ti+1)) k = 1, and goto STEP 3. //backtrack ELSE qj = ti, and goto STEP 5.

p

qn qk qj+1 qj qm Fig. 5. Vertex calculation in an ordered set.

3214

X. Zhang et al. / Applied Mathematics and Computation 216 (2010) 3209–3218

tK = QYx ti+1 ti ti− 1 t2 t1 = QxY Fig. 6. Vertex computation using edge slopes.

STEP 3: IF (j = = 2) j j  1, goto STEP 5. //backtrack to the first point IF (sl(qjk1, qjk) 6 sl(qjk, ti+1)) goto STEP 4. //keep backtracking ELSE j j  k, goto STEP 5. //find out the vertices and finish backtracking STEP 4: IF (j  k > 2) k k + 1, goto STEP 3. ELSE j = 1. //backtrack STEP 5: i i + 1, j j + 1, goto STEP 2. STEP 6: qj = tL = QYx, q1, q2, . . . , qj are the CH vertices. h 3.3. Proposed CH algorithm Let P = {p1, p2, . . . , pM} be a planar point set. To extract the CH of P, we calculate the extreme points of P, i.e., Qxy, QxY, QXy, QXY, Qyx, QyX, QYx and QYX by using the method described in the last paragraph of Section 3.1. If QxY – QYx, P1 = {pijf(pi, QxY, QYx) > 0, pi 2 P} [ {QxY} [ {QYx}. Otherwise, P1 = {QxY}. Likewise, if QYX – QXY, P2 = {pijf(pi, QYX, QXY) > 0, pi 2 P} [ {QYX} [ {QXY}. Otherwise, P2 = {QYX}. If QXy – QyX, P3 = {pijf(pi, QXy, QyX) < 0, pi 2 P} [ {QXy} [ {QyX}. Otherwise, P3 = {QXy}. If Qyx – Qxy, P4 = {pijf(pi, Qyx, Qxy) < 0, pi 2 P} [ {Qyx} [ {Qxy}. Otherwise, P4 = {Qyx}. Using the method presented in Section 3.2.1, we can extract the ordered point sets Ti from Pi (i = 1, 2, 3, 4), and then obtain the vertex subsets Qi. By combining Q1, Q2, Q3, and Q4, the CH is available. Detailed algorithm is as follows. STEP 1: Compute the extreme points Qxy, QxY, QXy, QXY, Qyx, QyX, QYx and QYX of P. STEP 2: Calculate the subsets Pi (i = 1, 2, 3, 4) of P. STEP 3: If the element number of Pi is equal to 1, Qi = Pi. Otherwise, we extract the ordered point sets Ti from Pi, and then compute the vertex subsets Qi from Ti (i = 1, 2, 3, 4). STEP 4: Q = {Q1} [ {Q2} [ {Q3} [ {Q4} are the vertex set of P. Connect these adjacent ordered points with edges to produce the entire CH. 3.4. Complexity analysis and experimental results Let A[n] be an array storing a planar point set having n points. To determine the subsets Pi (i = 1, 2, 3, 4), we just need to exchange the elements in the array. It only requires an additional memory unit. To sort the points of Pi requires a memory unit. So the proposed algorithm needs a memory unit at most. It has a very low space complexity. Calculating the extreme points and extracting Pi (i = 1, 2, 3, 4) both run in O(n) time. The heapsort algorithm requires Oðn log nÞ time at most. The time complexity of backtracking is O(n) time. So the proposed algorithm can extract CH with Oðn log nÞ time. It reaches the theoretical lower bound of planar CH extraction. To validate the proposed algorithm, many experiments are conducted and all CHs are correctly extracted. Some results are presented here. Fig. 7 is an example about the steps of CH extraction. Fig. 7(a) indicates the extreme points, (b) indicates the subsets P1, P2, P3, and P4, (c) shows the ordered point sets T1, T2, T3, and T4, and (d) shows the final CH. Fig. 8 present other four examples, where (a), (b), (c), and (d) are different point sets, (e), (f), (g), and (h) are their corresponding CHs respectively. To show the advantages, we compare the run times of CH extraction between the proposed algorithm and the algorithm in [15]. Both algorithms were implemented in C language and executed on a PC with Pentium III 930 MHz CPU and 256 MB RAM. In here, we generate random points with integer coordinates in a square sized 1024  1024. Point numbers used in the experiments range from 5,000  100,000. For each point number, we run 100 times and record the consumed time, and find the average time of CH extraction. The comparison results are listed in Table 1, where the unit is second. From the results, we observe that as the point number increases, both algorithms need more time to extract the CH. However, all the average times of proposed algorithm are smaller than those of [15]. In other words, the proposed algorithm is faster than the algorithm in [15]. This attributes to point elimination in STEP 2 and STEP 3 of the proposed algorithm, which can reduce many candidate points and then greatly improve the speed.

X. Zhang et al. / Applied Mathematics and Computation 216 (2010) 3209–3218

3215

Fig. 7. The steps of CH extraction.

Fig. 8. Different point sets and their corresponding CHs.

4. Proposed CH algorithm for two available CHs To calculate the CH of two available CHs, we compute extreme points of the point set forming by the vertices of two CHs, and then extract new CH by using the monotone property existing in the original CHs. Consideration of the CH of two CHs

3216

X. Zhang et al. / Applied Mathematics and Computation 216 (2010) 3209–3218

Table 1 Average time comparisons between the proposed algorithm and the algorithm in [15] (The unit is second). Point number

5000

10000

20000

30000

40000

50000

60000

70000

80000

90000

100000

Algorithm in [15] Proposed algorithm

0.0295 0.0012

0.0655 0.0014

0.1393 0.0024

0.2252 0.0060

0.3229 0.0069

0.4218 0.0090

0.5626 0.0109

0.6212 0.0126

0.7321 0.0140

0.8391 0.0155

0.9445 0.0171

QYx

QYX

QxY QXY

Qxy

QXy

Qyx

QyX

Fig. 9. The extreme points of CH forming by two CHs.

has practical significance as follows. In application to object recognition, we generally extract the CH of each object in advance to identify the similar targets; and further, we need to view two or more objects as a whole. In other words, the CH of each point set is separately calculated by using the conventional CH algorithm, e.g. the algorithm in [15] or our algorithm in Section 3. After that, the CH extraction of two available CHs is also needed. In this case, if we use the conventional CH algorithm to find the entire CH of two CHs, it runs in Oððm þ nÞ logðm þ nÞÞ time at least, where m and n are their vertex numbers respectively. Since two CHs are available, we can exploit CH properties to extract the CH. It only requires O(m + n) time, which will be discussed in Section 4.4. 4.1. Calculate extreme points based on those of two CHs ð1Þ ð1Þ ð1Þ Let Q ð1Þ ¼ fq1 ; q2 ; . . . ; qn g and Q ð2Þ ¼ ð1Þ ð1Þ ð1Þ ð1Þ ð1Þ ð1Þ ð1Þ ð1Þ Q xy ; Q xY ; Q Xy ; Q XY ; Q yx ; Q yX ; Q Yx ; Q YX , and (1) (2)

ð2Þ

ð2Þ

ð2Þ

fq1 ; q2 ; . . . ; qm g denote the vertex sets of two CHs, whose extreme points are ð2Þ ð2Þ ð2Þ ð2Þ ð2Þ ð2Þ ð2Þ Q ð2Þ xy ; Q xY ; Q Xy ; Q XY ; Q yx ; Q yX ; Q Yx ; Q YX , respectively. Using the extreme points of Q and Q , we can calculate extreme points of Q(1) [ Q(2) as follows. Qxy is the point with minimum y-coordinate in the ð1Þ ð2Þ ð2Þ subset consisting of the points with minimum x-coordinate among Q ð1Þ xy ; Q xY ; Q xy , and Q xY . Likewise, QxY is the point with ð1Þ ð2Þ ð2Þ maximum y-coordinate in the subset consisting of the points with minimum x-coordinate among Q ð1Þ xy , Q xY ; Q xy , and Q xY . (1) (2) Other extreme points can be extracted by using the similar steps. Fig. 9 shows CH extreme points of Q [ Q . 4.2. Extract CH vertices from the corresponding ordered sets between two CHs To extract the CH of Q(1) [ Q(2), we can exploit the property that the vertices of Q(1) and Q(2) are both in order. Let the verð1Þ ð1Þ ð1Þ ð1Þ ð2Þ ð2Þ ð2Þ ð2Þ tex subsets of Q(1) and Q(2) be Q 1 , Q 2 ; Q 3 ; Q 4 , and Q 1 ; Q 2 ; Q 3 ; Q 4 respectively. Clearly, vertices of Q1 are only related to ð1Þ ð2Þ the vertices of Q 1 and Q 1 . Take Q1 computation for example as follows. ð1Þ ð2Þ Let the vertices of Q 1 and Q 1 be (q(1)xi, q(1)yi) (i = 1, 2, . . . , K) and (q(2)xj, q(2)yj) (j = 1, 2, . . . , T) respectively, and the vertices of Q1 be q1, q2, . . . , qL (2 6 L 6 K + T), where the coordinates of qt (t = 1, 2, . . . , L) are (qxt, qyt). Obviously, QxY is a CH vertex since ð1Þ ð2Þ it is the point with minimum x-coordinate and maximum y-coordinate in Q(1) [ Q(2). Let q1 = QxY. Start from q1 and q1 ð1Þ ð1Þ respectively, and compute the vertices. Find a vertex qi satisfying q(1)yi > q(2)y1. If no point satisfies this, vertices in Q 1 ð2Þ ð2Þ ð2Þ (1) (2) (2) are not CH vertices of Q [ Q . Thus, Q1 is equal to Q 1 . Similarly, if all qj don’t satisfy q yj > qy1, vertices in Q 1 are ð1Þ ð1Þ ð2Þ not CH vertices of Q(1) [ Q(2). Thus, Q1 is equal to Q 1 . If qi and qj both satisfy the above conditions, we calculate the next ð1Þ ð2Þ (1) (2) i + 1. Otherwise, r ¼ qj and j j + 1. For the point r, if it satvertex using the follow rules. If q xi 6 q xj, r ¼ qi and i isfies f(r, qt1, QYx) < 0, {q1, q2, . . . , qt1, r} is an ordered point set. Backtrack from r to extract the temporary CH vertices. If f(r, qt1, QYx) P 0, find out the next ordered point. Repeat the above operations until QYx occurs. The detailed steps are as follows. STEP 1: STEP 2: ELSE STEP 3: ELSE

Let q1 = QxY, i = 1, j = 1, and t = 2. IF (q(1)yi 6 q(2)y1) goto STEP 3. goto STEP 4. //to find the points which need to be processed IF (i < T) i i + 1, goto STEP 2. ð1Þ qt (i = 1, 2, . . . , T), L T. Thus, Q1 is extracted. qt

X. Zhang et al. / Applied Mathematics and Computation 216 (2010) 3209–3218

3217

Fig. 10. Typical examples of the CH of two CHs.

STEP 4: IF (q(2)yj 6 q(1)y1) goto STEP 5. ELSE goto STEP 6. STEP 5: IF (j < K) j j + 1, goto STEP 4. ð2Þ qt (i = 1, 2, . . . , K), L K. Thus, Q1 is extracted. ELSE qt ð1Þ qi , and i i + 1. //to find the points with a small x-coordinate STEP 6: IF (q(1)xi 6 q(2)xj) r ð2Þ ELSE r qj , and j j + 1. STEP 7: IF (r = = QYx) goto STEP 10. IF (f(r, qt1, QYx) < 0) goto STEP 6. //r isn’t a CH vertex. r, t t + 1, goto STEP 6. //to the last point or backtracking is done. STEP 8: IF (t = = 2 or f(r, qt2, qt1) < 0) qt STEP 9: t t  1, and goto STEP 8. QYx, and q1, q2, . . . , qt are CH vertices. Thus, Q1 is extracted. STEP 10: qt The subsets Q2, Q3, and Q4 can be extracted by using the similar methods. 4.3. Proposed algorithm To extract the CH of Q(1) [ Q(2), we calculate the extreme points based on those of Q(1) and Q(2). Then, we extract vertices from the corresponding ordered sets between Q(1) and Q(2), and obtain the entire CH by orderly connecting these vertices. Detailed algorithm is as follows. STEP 1: Calculate Qxy, QxY, QXy, QXY, Qyx, QyX, QYx, QYX using the method described in Section 4.1. STEP 2: Extract vertices to form Qi (i = 1, 2, 3, 4) using the method described in Section 4.2. STEP 3: Q = Q1 [ Q2 [ Q3 [ Q4 is the vertex set of Q(1) [ Q(2). Connect these adjacent ordered points with edges to produce the entire CH. Obviously, the proposed algorithm here can be extended to find the CH of k CHs. The detailed procedure is as follows. Use our algorithm to extract the CH of two arbitrary CHs, and then compute the CH of the new CH and another CH. Repeat these operations until all k CHs are used. The last one is the final CH. 4.4. Complexity analysis and experimental results As for two CHs with m and n vertices, the proposed algorithm can obtain their eight extreme points with O(m) and O(n) ð1Þ ð2Þ times, respectively. To extract Qi (i = 1, 2, 3, 4), we just need to compute vertices in Q i and Q i , where each vertex is used once. So the time complexity of vertex computation is O(m + n). The operations of backtracking and re-determining vertices on the temporary convex hull also require O(m + n) time. Thus, the worse time complexity of the proposed algorithm is O(m + n). In order to validate the proposed algorithm, many experiments are done. The results show that it can correctly extract the CH of two CHs. The typical examples are presented in Fig. 10, where the dashed lines represent the available CHs and the solid lines represent the extracted CH. 5. Conclusions In this paper, we investigated the CH properties and derived some new properties about the vertices and the edge slopes. Using these properties, we designed two CH algorithms, i.e., CH algorithm for planar point set, and CH algorithm for two available CHs. The first algorithm can extract the CH in Oðn log nÞ time at the worst case, reaching the theoretical lower bound of planar CH extraction. It runs faster than the algorithm in [15]. The second one only requires O(m + n) time to find

3218

X. Zhang et al. / Applied Mathematics and Computation 216 (2010) 3209–3218

the CH of two given CHs with m and n vertices respectively. It is better than the conventional methods, which run in Oððm þ nÞ logðm þ nÞÞ time at least. Our algorithms reduce the computational cost in the following ways: (1) Reduce the number of candidate points by using the extreme points to extract the subsets Q1, Q2, Q3, and Q4 from the planar point set. Further, the subset computation is independent to each other. It reduces the number of points for sorting. (2) Eliminate those points which don’t satisfy the Theorem 1 during the sorting. Theoretical analysis and experimental results show that the proposed algorithms are practical and efficient. In the future, we will make farther study of the CH properties, design effective data structure, and focus on the real-time CH algorithm. Acknowledgements This work was partially supported by the Natural Science Foundation of China(60963008, 60763011), the Natural Science Foundation of Guangxi (0832104, 0447035), the project of the education administration of Guangxi (200911MS55, 200607MS135), and the Scientific and Technological Research Projects of Chongqing’s Education Commission (KJ081309). The authors thank the anonymous referees for their valuable comments and suggestions. References [1] B. Praveen, R. Wenger, R. Crawfis, Isosurface construction in any dimension using convex hulls, IEEE Transactions on Visualization and Computer Graphics 10 (2004) 130–141. [2] B. Yuan, C.L. Tan, Convex hull based skew estimation, Pattern Recognition 40 (2007) 456–475. [3] N.M. Sirakov, P.A. Mlsna, Search space partitioning using convex hull and concavity features for fast medical image retrieval, in: Proceedings of IEEE International Symposium on Biomedical Imaging, 2004, pp. 796–799. [4] X. Yu, H. Sun, J. Chen, Points matching via iterative convex hull vertices paring, in: Proceedings of International Conference on Machine Learning and Cybernetics, 2005, pp. 5350–5354. [5] C. Gope, N. Kehtarnavaz, Affine invariant comparison of point-sets using convex hulls and Hausdorff distances, Pattern Recognition 40 (2007) 309–320. [6] M.P. Yu, K.C. Lo, Object recognition by combining viewpoint invariant Fourier descriptor and convex hull, in: Proceedings of 2001 International Symposium on Intelligent Multimedia, Video and Speech Processing, 2001, pp. 401–404. [7] D.R. Chand, S.S. Kapur, An algorithm for convex polytopes, Journal of the ACM 17 (1970) 78–86. [8] R.A. Jarvis, On the identification of the convex hull of a finite set of points in the plane, Information Processing Letters 2 (1973) 18–21. [9] R.L. Graham, An efficient algorithm for determine the convex hull of a finite linear set, Information Processing Letters 1 (1972) 132–133. [10] F.P. Preparata, S.J. Hong, Convex hulls of finite sets of points in two and three dimensions, Communications of the ACM 20 (1977) 87–93. [11] P. Zhou, An algorithm for finding the convex hull of a line segment set in the plane, Journal of Engineering Graphics 23 (2003) 116–119 (in Chinese). [12] G. Cui, F. Hong, X. Yu, A class of optimal algorithms for determine the convex hull of a set of nodes in a plane, Chinese Journal of Computers 20 (1997) 330–334 (in Chinese). [13] W. Jin, T. He, X. Liu, W. Tang, R. Tang, A fast convex hull algorithm of planar point set based on sorted simple polygon, Chinese Journal of Computers 21 (1998) 533–539 (in Chinese). [14] T.M. Chan, Optimal output-sensitive convex hull algorithms in two and three dimensions, Discrete and Computational Geometry 16 (1996) 361–368. [15] H. Brönnimann, J. Iacono, J. Katajainen, P. Morin, J. Morrison, G. Toussaint, Space-efficient planar convex hull algorithms, Theoretical Computer Science 321 (2004) 25–40. [16] W. Chen, K. Wada, K. Kawaguchi, Robust algorithms for constructing strongly convex hulls in parallel, Theoretical Computer Science 289 (2001) 277– 295. [17] M.H. Overmars, J.V. Leeuwen, Maintenance of configurations in the plane, Journal of Computer and System Sciences 23 (1981) 166–204. [18] T.M. Chan, Dynamic planar convex hull operations in near-logarithmic amortized time, Journal of the ACM 48 (2001) 1–12. [19] G.S. Brodal, R. Jacob, Dynamic planar convex hull, in: Proceedings of the 43rd Annual IEEE Symposium on Foundations of Computer Science, 2002, pp. 617–626. [20] A.C. Yao, A lower bound to finding convex hulls, Journal of the ACM 28 (1981) 780–787. [21] C.B. Barber, D. Dobkin, H. Huhdanpaa, The Quickhull algorithm for convex hulls, ACM Transactions on Mathematical Software 22 (1996) 469–483. [22] N.M. Sirakov, A new active convex hull model for image regions, Journal of Mathematical Imaging and Vision 26 (2006) 309–325.