## 2 Methods
### ITS Set Aggregation Based on Gradient Change  
Due to the offset randomness caused by the deep network, the mean shift may individually cluster some branches, resulting in under-segmentation errors. In order to reduce the over-segmentation error, the ITS set aggregation algorithm is designed.  
When two sets are aggregated, the smaller set should be aggregated into the larger set. In the process of extreme offset, most of the points are successfully offset to the treetop, but a small part of the points are invalid offset. Therefore, the larger scale of the set, the closer the set is to the correct segmentation result. Therefore, the set with a relatively large scale is regarded as part of the correctly segmented individual tree, and the set with a relatively small scale is regarded as a fragment generated by an invalid offset.  
The ITS set aggregation algorithm based on gradient change criterion is as follows. If the horizontal distance between the fragment vertex point and the nearest neighbor point of the other set is greater than the preset bandwidth, then the gradient between the two sets is considered to change dramatically; therefore, they belong to different trees, respectively, and should not be aggregated, as shown in Figure 5a.  
If the horizontal distance between the fragment vertex point and the nearest neighbor point of the other set is less than the preset bandwidth, then the gradient change between the two sets is considered to be gentle, and they should belong to the same tree; therefore,  
Figure 5: Schematic diagram of the ITS set aggregation. (**a**) The purple and green sets should not be aggregated; (**b**) The green and blue sets should be aggregated.  
the two sets are aggregated, as shown in Figure 5b. The ITS set aggregation is shown in Equations (6)-(8).  
\[\left\{P_{i}\right\}_{i=1}^{m}=\left\{\cup_{j=i}^{m}\Theta\big{(}P_{i},P_{j} \big{)}\middle|\begin{matrix}i,j\in\{1,2,\cdots,m\}\\ i\leq j\end{matrix}\right\}, \tag{6}\]  
\[\Theta\big{(}P_{i},P_{j}\big{)}=\left\{P_{j},\quad dis_{\textit{avg}}\big{(}P_ {i},P_{j}\big{)}<k\cdot w\right. \tag{7}\]  
\[dis_{\textit{avg}}\big{(}P_{i},P_{j}\big{)}=\left\{\begin{matrix}\left\|t_{P_{i }}-near_{P_{j}}\right\|_{2},&N_{P_{i}}<N_{P_{j}}\\ \left\|t_{P_{j}}-near_{P_{j}}\right\|_{2},&N_{P_{j}}\geq N_{P_{j}}\end{matrix} \right., \tag{8}\]  
where \(\left\{P_{i}\right\}_{i=1}^{m}\) represents the point set after set aggregation; \(m\) denotes the number of sets currently; \(\Theta\big{(}P_{i},P_{j}\big{)}\) decides whether to merge the two sets \(P_{i},P_{j}\); \(dis_{\textit{avg}}\big{(}P_{i},P_{j}\big{)}\) computes the Euclidean distance between two sets in the xoy plane; \(t_{P_{i}}\) is the highest point in the set \(P_{i}\); \(near_{P_{j}}\) is the nearest point from the set \(P_{j}\) to other set \(P_{i}\); \(N_{P_{i}}\) denotes the total number of points in the set \(P_{i}\); \(N_{P_{j}}\) denotes the total number of points in the set \(P_{j}\); \(w\) is the raster width (0.5 by default); \(k\) is the preset bandwidth (1.5 \(w\) by default).  
After the above processing, there may be noisy point sets with a small number of points. These noisy point sets will be directly aggregated into the nearest sets.