University of Huddersfield Repository

University of Huddersfield Repository Lou, Shan, Jiang, Xiangqian and Scott, Paul J. Algorithms for morphological profile filters and their comparison Original Citation Lou, Shan, Jiang, Xiangqian and Scott, Paul J. (2012) Algorithms for morphological profile filters and their comparison. Precision Engineering, 36 (3). pp. 414-423. ISSN 01416359 This version is available at http://eprints.hud.ac.uk/12839/ The University Repository is a digital collection of the research output of the University, available on Open Access. Copyright and Moral Rights for the items on this site are retained by the individual author and/or other copyright owners. Users may access full items free of charge; copies of full text items generally can be reproduced, displayed or performed and given to third parties in any format or medium for personal research or study, educational or not-for-profit purposes without prior permission or charge, provided: • • • The authors, title and full bibliographic details is credited in any copy; A hyperlink and/or URL is included for the original metadata page; and The content is not changed in any way. For more information, including our policy and submission procedure, please contact the Repository Team at: [email protected] http://eprints.hud.ac.uk/ Algorithms for Morphological Profile Filters and Their Comparison Shan Lou, Xiangqian Jiang*, Paul J. Scott EPSRC Centre for Innovative Manufacturing in Advanced Metrology, University of Huddersfield, Huddersfield, HD1 3DH, UK *Corresponding author: Tel: +44 1484 473634; Fax: +44 1484 472161; E-mail: [email protected] Abstract Morphological filters, regarded as the complement of mean-line based filters, are useful in the analysis of surface texture and the prediction of functional performance. The paper first recalls two existing algorithms, the naive algorithm and the motif combination algorithm, originally developed for the traditional envelope filter. With minor extension, they could be used to compute morphological filters. A recent novel approach based on the relationship between the alpha shape and morphological closing and opening operations is presented as well. Afterwards two novel algorithms are developed. By correlating the convex hull and morphological operations, the Graham scan algorithm, original developed for the convex hull is modified to compute the morphological envelopes. The alpha shape method depending on the Delaunay triangulation is costly and redundant for the computation for the alpha shape for a given radius. A recursive algorithm is proposed to solve this problem. A series of observations are presented for searching the contact points. Based on the proposed observations, the algorithm partitions the profile data into small segments and searches the contact points in a recursive manner. The paper proceeds to compare the five distinct algorithms in five aspects: algorithm verification, algorithm analysis, performance evaluation, end effects correction, and areal extension. By looking into these aspects, the merits and shortcomings of these algorithms are evaluated and compared. Keywords: Morphological filter, alpha shape, motif combination, Graham scan, contact point 1. Introduction In the analysis of the surface texture, filtration techniques are widely used as a pre-process tool to evaluate the characteristics of surfaces. They play critical roles in several respects. For instance, the separation of different scales of features on surfaces is performed by filters. Furthermore filters help to remove noises derived from the surface roughness or measurement interruptions in order to achieve more stable data sets for further processes. Filters also help in functional simulation and performance prediction. Among various filtering techniques, the envelope filter depends on the geometrical features of surfaces [1] and thus is believed to give better results for functional prediction. With the introduction of morphological operations [2], morphological filters emerged as the evolution of the traditional envelope filter, offering more tools and capabilities. Acting as the complement of the mean-lines filters (e.g. the Gaussian filter), morphological filters have found many applications in practices over the last decade. They were applied to simulate the conformable interface of two mating surfaces [3] and analyze the inner surface of the cylinder liner comprising of deep valleys superimposed on the plateax roughness [4]. As to the implementation of morphological filters, several approaches are of concern. Following Von Weingraber’s work, Shunmugam & Radhakrishnan [5] developed a direct algorithm for the traditional envelope filter. Scott [6] proposed a general mathematical theory for motifs and motif combination. Meanwhile an efficient algorithm based on the motif combination was constructed to calculate the profile envelope and perform the functional simulation. Recently we [7] proposed a novel method for implementation of morphological filters, which is based on the alpha shape. This paper first recalls two existing algorithms for the traditional envelope filter and the alpha shape method for morphological filters. Afterward we propose two novel algorithms, the modified Graham scan algorithm and the recursive algorithm. The five algorithms are further analyzed and compared in various aspects, thus advantages and disadvantages of these algorithms are illustrated. Section 2 reviews the algorithm proposed by Shunmugam & Radhakrishnan and ISO 16610. We call it the “naive” algorithm for convenience in that this algorithm is a direct implementation to morphological operations as it will be seen in the section. Scott’s motif combination algorithm is given in Section 3. Section 4 presents the algorithm for morphological filters based on the alpha shape. In Section 5 we introduce the computational geometry technique into morphological operations calculation. Based on the correlation between the convex hull and morphological operations, the Graham scan algorithm, original developed for the convex hull computation is modified and adapted to calculate morphological envelopes. Section 6 presents another algorithm. Aiming to the deficit of the alpha shape method, a recursive algorithm is developed based on a series of observations concerning with the search of the contact points. The comparison of the five algorithms is conducted in Section 7 in five aspects: algorithm verification, algorithm analysis, performance evaluation, end effects correction, and areal extension. Finally Section 8 gives the conclusions. 2. Naive algorithm The naive algorithm was original developed to compute the covering envelope of the disk as it rolls over the profile. The envelope is the locus of the center of the rolling disk, usually compensated by the disk radius. The uncompensated envelope is in essence the morphological dilation of the profile data. If the disk rolls over the profile from below, the envelope of the rolling disk is the erosion of the profile. Thus according to the definition of morphological operations [8], morphological closing and opening could be obtained by combining the dilation and erosion pairs in sequence, either dilation followed by erosion or vice versa. The naive algorithm takes discrete representation of the input profile and the structuring element as illustrated in Figure 1 (The structuring element is a disk in this example). The disk ordinates ei are computed from the disk center to the two ends. These ordinates are placed over the profile ordinates with the disk ordinate e1 over the profile point p j with height ordinate z j . The ordinate where the mapping pair {( e , z ) | (i = j )} gives the maximum value max(e + z ) determines the height of the disk center. The i j i ( j ) envelope ordinate is given by max( ei + z j ) − e1 . This procedure is repeated for all the profile ordinates to obtain the whole envelope. In this sense, the naive algorithm conforms to the definition of the morphological dilation and erosion which are defined as the Minkowski addition and subtraction of the input set and the structuring element respectively [9]. Figure 1. Computation of the profile upper envelope. ISO 16610 Part 41 [10] presents a basic method to compute discrete morphological filters either. It puts the origin of the structuring element at every point of the input profile, as illustrated for a few positions of a circular structuring element for dilation in Figure 2. Extreme value at each position is collected and they form the output envelope. The extreme heights for input points are the results of adding the ordinates of input profile points with the ordinates of sample points on the disk, as marked by the top-most stars at vertical lines in the figure. 2 Figure 2. Dilation of the profile with a circular structuring element [10]. Essentially the basic approach presented by ISO 16610 is equivalent to the one proposed by Shunmugam & Radhakrishnan. They both take discrete forms of the input profile and the structuring element and compute the envelope ordinate at each sampling position. Figure 3 presents the pseudocode of the naive algorithm for morphological dilation. Due to the duality of morphological dilation and erosion, the erosion of opening profiles could be easily computed by first flipping the structuring element and later flipping the dilation results, i.e., Erosion ( X , B ) = − Dilation ( X , − B ) . (2.1) Combining morphological dilation and erosion in two opposite sequences results in morphological closing and opening. Figure 4 illustrates an example of applying the closing filter to a profile using the naive algorithm. The experimental profile consists of 250 sample data with sampling interval 5 µm. The profile is filtered by a 0.5 mm disk. Algorithm Dilation(X, B) {Given a profile data set S with n points and the structuring} {element B, compute the dilation D of X by B.} j = 1; m = B.length/2; while j <= n do D(j) = max(z(j-m) : z(j+m) + B); end while; return D; Figure 3. Naive algorithm for morphological dilation operation. Height / µm 4 2 0 -2 0.2 0.4 0.6 X / mm 0.8 1 1.2 Figure 4. Closing envelope computed by the naive algorithm. 3 3. Motif combination algorithm Scott [6] proposed an alternative way to calculate the profile envelope using the motif combination. Couple of definitions were given as the data type used in the algorithm. Events: an event splits the profile into a number of discrete sections. The events might be the highest points on all the local peaks or all the upcrossing of the profile through a reference line or even every sample point of the profile. They are numbered in order along the profile. The initial set of events is all the sample points on the profile. Motif: a motif ( i, j ) , where i < j , consists of that section of the profile between the i th and j th events. Motif Combination Test: it is performed on two adjacent motifs (say, two motifs ( i, j ) and ( j, k ) ) with the common event (say, j ) to determine if the common event is significant or not. If the event is not significant, two adjacent motifs to that event are combined (say, motifs ( i, j ) and ( j, k ) are combined to form a new motif ( i, k ) ) and thus the event is eliminated. For rolling a disk on the profile, the functional motif combination test is to check if the disk is possible to contact the common event by placing the disk on two adjacent motifs. The motif combination algorithm starts with the set of all events, namely all the sample data on the profile, and then it eliminates the insignificant events by repeatedly applying the motif combination test until all adjacent motifs pass the test. Scott found a set of criteria that the motif combination had to satisfy so that the order of the motif combinations did not matter, they all resulted in the same final answer. Both the rolling disk and the sliding line segment satisfy these criteria. The pseudocode of the motif combination algorithm is presented in Figure 5. Algorithm MotifCombination(X, B) {Given a data set X with n points and the structuring} {element B, compute the final motifs motifs } Chain list motifs= {(p1, p2), (p2, p3), …, (pn-1, pn)}; while 1 if CombineMotifs(motifs, B) break; end if; end while; return motifs; Procedure CombineMotifs(motifs, B) flag = false; motif1 = motifs(1); for i = 2 to motifs.length motif2 = motifs(i); if CombineTest(motif1, motif2, B) motif1 = {motif1.Start, motif2.End}; motifs.Remove(motif2); flag = true; end if; end for; return flag; Figure 5. Motif combination algorithm for morphological filters. The profile motif combination method results in a sequence of final motifs which are significant. The set of events specifying these motifs are the points which may contact the disk while it is traversing the profile. With the significant motifs, the envelope ordinates of the circular structuring element are computed by interpolating points on the arcs determined by the motifs at each sampling position. For the line segment 4 structuring element, the profile envelope ordinates are given by the smaller one of the two events of each final motif. Using this method, the same experimental profile data used in the previous section is filtered by morphological closing filter with the disk of the same radius. Figure 6 illustrates the closing envelope along with the significant motifs marked by the line segments. Height / µm 4 2 0 -2 0.2 0.4 0.6 X / mm 0.8 1 1.2 Figure 6. Closing envelope and final significant motifs computed by the motif combination algorithm. 4. Alpha shape algorithm Recently we [7] proposed a novel method for morphological filters based on the link between the alpha hull and morphological operations. The alpha shape was introduced by Edelsbrunner [11] aiming to describe the specific “shape” of a finite point set with a real parameter α controlling the desired level of details. The alpha hull is the boundary formed by rolling a ball (disk) with the given radius over the point set. There exists a theoretical link between the alpha hull and morphological operations: the alpha hull is equivalent to the closing of the point set X with a generalized ball of radius − 1 α and that from the duality of closing and opening the alpha hull is the complement of the opening of X c (complement of X ) with the same ball as the structuring element [12]. This relationship provides the theoretical basis of using the alpha shape to compute morphological filters. The basic idea of this approach is to compute the alpha shape of the data set and utilize it to calculate morphological opening and closing envelopes. The calculation of the alpha shape is based on the Delaunay triangulation. For a finite planar point set X , the Delaunay triangulation DT ( X ) results in a series of triangles. These triangles are connected by the points in the set as their vertices and the circumscribed circles of these triangles are all empty. The relationship between the Delaunay triangulation and the alpha shape is that the boundary of the alpha shape ∂Sα ( X ) is contained in the Delaunay triangulation DT ( X ) , namely ∂Sα ( X ) ⊆ DT ( X ) . ∂Sα ( X ) is a collection of simplices (triangles and edges) in DT ( X ) satisfying two properties: (i) the radius of the smallest circumcircle of the simplex is smaller than the disk radius α and the circumcircle is empty; (ii) the simplex is a face of super simplex of the alpha shape. The algorithm to compute the alpha shape boundary facets is illustrated in Figure 7. Following the Delaunay triangulation of the point set X , the algorithm loops to check the edges of the triangles in two steps. First, calculate the circumcircle of its super simplex, namely a triangle. If the radius of the circumcircle is smaller than the given disk radius α and the edge has an unique super triangle, then it belongs to the boundary facets. Otherwise, go to the second step. Compute the smallest circumcircle of the edge and compare with α . If smaller than α , continue to check whether the circumcircle is empty. If all these conditions are satisfied, then the edge is a boundary facet either. 5 Algorithm AlphaShape (X, α) {Given a point set X and the chosen disk radius α, computes} {the list f of the boundary facets of the alpha shape of X.} triangle = DT(X); i = 1; for each edge do R = CircumCircle(triangle); if R < α if Unique(triangle) f(i) = edge; i = i + 1; end if; continue; end if; R = CircumCircle(edge); if R < α if IsCircleEmpty(edge) f(i) = edge; i = i + 1; continue; end if; end if; end for; return f; Figure 7. Alpha shape algorithm for morphological filters. With the boundary facets of the alpha shape, the envelope ordinates are computed in a manner similar to the motif combination algorithm, i.e. interpolating point on the arcs determined by the alpha shape facets for each sampling position. Since there may exists overlap facets for a certain sampling position, only the extreme ordinate is retained. For instance, only the highest ordinates are retained for the closing envelope, and vice versa for the opening envelope. Again the alpha shape algorithm was performed on the same experimental profile data with a 0.5 mm disk. Figure 8 shows the resultant closing envelope as well as the alpha shape boundary facets marked by the line segments. Height / µm 4 2 0 -2 0.2 0.4 0.6 X / mm 0.8 1 1.2 Figure 8. Closing envelope and alpha shape facets computed by the alpha shape algorithm. 5. Modified Graham scan algorithm Morphological operations, as it were created, were first utilized to examine the geometrical structure of rock cross sections [13]. It then led to a new quantitative approach in image analysis. The central idea of morphological operations is to examine the geometrical structure of an image by matching it with small patterns at various locations in the image. By varying the size and the shape of the matching patterns, called 6 structuring elements, useful information about the shape of the different part of an image and their interrelation could be extracted. In general this procedure results in non-linear image operations which are well suited for the analysis of the geometrical and topological structure of an image [14]. This image processing method was introduced into the surface texture analysis as a non-linear filtering technique [2]. The measured data uniformly sampled on the surface are treated as the image pixels. In fact the naive algorithm is a typical image processing method. It however has some limitations by dealing the measured data as image pixels. Image has to be planar, unable to rotate in space, while the workpiece surface is a physical object existing in space, invariant under translation and rotation. It is thus more reasonable to view the sampled data as the point set in space rather than image pixels. As illustrated in Figure 9, the closing envelope is obtained by rolling a disk over profile from above and taking the lower boundary of the disks [15]. Consider the set of sample points as the discrete representation of the physical profile, it is equivalent to roll the disk over these discrete points. This operation turns to be a computational geometry problem instead of an image processing issue. Figure 9. Closing envelope obtained by rolling a disk over the profile [15]. In computational geometry, the convex hull is the most ubiquitous structure, playing a central role in many engineering computations. Intuitively the convex hull of a point set in 2D is obtained by pivoting an infinite extending line around the point set (See Figure 10). The line-segment envelope bounding the point set is called the convex hull. In the mathematical morphology point of view, the point set is equivalent to the image being processed and the infinite extending line serves as the structuring element. If replacing the infinite extending line by the desired geometrical object, for example, a disk, the convex hull turns to the morphological envelopes. In this sense, the convex hull could be viewed as a special morphological envelope with the infinite extending line being the structuring element. Based on that, it is able to correlate the convex hull computation technique with the morphological envelope calculation. Figure 10. Pivoting the infinite extending line around the point set yields the convex hull. Among various convex hull calculation methods, the Graham scan algorithm was a very efficient method for planar point set [16]. As illustrated in Figure 11, the algorithm sorts the points by angle counterclockwise firstly. Then the algorithm proceeds to consider each of the sorted point in sequence. It maintains a stack structure to hold the points on the convex hull found so far. For each point, it is determined whether moving from the two previously considered points to this point is a "left turn" or a "right turn". If it is a "right turn", it means that the second-to-last point is not part of the convex hull and should be removed from the stack. For example, in Figure 11, p3 , p4 and p5 forms a “right turn”, thus p4 is pop out from the stack. 7 Then the renewed chain, p2 , p3 and p5 , forms a “left turn”, and p5 is pushed into the stack. This process is continued as long as the set of the last three points is a "right turn". As soon as a "left turn" is encountered, the point is pushed into the stack and the algorithm moves on to the next point in the sorted array. In the end, the points contained in the stack are all the convex hull points. Figure 11. Graham scan algorithm for convex hull. To compute morphological profile envelopes, we modify the Graham scan algorithm with aim of searching the contact points, namely the points on the profile which may contact the structuring element. The modified algorithm does not sort the data as is required in the convex hull computation in that the profile points are naturally “sorted” in the sequence of sampling, but directly searches the contact points on the profile. Similar to the original convex hull method, the modified algorithm maintains a stack structure to contain the contact points. The algorithm pseudocode is presented in Figure 12. At beginning the stack keeps the first two sample points as the initial elements. Then it processes the rest of points incrementally. Each time the coming point is evaluated with the top element pt and the second top element pt −1 in the stack. The chain composed by the three points is checked whether the structuring element could contact the middle point pt −1 . If it is unable to touch pt −1 , the point in evaluation is pushed into the stack, otherwise the top element of the stack is popped out. The contact test is performed repeatedly until the test succeeds. Thus in this manner when all the points are processed, the points in the final stack are all the contact points. Algorithm GrahamScan(X, B) {Given a point set {pi|i<n} and the structuring} { element B, computes the contact points.} Stack stack = (p1, p2); t indexes top. i = 3; while i <= n do if t < 2 Push(stack, pi); continue; end if; if CheckContact(pt-1, pt, pi, B) Push(stack, pi); i = i + 1; else Pop(stack); end if; end while; return stack; Figure 12. Modified Graham scan algorithm for morphological filters. Similar to the motif combination algorithm in Section 3, the envelope ordinates for the circular structuring element are achieved by interpolating points on the arcs determined by the adjacent contact point 8 pairs at each sampling position. Likewise, for the line segment structuring element, the envelope ordinates are achieved by interpolating points on the horizontal line that pass through the lower contact point in the contact point pair. Figure 13 demonstrates the closing envelope of the experimental profile with disk radius 0.5 mm, computed by the modified Graham scan algorithm. The star marks in the figure are the contact points on the profile. Height / µm 4 2 0 -2 0.2 0.4 0.6 X / mm 0.8 1 1.2 Figure 13. Closing envelope and contact points computed by the Graham scan algorithm. 6. Recursive algorithm As already presented in Section 4, the alpha shape is extracted from the Delaunay triangulation. In fact the Delaunay triangulation could generate the whole family of alpha shapes. Therefore the Delaunay triangulation data is reusable for multiple trails of ball radii for the same data set. It is a merit for computation in that there is no need to perform the Delaunay triangulation for various radii attempts on the same data set. It however could be a drawback in the meanwhile because the Delaunay triangulation is costly for large data sets. Given a specific radius, the Delaunay triangulation contains much more information than the necessity to generate the corresponding alpha shape related with the given radius. Thus in this sense there is no need to achieve the desired alpha shape with redundant computations. A solution to this problem is to find the alpha shape boundary facets without performing the Delaunay triangulation. In fact the vertices of the alpha shape boundary facets are those points on the surface that contact the ball as it is rolling over the surface, namely the contact points. By investigating the contact points and their composition, it is possible to find the alpha shape boundary facets and afterward compute the morphological envelopes. Supposing to use an infinite large ball ( α → ∞ ) to roll over the point set X , the boundary of the alpha shape ∂Sα ( X ) turns to the convex hull ∂Conv ( X ) , i.e. lim ∂Sα ( X ) = ∂Conv ( X ) . In essence the infinite α →∞ extending line used in the context of the convex hull as mentioned in Section 5 could be viewed as a part of the infinite large ball. In this case, the boundary facets of the alpha shape of the point set are the facets of convex hull. Therefore the convex hull points are all the contact points with the infinite large ball as the structuring element. Given two difference ball radius, α1 and α 2 with α1 < α 2 , it could be found that the alpha shape of α1 is contained in the alpha shape of α 2 , i.e. α1 < α 2 ⇒ Sα1 ( X ) ⊆ Sα2 ( X ) [17]. Since the contact points are the vertices of the boundary alpha shape facets, the contact point set of the ball α 2 , P (α 2 ) must be contained in the contact point of α1 , P (α1 ) , namely α1 < α 2 ⇒ P (α 2 ) ⊆ P (α1 ) . This indicates that the contact points obtained from the big radius ball must be the contact points derived from the smaller radius ball. Since the convex hull is obtained using the ball with infinite large radius ( α → ∞ ), the convex hull point must be the contact points for arbitrary radius. For morphological envelope of the opening profile, the disk is rolling from either above or below depending on whether it is a closing operation or an opening operation. Thus only half of the convex hull points are desired for a certain morphological operations. For the closing envelope, only the upper convex hull points are the contact points. See Figure 14. These points naturally partition the profile data into small segments. In each segment, we search other possible contact points. 9 Figure 14. The upper convex hull of the profile data. Couples of observations are listed as follows concerning with the search of contact points. For convenience of explanation, we take the morphological closing envelope and the disk structuring element for demonstration. The opening envelope can be easily obtained by Formula 2.1 and the envelope using the line segment structuring element could also be achieved in a similar but easier manner. Given two contact points a and b and the disk radius r , (1) If there are sample points lying above the simplex σ ab (left/positive side of ab ), then the contact point is the furthest point orthogonal to ab . In Figure 15, p1 , c , p3 are three points between the two known contact points a and b . The furthest point c is the convex hull point for the point set {a , b, p1 , c, p3} [18]. c therefore is the contact point. Figure 15. Search the furthest point orthogonal to ab on positive side. (2) If there are no points lying above σ ab and there exist points { pi } inside the circular section ab of the disk with radius max{r , 1 2 ab } below σ ab , then the contact point c is the one among the points { pi } , which satisfied the condition: The circumscribed circle of σ abc have the largest radius among the { } circumscribed circles of σ abpi . Figure 16 (a) and (b) illustrates the case of ab ≤ 2r and the case of ab > 2r respectively. In the first case, it is clear that the alpha ball with radius r is not α -exposed, thus σ ab is not the alpha shape 10 { facets. However the circumcircle of σ abc which has the largest radius among σ abpi } must be empty. Thus c is the contact point. For the later case, we could find the similar result. (b) Figure 16. Search the contact point in the circular section below σ ab . (a): ab ≤ 2 r . (b): ab > 2 r . (3) If ab > 2r and there are no points lying above σ ab and also no points in the circular section ab of the disk with radius 1 2 ab below σ ab , then the contact point is the one c that satisfies the condition: the circumscribe circle of σ abc have the smallest radius among the circumscribed circle of { {σ } . abpi } See Figure 17. It could be noticed that among the circumcircle of σ abpi , the circumcircle of σ abc , which has the smallest radius, is empty. Thus in this case, the contact point is c . Figure 17. Search the contact point outside the circular section below σ ab with ab > 2 r . (4) If ab ≤ 2r and there are no points lying above σ ab and also no points in the circular section ab of the disk with radius r below σ ab , then there is no contact point between a and b , and σ ab is a boundary facet of the alpha shape. With these observations, all of the contact point can be found in a recursive manner. Figure 18 presents the pseudocode of the recursive algorithm. At the beginning, two end points of the profile data are selected as the initial contact points for the recursive process. Then the whole profile is divided into two segments by the partition point, i.e. the contact point found by the two initial points. This procedure is repeated in each profile segment until two end points in recursion could hold on the disk without containing any other points, namely the disk is empty. The final points result from the recursive procedure are all the contact points on the profile and the envelope could be obtained by interpolating point on the arcs determined by two adjacent contact points. 11 Algorithm CheckContactPnt(X, r) {Given a point set X and the chosen disk} { radius r, computes the contact points.} a ← the left end point of X. b ← the right end point of X. Partition(a, b, r); Procedure Partition (a, b, r) c ← contact point. if c exist Partition (a, c, r); Partition (c, b, r); else record a, b; return; end Figure 18. Recursive algorithm for morphological filters. Figure 19 illustrates an example of the closing envelope using the recursive algorithm. It employs the same experimental data and the disk radius as used in the previous sections. The contact points are circled in the figure. Height / µm 4 2 0 -2 0.2 0.4 0.6 X / mm 0.8 1 1.2 Figure 19. Closing envelope and contact points computed by the recursive algorithm. 7. Discussion In preceding sections five different algorithms have been presented for morphological profile filters, namely the naive algorithm, the motif combination algorithm, the alpha shape method and the modified Graham scan algorithm and the recursive algorithm. These five algorithms achieve the same goal, whereas they are derived from distinct origins and have their respective advantages and disadvantages. Thus in order to expose their merits and shortcomings, we proceed to discuss these algorithms in following perspectives: algorithm verification, algorithm analysis, performance evaluation, end effects correction and area extension. 7.1 Algorithm verification To verify the accuracy of these algorithms, they are applied on a milled surface profile. The profile contains 1000 points with sampling interval 10 µm. The profile is filtered by the morphological closing filter with disk radius 500 mm. The results from the five algorithms are graphed in Figure 20. It is clear from the figure that the five envelopes overlap except at the two ends of the profile. It indicates that the algorithms are in agreement with each other. The edge distortion is caused by the end effect of filtration on the open surface data. The traditional algorithm has the end effect corrected while the other algorithms do not. The end effect correction will be discussed later. 12 Height / µm 1 0.5 Raw profile Traditional algorithm Motif Combination algorithm Alpha shape algorithm Graham scan algorithm Recursive algorithm 0 -0.5 1 2 3 4 5 X / mm 6 7 8 9 10 Figure 20. Morphological closing envelopes generated by the five algorithms. 7.2 Algorithm analysis The naive algorithm, being a direct approach following the definition of morphological dilation and erosion, combines them to yield morphological closing and opening. This algorithm, may be improved by some techniques [19], is widely used in image processing. However it has some fatal limitations. For one thing, it is time-consuming for large data set and large structuring elements. The maximum size of the structuring element is limited due to the huge computation requirement, while for many real applications they may desire the structuring element size much larger than the profile length. For another, it is impossible for this algorithm to handle non-uniform sampled data. The motif combination algorithm emphasises the elimination of the insignificant motifs and obtains only the significant ones. It is an iterative process in that the motifs are merged repeatedly until no more combination occurs. The final events are the contact points on the profile. This algorithm is consistent with the functionality of morphological filters that the features on the profile smaller than the structuring element in size are removed by the filter. By defining the motif combination test criterion, i.e. how two adjacent motifs are combined, various types of structuring elements are available, for instance, circular disks and line segments. Although the structuring element is restricted to the convex object and is not allow to tilt, it could satisfy most of the applications [6]. The approach based on the alpha shape utilizes the relationship between the alpha hull and morphological operations that the boundary of the hull obtained by rolling the alpha ball over the point set is identical to the closing/opening envelope. Therefore the algorithm for computing the alpha shape could be used to calculate morphological closing and opening filters. This algorithm is based on the Delaunay triangulation. The triangulation data could be reused for multiple attempts of various disk radii. It could save a great deal of computing time since in real practice a multitude of trails may be made for an appropriate disk radius. Another merit is that it works for non-uniform sampled data, bringing more generality over the naive algorithm. Although the link puts the restriction that the structuring element must be circular, the circular disk is most commonly used and is regarded as the default structuring element in ISO 16610. In comparison to the naive algorithm as a typical image processing technique, which treats the measured data as image pixels, the modified Graham scan algorithm views the data as the point set in space. Regarding the measured data as the input set and the infinite extending line as the structuring element, the convex hull could be viewed as a special morphological envelope. It links computational geometry techniques with the calculation of morphological envelopes. The Graham scan algorithm original developed for the convex hull computation is modified and adapted to calculate morphological envelopes. The method is an incremental algorithm in that the profile data is processed in sequence and a new dealing data will cause the correction of the processed data. It simulates moving the structuring element over the profile and obtains the contact points. In this aspect it resembles the motif combination approach though they compute the contact points in a different manner. The alpha shape method depends on the Delaunay triangulation. The triangulation provides the information for generating the whole family of alpha shapes. It saves time for multiple trails of ball radii. However the Delaunay triangulation is costly for large data set. For a given radius, the Delaunay triangulation is redundant for the computation of the desired alpha shape related with the given radius. The recursive algorithm solved this problem. It searches the contact points based on a series of observations. The 13 algorithm partitions the profile into small segments and searches the contact point recursively until the two ends of the profile segment in evaluation could hold an empty disk with the given radius. 7.3 Performance evaluation To evaluate the performance of the five algorithms, it is necessary to analysis the time complexity of the algorithms. For the naive algorithm, the worse case is that the size of the structuring element is equal to or larger than twice of the profile length. The calculation of each envelope ordinate involves the whole profile data, thus its time complexity is O ( n 2 ) . The alpha shape method depends on the Delaunay triangulation with time complexity O ( n log n ) , therefore its time complexity is O ( n log n ) . For the motif combination approach, the iterative process has the time complexity O ( n ) . As to the Graham scan algorithm, since it does not need data sorting as required in the computation of the convex hull which may cost O ( n log n ) time, the computation of the contact points is also in O ( n ) time. The Graham scan algorithm has the same time complexity as the motif combination algorithm, however it requires less memory because it is incremental and does not need to handle all the data simultaneously. As to the recursive algorithm, in the worse case that each set of divided segments of data is as skewed as possible, the time complexity is O ( n 2 ) although it rarely occurs in real practice. Its expected time complexity is O ( n log n ) . To verify the actual performance, experiments are carried out on the profile data with the point amount varying from 1000 points to 80,000 points. The profile data is sampled from a metal sheet surface in form of the propeller blade. The evaluation length is 80 mm with sample interval 1 µm. The morphological closing filter with disk radius 5 mm was performed on the profiles using the five algorithms. These algorithms were implemented by Visual Studio C++ and ran on a computer with 3.16 GHz Intel Core Duo CPU and 3 GB RAM. The performance data are listed in Table 1. Table 1. Algorithm running times over various amount of profile data with same disk radius. Data amount Algorithm Naive algorithm Motif Combination algorithm Alpha Shape algorithm Modified Graham Scan algorithm Recursive algorithm 5,000 10,000 40,000 80,000 0.0010s 0.0076s 0.0124s 0.0079s 0.0010s 1.0294s 0.0157s 0.0508s 0.0158s 0.0025s 4.8391s 0.0609s 1.0112s 0.0636s 0.0916s 9.9274s 0.1238s 2.1531s 0.1253s 0.1038s The running time data presented in Table 1 verifies the theoretical analysis of the time complexity of the algorithms. The naive algorithm is most time consuming, spending nearly 10 seconds for the 80,000 data set. The alpha shape method is more efficient than the naive algorithm reducing the running time to about 2 seconds for the 80,000 data set. The alpha shape method is dependent on the Delaunay triangulation which could be costly in its data structure support, compared with other algorithms. The motif combination algorithm and the modified Graham scan algorithm are much more efficient, only spending 0.1 second. The recursive algorithm runs slower than the motif combination algorithm and the Graham scan algorithm, but is more efficient than the alpha shape algorithm and the naive algorithm. Another experiment was carried out with aim to assess the algorithm performances with the variation of disk radii. The experiment was performed on the 80,000 data set with the disk radius varying from 0.5 mm to 10 mm. The experimental data is presented in Table 2 and plotted in Figure 21. It is evident in the figure that the running time of the naive algorithm grows rapidly as the disk radius increases. The alpha shape algorithm and the recursive algorithm behave in an opposite manner: their running time decreases as the disk radius grows. It is reasonable considering the number of the alpha shape boundary facets decreases as the disk radius increases. And for the recursive algorithm, the recursion number reduces either with increase of the disk radius. As to the motif combination approach and the modified Graham scan approach, the disk radius variation has little impact on their performances. 14 Table 2. Algorithm running times with various disk radii and the same profile data. Data amount Algorithm Naive algorithm Motif Combination algorithm Alpha Shape algorithm Modified Graham Scan algorithm Recursive algorithm 0.5mm 1mm 5mm 10mm 1.0167s 0.1537s 2.4061s 0.1293s 2.2728s 2.0086s 0.1386s 2.2214s 0.1302s 1.5197s 9.9274s 0.1238s 2.1531s 0.1253s 0.1038s 19.3092s 0.1200s 2.0540s 0.1259s 0.0190s Figure 21. Algorithm running times on the same profile data using various disk radii. 7.4 End effects correction End effects are common in the filtration of open profiles. Mean-line based filters, for example the Gaussian filter, have distortion at both ends of the profile for half cut-off wavelength. A common solution for mean-line filters is to add sufficient zeros to the ends of the profile, referred as zero-padding [20]. Morphological filters have similar problems. The distortion is confined to two ends of the profile maximum for half size of the structuring elements. The solution to correct the distortion varies for specific algorithms. The naive algorithm calculates the dilation and erosion and combines them in pairs. Both of dilation and erosion need to correct end effects. The solution is similar to the zero-padding as used in meanline filters: the profile is assumed to drop down to the negative/positive infinity outside of the profile for dilation/erosion respectively, known as infinity padding. It pads sufficient extreme ordinates for half size of the structuring element on both ends. Fig. 22 illustrates the infinity padding for dilation with circular structuring element. Since the closing and the opening are combined using the dilation and the erosion, end effects are automatically handled [10]. Other algorithms are different from the naive algorithm in this aspect. They yield the closing and the opening directly without combining dilation and erosion. Zero-padding does not work for them because these algorithms depend on the geometrical properties of the profile. Thus the padded part of the profile cannot be geometrically viewed as flat. Instead it should reflect the geometrical features of the profile ends. Therefore padding should be made by reflection as Figure 23 presents [7]. Figure 22. Infinity padding on two ends of the profile. Figure 23. Reflective padding on two ends of the profile. 7.5 Areal extension All the five algorithms work for morphological profile filters. It naturally leads to investigate whether they could be extended to areal data. It could be easily recognized that the naive algorithm could apply to areal data by replacing the profile structuring element with its areal counterpart. For instance, the disk used in profile data becomes the ball in areal data. In this case, extreme points are achieved by evaluating the vector sum of the ball and the areal data in range overlapped by the ball. The alpha shape method is also possible to extend to the areal data if replacing the disk with the ball. Instead of a series of 2-simplexes resulted by the 2D Delaunay triangulation, the 3D Delaunay triangulation yields a series of 3-simplexes. Subsequently by checking the smallest circumsphere of these 3-simplexes, the facets of the alpha shape could be obtained. Then the spatial envelope ordinates can be achieved by interpolating points on the caps determined by the alpha shape boundary facets. As to the motif combination algorithm, it has no obvious extension to the areal data because the motif combination test could be complex in the spatial case. For the modified Graham scan algorithm, there is no existing extension for 3D data. An algorithm called the ball pivoting algorithm [21] was developed to reconstruct the surface from the discrete point cloud. It simulates rolling a ball over the areal point set. In this sense this method could be viewed as the extension of the modified Graham scan algorithm for profile data. Obviously it is possible to extend the recursive algorithm to areal data. For example, the disk could be replaced by the ball and the partition are assumed to be done by intersecting three planes passing through the contact point and three vertices of the base triangle face respectively. 8. Conclusion In this paper two existing algorithms, the naive algorithm and the motif combination algorithm, are first recalled, which were originally developed for the traditional envelope filter. With minor extension, they could be applied to morphological filters. A recent approach based on the alpha shape is presented as well. It makes use of the link between the alpha hull and morphological closing and opening that the alpha hull is theoretically equivalent to the closing and opening. Afterward two novel algorithms are developed, namely the modified Graham scan algorithm and the recursive algorithm. By correlating the convex hull and the morphological operation, the Graham scan algorithm for the convex hull computation is modified and adapted to compute the morphological operations. The alpha shape method depends on the Delaunay triangulation which is costly and redundant for the computation for a given radius. The recursive algorithm solved this problem. A series of observations are presented for searching the contact points. Based on these observations, the algorithm partitions the profile data into small segments and searches the contact points in a recursive manner. The comparison of the five algorithms is further discussed in five aspects: algorithm verification, algorithm analysis, performance evaluation, end effects correction, and areal extension. The experimental results show that the five algorithms are in agreement with each other except at two ends of the profile. The naive algorithm is a direct implementation to morphological operations but it is time consuming for large data set and large structuring element. It has several limitations, such as the size of the structuring elements is restricted and unable to handle non-uniform sampled data. Opposed to these limitations, the alpha shape algorithm provides more feasibility and flexibility as well as easy extension to areal data. The motif combination approach and the Graham scan approach are most efficient in performance with the linear time complexity. However they are hard to extend to areal data. The recursive algorithm is slower than the motif combination algorithm and the modified Graham scan algorithm, but more efficient than the naive algorithm and the alpha shape algorithm. A great merit of the recursive algorithm is that it is easy to extend to areal data which would be efficient for large areal data sets and large structuring elements. The correction of end 16 effects varies for specific algorithms. Infinity padding works for the naive algorithm while the other four algorithms use reflective padding. Acknowledgements The author X. Jiang gratefully acknowledges the Royal Society under a Wolfson-Royal Society Research Merit Award. The authors gratefully acknowledge the European Research Council for its “Ideal Specific programme” ERC-2008-AdG 228117-Surfund and the UK research council for its “manufacturing the future” program on the EPSRC centre in advanced metrology. References [1] H. Von Weingraber, Zur Definition der Oberflächenrauheit, Werkstattstechnik Masch Bass 46 (1956). [2] V. Srinivasan, Discrete morphological filters for metrology, Proceedings of the 6th ISMQC Symposium on Metrology for Quality Control in Production TU Wien Austria (1998) 623-628. [3] C. M. Malburg, Surface profile analysis for conformable interfaces, Transactions of ASME 125 (2003) 624-627. [4] B. Muralikrishnan, J. Raja, Functional filtering and performance correlation of plateau honed surface profiles, Manufacture Science and Engineering 127 (2005) 193-197. [5] M. S. Shunmugam, V. Radhakrishnan, Two-and three dimensional analyses of surfaces according to the E-system, Proc. Instn. Mech. Eng. 188 (1974) 691-699. [6] P. J. Scott, The mathematics of motif combination and their use for functional simulation, Int. J. Mach. Tools Manufact. 32 (1992) 69-73. [7] S. Lou, X. Jiang, P. J. Scott, Fast algorithm to morphological filters, Journal of Physics: Conference Series 311 (2011): 1-5. [8] J. Serra, Image Analysis and Mathematical Morphology, Academic Press, New York, 1982. [9] H. Minkowski, Volumen and oberflache, Mathematical Annals 57 (1903) 447-495. [10] International Standards Organization, ISO 16610-41 Geometrical Product Specification (GPS)-Filtration Part 41: Morphological profile filters: Disk and horizontal line-segment filters, Switzerland, 2010. [11] H. Edelsbrunner, E. P. Mucke, Three-dimensional alpha shapes, ACM Trans. Graph. 13 (1994) 43-72. [12] M. Worring, W. M. Smelders, Shape of arbitrary finite point set in R2, Journal of Mathematical Image and Vision 4 (1994) 151-170. [13] G. Matheron, and J. Serra, The birth of mathematical morphology, Proc. 6th Intl. Symp. Mathematical Morphology (2002) 1-16. [14] H. J. A .M Heijmans, Mathematical morphology: a modern approach in image processing based on algebra and geometry. SIAM Review 37 (1995) 1-36 [15] P. J. Scott Scale-space techniques Proceedings of the X International Colloquium on Surfaces (2000) 153-161 [16] R. Graham, An efficient algorithm for determining the convex Hull of a finite planar set, Information Processing Letters 1 (1972) 132-133. [17] K. Fischer, Introduction to Alpha Shapes, http://www.inf.ethz.ch/personal/fischerk/pubs/as.pdf (2000) [18] C. B. Barber, D. P. Dobkin, H. T. Huhdanpaa, The Quickhull algorithm for convex hulls, ACM Transactions on Mathematical Software, 4 (1996) 469-483. [19] M. H. Sedaaghi, Direct implementation of open-closing in morphological filtering, Electronic Letters 33 (1997) 198-199. [20] International Standards Organization, ISO 16610-28 Geometrical Product Specification (GPS)Filtration-Profile Filters Part 28: profile filters: End effects, Switzerland, 2010. [21] F. Bernardini, J. Mittleman, H. Rushmeier, C. Silva, G. Taubin, The ball-pivoting algorithm for surface reconstruction, IEEE Transactions on Visualization and Computer Graphics 5 (1999) 349-359. 17
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Related manuals
Download PDF
advertisement