# Mean Shift Segmentation Assessment for Individual Forest Tree Delineation from Airborne Lidar Data
## Materials and Methods
### Methods
#### 3.2.2 Mean Shift Segmentation  
Mean shift has been widely used for image clustering in feature space, which can be multi-dimensional. This section will explain the different adaptations of mean shift for 3D point cloud segmentation. Given a lidar data of n points xi, i = 1,...,n in a 3D space, the mean shift vector can be derived as the gradient of a multivariate kernel density estimator as follows:  
\[\mathrm{v_{h}(x)}=\frac{\sum_{i=1}^{n}\mathrm{x_{i}g}\Big{(}\|\frac{\mathrm{x -x_{i}}}{\mathrm{h}}\|^{2}\Big{)}}{\sum_{i=1}^{n}g\Big{(}\|\frac{\mathrm{x-x_{ i}}}{\mathrm{h}}\|^{2}\Big{)}}-x \tag{1}\]  
in which g\((-)\) defines the kernel profile, and h is the bandwidth parameter that determines the size of the kernel. The vector \(\mathrm{v_{h}(x)}\) is the difference between weighted mean, using the kernel for weights, and point x, the center of the kernel, and is pointing toward the direction of the maximum increase in the density, so that the modes of density can be reached iteratively by translating the kernel (window) by the vector. [30; 31] can be referred to for more details. The algorithm has been adapted to a best fit for tree segmentation in terms of kernel shape, size and weight. _Kernel shape_: the simplest kernel shape in 3D is a sphere [42], and it is adapted to different shapes to better segment trees, such as a Cylinder [24]. The Pollock model has also been used as the kernel since the model represents the crown shape which can be adjusted by an extra parameter [27]. The model is defined as follows:  
\[\mathrm{F(x)}=\frac{Z}{b^{m}}+\frac{\sqrt{\left(X^{2}+Y^{2}\right)^{m}}}{a^{m} }=1 \tag{2}\]in which \(x=(X,Y,Z)\) with respect to the model center, a is the radius of the crown circle in the XY-plane, b is the radius along the Z-axis and m is the crown shape parameter. When m = 1, the model is a cone, and it becomes an ellipsoid as m increases to 2. These three kernel shapes, sphere, cylinder, and Pollock model, will be tested to determine their effects on tree segmentation. _Kernel size_: it has been shown that different kernel sizes can be used to segment trees of different sizes and at different layers of the canopy [24], but the settings of the kernel size are mostly trial and error based. Both the Cylinder and Pollock model kernels have two bandwidth/size parameters (a, b) along the horizontal and vertical axes, respectively. Most commonly, the ratio between the two bandwidth parameters b/a is kept fixed during the shifting process, and only one is tuned. Another approach is to adapt the kernel size to the height of trees under the assumption that taller trees will favor a larger kernel, whereas shorter and smaller trees will favor a smaller kernel. This approach is known as continuous adaptive mean shift (Camshift) [27]. In the tests, the kernel size (bandwidth) is tested in two regards, namely, (1) the effects of horizontal bandwidth (a \(\in[2,3,4,5,6,7,8,9]\)), and the ratio between the two bandwidth parameters (b/a \(\in[1,\ 1.5,\ 2,\ 2.5,\ 3]\)), and (2) whether the kernel is continuously adaptive to the height of the tree (Y or N). _Kernel weight_: in addition to the shape of the kernel, different weighting strategies can be applied to the kernel, including weight in the XY-plane, weight in Z, or simply a flat kernel without any weight. Horizontal kernel weights, such as a Gaussian function [24], will put more weight on the center points, meaning the kernel tends to move around less, which will result in more isolated points as standalone clusters. Vertical kernel weights, such as weighting on higher points in the kernel, will lead the kernel to move upwards to converge at the top of a tree [28]. The combination of vertical weight in height \(\frac{Z-Z_{\text{min}}}{Z_{\text{max}}-Z_{\text{min}}}\) and horizontal Gaussian weight for the Pollock kernel can be expressed as follows:  
\[g\left(\|\frac{x-x_{i}}{h}\|^{2}\right)=\left\{