## 2 Three-Dimensional Object Segmentation and Labeling Algorithm
### Object Extension and Merge Algorithm
The closure property of a line segment defines whether the extension of the line segment endpoints of two different objects can form the same line segment. The extension and intersection of two-line segment endpoints can be classified into two categories: (1) there is an intersection in the extension direction of the two endpoints; (2) the extension of a single endpoint intersects with another line segment. Plane 62 in Figure 8 is used as an example, as shown in Figure 10. The examples of Categories 1 and 2 are shown in Figure 10a,b, respectively. Only the extension and intersection of the line segment endpoints in Category 1 can form the same line segment and satisfy the closure property. The extension objects that satisfy the closure property of a line segment have to judge the color continuity of the line segment. In the process of color continuity, the similarity of the average color values on both sides of the line segment endpoints is compared between the processed object and the extension object. The method for calculating the average color value on both sides of the line segment endpoints is illustrated in Figure 11. In the figure, the line segment is numbered sequentially from the endpoint, and a \(7\times 7\)-pixel block centered on the 5 th point (No. 5) of the line segment end point (No. 1) is obtained. In the pixel block, the line segment is used as the boundary line to calculate the average color value on both sides of the line segment and then obtain the sum of the absolute difference between the average color values of two object endpoints and both sides. If there are multiple extension objects, the smallest value of the sum of the absolute difference is used. When the sum of the absolute difference is less than \(TH\_color\), object extension and merging are performed. \(TH\_color\) is preset to 60. During the object extension and merging, the label number of the extension object is changed to be the same as that of the processed object, the record of two extended and connected endpoints is canceled, the labeling data of the two objects are retained, and the bounding box coordinate record of the merged object is modified. Continuing to process the next object until all objects in this distance plane are processed. Figure 10: Example of the closure property of a line segment using Plane 62 in Figure 8. (**a**) Category 1; (**b**) Category 2. Figure 9: Illustration of the extension direction. Figure 12a shows the extension connection judgment result of Plane 62 in Figure 8b. After the extension connection judgment, each object is composed of different line segments. Therefore, the third step, that is, overlapping object processing, is performed to merge different line segments of the same object on a single distance plane into the same object. The line segments are merged based on the overlapping characteristic of adjacent objects. Hence, the adjacent objects with overlapping bounding boxes are merged and the label number of the small object is changed to be the same as that of the large object. The bounding box coordinate record of the merged object is modified and the endpoint record of the two objects is retained. Figure 12b shows the result of Figure 12a after overlapping object processing. Different contour line segments of the front of the truck can be merged into the same object. Figure 12c shows the processing result of the single-distance plane line segment extension. Here, 2663 objects are merged into 1146 objects after the single-distance plane line segment extension. Finally, the cross-distance plane line segment extension is performed, and the main purpose is to judge each edge line segment in different distance planes and merge the line segments that satisfy the cross-plane extension connection condition. During the cross-distance plane line segment extension, planes are processed from nearest to farthest. First, all the endpoints of an object in Plane 1 are obtained and it is determined sequentially whether an extension object exists in Plane 2 in the extension direction of each endpoint.