# A 3D Vision-Based Weld Seam Extraction Method for Arbitrarily Placed Spatial Planar Weldments
## 2 Improved RANSAC for Plane Segmentation
### Consecutive Plane Segmentation  
With the proposed improved RANSAC algorithm for single-plane segmentation, consecutive segmentation becomes achievable. To consecutively segment multiple planes from a point cloud, the fundamental concept involves iteratively executing the algorithm on the point cloud with the inliers of the last segmented plane removed until all valid planes are segmented from the point cloud. Figure 6 illustrates this process. The output of the consecutive plane segmentation comprises a list of plane models segmented from the input point cloud, along with the corresponding inliers of each segmented plane.  
In consecutive plane segmentation, two termination conditions can be considered: the number of segmented planes and the number of remaining points. Since the former requires clear user expectations, making automation applications less flexible, the latter termination condition is adopted in this paper.  
In the proposed improved RANSAC algorithm, comparisons of normal vectors occur frequently, leading to time-consuming duplication of efforts. Particularly in the sampling process, numerous invalid iterations are spent on sampling points with different normal vectors. This inefficiency could be mitigated by clustering points based on normal vectors. To explore this approach, the normal vectors of the point cloud are visualized in a unit ball (Figure 7a), and the result is rendered into a temperature map representing the probability density of the normal vectors (Figure 7b). It becomes apparent that the points can be clustered based on their normal vectors. This insight inspires us that most points in a point cloud can be divided into several clusters according to their normal vectors.  
Figure 5: Segmentation before (**a**) and after (**b**) using Rule 5, with each segmented plane rendered in a different color.  
Figure 6: The process of consecutive plane segmentation: Each step of the segmentation fits a plane and removes its inliers. The inliers of each plane are rendered in a different color. The color contrast of the inliers belonging to the same plane is caused by the inconsistent density of points in the point cloud (caused by occlusion during point cloud capturing).  
To precisely obtain cluster information, Euclidean clustering is applied to the unit ball in Figure 7b. The result (Figure 7c) resembles the probability density result in Figure 7b. The three major clusters in Figure 7c correspond to the three groups of orthogonal planes in Figure 7a.  
Normal vector clustering offers two significant merits. Firstly, by clustering points, sampling is performed from a cluster rather than the entire point cloud in each iteration. This not only enhances sampling efficiency by reducing the sample space but also decreases the number of points to be considered in subsequent steps. Secondly, since points with different normal vectors are segregated into distinct clusters, they do not interfere with each other during the selection and counting of inliers, leading to improved segmentation results.  
The detailed steps of consecutive plane segmentation based on normal vector clustering are elucidated in the pseudo-code provided in Section 2.4.2.