## 2 Materials and Methods
### Detection Algorithm of Grape Clusters
#### 2.2.3 Construct Strong Classifier Based on the AdaBoost Framework  
The detection method and model are the key technology to precisely identify the grape clusters. Although these classification models constructed in Section 2.2.2 can be used to identify grape object, most of these models play a limited role in grape clusters detection. To regenerate a strong classifier, a new classification application was investigated by combining the AdaBoost algorithm and the various constructed linear classifiers. The AdaBoost algorithm is an iterative algorithm which was proposed by [PERSON] and [PERSON] [34; 35] according to the online assignment algorithm. In the AdaBoost algorithm, a different set of training samples is obtained by changing the distribution of the sample weight [36; 37]. At the beginning, the weight of every sample was set at the same value, and then the first weak classifier was trained according to the given weight. After a round of iterative, the corresponding weight for the misclassified samples would be increased, and the weight for the correct classification sample would be reduced, so the misclassified samples were highlighted, a new weight for every sample were regenerated. The second weak classifier was trained using the new weight, and in a loop until the last weak classifier was trained out. Finally, a desired strong classifier was obtained by a weighted average of the multiple weak classifiers. In order to illustrate the proposed classifier clearly, based on the discussion in Section 2.2.2 and Equation (4), we described the weak classifiers \(h_{t}(x_{i})\) by Equation (6):  
\[h_{t}(x_{i})= \begin{cases}1&L_{t}(x_{i},p)\geq 0\\ -1&otherwise\end{cases}  \tag{6}\]  
where \(t\) was the series number of the weak classifiers and also was a running index which means the iterative times in the AdaBoost algorithm (\(1\leq t\leq T\)), \(L_{t}(x_{i},p)\) was the dividing line of the corresponding classifier and \(p\) are the parameters set of the classifier. When the value of \(L_{t}(x_{i},p)\) was greater than 0, \(x_{i}\) was considered to be grape cluster (1), otherwise, \(x_{i}\) was view as background (\(-1\)). The pseudo code and the detailed training process of the proposed classifier are as follows (in Algorithm 1):  
```
0: Training samples set \(Data=(x_{1},x_{2},\ldots x_{N})\) and number of learning rounds \(T\). 1. \(D_{1}(x_{i})=1/m\) % Initialize the weight distribution for all samples
2. For\(t=1,\ 2,\ \ldots T\)

\(h_{t}(x_{i})=LCE(Data,D_{t}(x_{i}))\) % Train a learner \(h_{t}(x_{i})\) from \(Data\) using \(D_{t}(x_{i})\) based on the LCE method
3. \(\epsilon_{t}=\sum_{i=1}^{N}D_{t}(x_{i})\) [\(y_{i}\
eq h_{t}(x_{i})\)] % Calculate the error of \(h_{t}(x_{i})\)
4. If\(\epsilon_{t}>0.5\)then break
5. \(\alpha_{t}=\frac{1}{2}log\left[\frac{(1-\epsilon_{t})}{\epsilon_{t}}\right]\) % Determine the weight of \(h_{t}(x_{i})\)
6. \(D_{t+1}=\frac{D_{t}(x_{i})}{Z_{t}}\times \begin{cases}e^{-\alpha_{t}}&if\ y_{i}=h_{t}(x_{i})\\ e^{\alpha_{t}}&otherwise\end{cases} \) % Update the weight distribution for all samples
7. End Output: The proposed classifier \(H(x_{i})=sign(\sum_{t=1}^{T}\alpha_{t}h_{t}(x_{i}))\)
```  
**Algorithm 1**The pseudo code of the constructed classifier. Firstly, allocated an initial weight for each training sample, \(D_{1}(x_{i})=1/N\). Then, the first weak classifiers \(h_{1}(x_{i})\) from the training dataset using the weight \(D_{1}(x_{i})\) are trained. The training step searched for the most suitable classifier \(L_{t}(x_{i},p)\) and its corresponding parameter \(p\) that could minimize the misclassified error \(\varepsilon_{t}\) by using the _LCE_ method. The \(\varepsilon_{t}\) could be calculated by Equation (7):  
\[\varepsilon_{t}=\sum_{i=1}^{N}D_{t}(x_{i})\ [y_{i}\
eq h_{t}(x_{i})] \tag{7}\]  
where \(\varepsilon_{t}\) is the sum of weights of samples which were misclassified. \(y_{i}\) is the label value of the \(i\)th sample which had been set as 1 or \(-1\), \(D_{t}(x_{i})\) is the weight of the \(i\)th sample, and \(N\) is the total number of sample.