4.1.1. Fruit Clustering Definition

In order to determine which cluster set should a fruit belong to; the following definitions are given:

(1) If Dij, the center distance between fruit i and j, is less than or equal to the sum of their radius, as Equation (15), fruits i and j belong to the same cluster;

$$\mathbf{D}\_{\overline{\mathbf{i}}} \le \mathbf{r}\_{\overline{\mathbf{i}}} + \mathbf{r}\_{\overline{\mathbf{j}}} \tag{15}$$

where,

ri, rj represent the radius of fruit i and j, respectively.


#### 4.1.2. Local Density Calculation

Let N be the set of all mature fruits and n be the set of the number of fruits. The local density ρ<sup>i</sup> represents the number of fruits that belong to the same cluster (that is, meet the definition (1) in Section 4.1). The larger the local density, the more likely the fruit is the center of the cluster center; when the local density is 0, the fruit is a discrete fruit. The calculation process of local density is as follows:

$$\rho\_{\mathbf{i}} = \sum\_{\mathbf{j}=1}^{n} \text{Clu}\_{\overline{\mathbf{i}}\prime} \text{ i } \neq \mathbf{j} \text{ i } \mathbf{j} \in \mathbb{N} \text{ } \tag{16}$$

$$\text{Chu}\_{\text{ij}} = \begin{cases} 1, & \text{D}\_{\text{ij}} \le \text{r}\_{\text{i}} + \text{r}\_{\text{j}} \\ 0, & \text{D}\_{\text{ij}} > \text{r}\_{\text{i}} + \text{r}\_{\text{j}} \end{cases}, \text{ i } \ne \text{j, i, j} \in \mathbb{N}, \tag{17}$$

where Cluij is used to determine if fruit i and j belong to the same cluster.

4.1.3. Improved Density-Based Clustering Algorithm

The improved clustering algorithm is divided into an ascending process and a descending process, as shown in Figure 8.

**Figure 8.** The flow chart of the improved local density-based clustering algorithm.

In the ascending process, calculate the local density of different fruit points, find the high local density point closest to the fruit point, form a data chain from the data points of low local density to high local density, and find the cluster center of the ascending process for all fruits point. The codes in details are shown in Table 1.



In the descending process, the data point with the highest local density is used as the cluster center, and then the data chain is merged. After all data points are traversed, and finally, clustering is performed to complete the unified operation of all fruit clustering centers in the same cluster, the codes in detail are shown in Table 2. In addition, consolidation operations were added to the descent. Because the growth characteristics of straw-rotting fungus easily lead to the highest local density points within the same cluster, which may not be unique, they need to be integrated into the same cluster. For example, the local density values of A and B in Figure 9 are both equal to 3, which are both the highest local density points in the cluster. In this case, fruit A and B may be the cluster centers of each other, so it is necessary to integrate Fruit A and B into the same cluster. Its processing method is shown in lines 9–10 in Table 2.

**Table 2.** The codes of descending process of the improved clustering algorithm.


**Figure 9.** The highest local density point within the cluster is not unique.
