## 2 Three-Dimensional Object Segmentation and Labeling Algorithm
### Distance Connected Component Algorithm
The distance resolution \(\Delta Z\) of the center pixel and the magnitude of the separation distance \(S\) are used to determine the value of _TH_dis_. The distance resolution \(\Delta Z\) can be expressed by Equation (5), where \(d\) represents the disparity value of the center pixel. The value of _TH_dis_ is set using Equation (6). \[\Delta Z=\left|\frac{Bf}{d-1}-\frac{Bf}{d}\right|=\left|\frac{Bf}{d(d-1)}\right| \tag{5}\]  
\[TH\_dis= \begin{cases}S,&\text{if }\Delta Z\leq S\\ \Delta Z,&\text{if }\Delta Z>S\end{cases}  \tag{6}\]  
The separation distance \(S\) is a preset fixed value, which is used to define the minimum distance between the overlapping objects to be segmented. Considering the difference in size and distribution of the objects photographed in outdoor and indoor scenes, this paper preset \(S\) to 30 cm and 10 cm for outdoor and indoor scenes, respectively. The outdoor test image shown in Figure 4c is used as an example to illustrate the process of distance object labeling. In the outdoor scene, \(S\) is preset to 30 cm. In Figure 5a, each grid represents the position of a single pixel, the number at the top of the grid is the distance (cm) of the pixel, and the number in the bracket at the bottom of the grid represents the label number. The parity value \(d\) of the center pixel is 75 pixels, and the distance value is 515 cm computed by Equation (2). The \(\Delta Z\) obtained using Equation (5) is 7 cm. The _TH_dis_ is determined by Equation (6) to be 30 cm. First, the absolute value of the difference in distance between the adjacent edge pixels and the center pixel is calculated. Only the value of the upper left adjacent edge pixel is larger than _TH_dis_, and the remaining are smaller than _TH_dis_. Therefore, the upper left adjacent edge pixel is not adjusted, as shown in Figure 5b. Next, we observed that the difference in distance between the center pixel and the upper right adjacent edge pixel is the smallest. Therefore, the label number of the center pixel is marked as (2), and the upper right adjacent edge pixel is defined as the reference point. Because the absolute value of the difference in distance between the upper adjacent edge pixel and the reference point is greater than _TH_dis_, the upper adjacent pixel is not adjusted. The absolute value of the difference in distance between the left adjacent edge pixel and the reference point is less than _TH_dis_; therefore, the label number of the left adjacent pixel is adjusted to (2). The processing result is shown in Figure 5c. After completing the distance connected component algorithm, each line segment can be labeled and recorded with 3D adjacent connection characteristics. The processing result of the distance connected component algorithm is shown in Figure 6. In Figure 6, different colors represent different line segments. Each line segment records the object number, bounding box coordinates, and endpoint coordinates. There are 4073 objects after the processing of the distance connected component algorithm, including single isolated points and line segments composed of multiple points. Figure 5: Example of distance object labeling process. (**a**) Center pixel and adjacent edge pixels; (**b**) The adjustment of the processing; (**c**) The result of distance object labeling process.