## 3 Methods
### Leaf Exactation based on Multi-feature and Improved Random Forest Classifier
#### 3.3.2 Proposed Image-Segmentation Model  
By using the operations detailed above, image segmentation was transformed into building a two-class model. This model contains two types of samples: Positive samples (containing leaf patches manually labeled from different varieties) and negative samples (containing background patches manually labeled from soil and stem). We next built a training dataset with 24,000 positive patches (ten patches for each image) and 19,200 negative patches (eight patches for each image). Each training patch contained \(20\times 20\) pixels to match the size of leaf, and the training patches were then represented in an M\(\times\)N matrix called the \"feature cube.\" In this cube, M is the number of pixels in the patch (M = 400) whereas N is the number of features (N = 22 in the axis). To summarize, we built a training with enough positive and negative samples, which satisfies the requirements of the ML sample size. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Feature Kind** & **Computational Formula** & **Implication** \\ \hline ASM & \(ASM=\sum_{i=1}^{k}\sum_{j=1}^{k}[G(i,j)]^{2}\) & Image gray distribution \\  & & uniformity and textural detail \\ ENT & \(ENT=-\sum_{i=1}^{k}\sum_{j=1}^{k}G(i,j)\log G(i,j)\) & Image gray distribution \\  & & heterogeneity or \\ CON & \(CON=\sum_{i=0}^{k-1}n^{2}\Big{[}\sum_{j=i}\)\(G(i,j)\Big{]}\) & complexity \\ COR & \(COR=\sum_{i=1}^{k}\sum_{j=1}^{k}\frac{(i)G(i,j)-u_{i}}{s_{j}}\) & Image clarity and texture depth \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Implication of texture features extracted from the gray-level co-occurrence matrix (GLCM). Types of features are angular second moment (ASM), entropy (ENT), contrast (CON), and correlation (COR). We then used the improved random forest classifier to classify the model training based on the above dataset. The conventional random forest methods are an ensemble of learning methods for classification (and regression), that constructs a multitude of decision trees at training time and outputs the class that is the mode of the classes output by individual trees. It is a classifier composed of decision trees. By using \(x\in X\) as sample data and \(t\in T\) as an independent decision tree, the predictive function \(h(x\big{|}t)\) can be expressed as  
\[\left\{ \begin{array}{c}\text{nonleaf node}:h(x|N(\psi,t_{l},t_{r}))=\left\{ \begin{array}{c}h(x\big{|}t_{l}),\psi(x)=0\\ h(x\big{|}t_{r}),\psi(x)=1\end{array}\right\}\\ \text{leaf node}:h(x\big{|}L(\pi))=\pi\end{array} \right\} \tag{5}\]  
where \(\psi(x)\) is the splitting function of each node in the decision tree, and \(\pi\) is the category information of a leaf. The voting model of a random forest \(F\) is  
\[y^{*}=\underset{y\in Y}{\text{argmax}}\sum_{t\in F}I(h(x\big{|}t)=y), \tag{6}\]  
where \(I\) is the indicator function, which can take on values in the range [0,1]. We define the function \(f(x,\theta_{i})\) as the \(i^{\text{th}}\) tree constructed by the random vector \(\theta_{i}\). The random forest can then be represented by \(F=\{f_{1},f_{2},\ldots,f_{T}\}\), where \(T\) is the scale of the forest. The margin function of the sample data \((x,y)\) is  
\[mg(x,y)=av_{T}I(f_{T}(x)=y)-\underset{j\
eq y}{\text{max}}av_{T}I(f_{T}(x)=j), \tag{7}\]  
where \(av_{T}\) represents the average function. The generalization error can then be expressed as  
\[GE=E_{(x,y)}(mg(x,y)<0). \tag{8}\]  
In Equation (8), the subscripts \(x\), \(y\) indicate that the probability runs over the \(x\), \(y\) space. The generalization error \(GE\) has an upper bound that is defined as  
\[GE*\leq\overline{\rho}\frac{1-s^{2}}{s^{2}}, \tag{9}\]  
where \(\overline{\rho}\) is the mean of the correlation and \(s\) is the strength of the set of classifiers. To reduce the correlation coefficient \(\overline{\rho}\) of the decision trees, and widen the information field of the optional new feature attribute, we should improve the randomness when building the decision trees. The improved random forest algorithm is described in Algorithm 1.