# Image Segmentation by Searching for Image Feature Density Peaks
## 2 Materials and Methods
### Improvement of the Clustering Method  
The novel clustering approach based on the assumption is that the cluster centers are surrounded by points with lower local density and have a relatively large distance from points with higher density [15]. The steps that required to complete this method are as follow:  
For each point \(i\), \(1\leq i\leq N\) (N is the total number of superpixels) based on the basic assumption, there are only two quantities need to be computed: its distance \(\delta_{i}\) from points of higher density, and its local density \(\rho_{i}\)[15; 23; 29]. In the original clustering method, the local density \(\rho_{i}\) is computed according to the following equation:  
\[\rho_{i}=\sum_{j}X\left(d_{ij}-d_{c}\right)\,, \tag{1}\]  
where  
\[X\left(d\right)= \begin{cases}1,&d<0\\ 0,&otherwise\end{cases}  \tag{2}\]  
Figure 4: (**a**) Original image. (**b**) The 2-d color feature space for all sample points from image (**a**), which is represented through the strategy illustrated in Figure 3. (**c**) Local density \(\rho\) for sample points, which are shown as 3D shaded surface plot of the probability density function. (**d**) Distributions of discrete distance \(\delta\) for 3D condition, which are computed by using Equation (5). \(d_{ij}\) is the Euclidean distance between data point \(i\) and data point \(j\), and \(d_{c}\) is the cutoff distance. Actually, \(\rho_{i}\) is decided based on the number of points that are closer than \(d_{c}\) to point \(i\). It's obvious that the choice of \(d_{c}\) has a huge impact on the algorithm if the value of \(d_{c}\) is not appropriate, then the efficiency of the procedure will be greatly reduced. The solution of local density \(\rho_{i}\) is an important parameter which indicates the sparseness of distribution of sample points and has a considerable influence on the final analysis results [30]. In our work, we proposed another way to compute local density \(\rho_{i}\) without a cutoff distance. Kernel density estimation (KDE) [31] is the most commonly used density estimation method, which is a non-parametric way to estimate the probability density function of a random variable. Let us define an multivariable independent sample \(\left(\left(x_{1},y_{1}\right),\left(x_{2},y_{2}\right),\ldots,\left(x_{n},y_ {n}\right)\right)\), whose distribution is drawn from our superpixels distribution in the feature space. In other words, the values of the sample points in the \(L\) channel and \(a\) channel are respectively stored in \(\mathbf{x}\) and \(\mathbf{y}\). We intend to fit the shape of samples' probability density function \(\rho\), its kernel density estimator is:  
\[ \begin{split}\rho_{i}\left(x,y\right)&=\frac{1}{n} \underset{i=1}{\overset{n}{\sum}}K_{h}\left(x-x_{i},y-y_{i}\right)\\ &=\frac{1}{nh}\underset{i=1}{\overset{n}{\sum}}K_{h}\left( \frac{x-x_{i}}{h},\frac{y-y_{i}}{h}\right)\end{split}  \tag{3}\]  
where \(K\) is kernel which is a non-negative function integrates into one. \(h>0\) is bandwidth, which is also called window, it is a smoothing parameter whose choice will strongly influence the estimation results [32]. The kernel density estimation is to use a smooth peak function we called 'kernel' to fit the observed data points, so as to simulate the true probability distribution curve. Kernel density estimate has many types of kernel, the Gaussian kernel function is one of the most commonly used among them, so we apply it to figure out local density \(\rho_{i}\). \[K\left(x,y\right)=\frac{1}{2\pi\sigma^{2}}\exp\left(-\frac{\left(x-x_{0} \right)^{2}+\left(y-y_{0}\right)^{2}}{2\sigma^{2}}\right) \tag{4}\]  
In this method, we used the kernel approach described in [16]. And we can see the 3-dimensional density estimation result clearly in Figure 4a. In addition to the following calculations, the density values and function shape also provide grounds for roughly estimating the location of the cluster centers and more comprehensively classifying sample points.