# Image Segmentation by Searching for Image Feature Density Peaks
## 2 Materials and Methods
### Adaptive Selection of Cluster Centers  
Due to the difficulty of solving the above problem, a separate function is found to assist in picking the cluster centers automatically. The measure of functions is based on the method in [33] as following:  
\[R=\rho\delta-k\left(\rho+\delta\right)^{2} \tag{6}\]  
\(k\) is a constant determined by experience, which will affect the accuracy of the algorithm to some extent. In Section 3, the exact \(k\) value and its influence on the accuracy will be discussed in detail. The points are considered as cluster centers when \(R>0\). Thus, the separate function can achieve the separation between cluster centers and other sample points. Therefore, the decision graph in Figure 5 can be redrawn as follows:  
As shown in Figure 6, the points to the right of the curve are considered as the cluster centers. And after the cluster centers have been found, the remaining data points will be assigned to the same clusters as its nearest neighbors of higher density. Once a point is assigned to a cluster, the information regarding the classification is updated immediately, this procedure continues until no valid candidates are left to be assigned [8]. We define the _candidacy_ of a point \(i\) as follows:  
\[cady(i)=\begin{cases}true,&\text{point $i$ is cluster center}\\ false,&\text{otherwise}\end{cases} \tag{7}\]  
Figure 5: The decision graph, which is represented based on the both the local density \(\rho_{i}\) and distance \(\delta_{i}\) used in our method.  
For each point, we check its candidacy firstly. This helps us to filter out the points which are not valid candidates to be analyzed and hence reduces the computational time. This step is shown in Algorithm 1.  
```
0: cluster centers \(\{cady|cady(i)=1,i=1,2,\cdots,N\}\); the local density set \(P=\{\rho_{1},\rho_{2},\rho_{3},\cdots,\rho_{N}\}\) and distance set \(Q=\{\sigma_{1},\rho_{2},\sigma_{3},\cdots,\sigma_{N}\}\) for all superpixels computed from the original image.
1:for each: superpixel \(i\) with \(cady(i)=0\) in the rest of un-classified superpixels do
2: Searching for a series of superpixels \(SL\) with lower local density \(\rho_{i}\) by using density set \(P\) and Equations (1)-(4).
3: Searching for one superpixel \(pm\) with the minimum value of \(\sigma_{i}\) from \(SL\) by using the distance set \(Q\) and Equations (5)-(8).
4:if\(pm\) is a cluster center then
5:\(i\gets L\), where \(L\) is the class label of \(pm\)
6: Update cluster centers cady(i): \(cady(i)\gets 1\)
7:endif
8:endfor
9: All of the classified superpixels.
```  
**Algorithm 1** Assignment of remaining points  
Marking each pixel points with its cluster number, and the cluster number of each pixel data is the cluster number of the superpixel area to which the point belongs. And fill all pixel points with the mean color of the clusters they are belonging to. Then achieving the final segmentation based on the numbers marked through the last step, as shown in Figure 7.  
Figure 6: Separate Function Decision Graph. The letters of final cluster centers are marked by red color.  
Figure 7: The segmentation result **(a)** by our method on the original picture **(b)**.