# Plant-Leaf Recognition Based on Sample Standardization and Transfer Learning
## 2 Materials and Methods  
### Minimum Enclosing Quadrate Treatment of Leaf Samples  
In the classification and recognition of plants, the shape and texture features of leaves are particularly important. However, asymmetric compression operations are often detrimental to maintaining the normativity of these features. As shown in Figure 1, the original sample image is shown on the left, and the compressed image of this sample is shown on the right. In the process of compression, its size is changed from 2544 \(\times\) 1205 to 224 \(\times\) 224. It can be clearly seen that the basic characteristics of the leaves have been greatly changed. Obviously, this phenomenon is not conducive to the classification and recognition of the CNN models. It can also be seen that there is a lot of redundant information in the original sample, which will also affect the classification accuracy of the models. Figure 1: Comparison of a leaf-sample image before and after compression. In order to avoid the influence of the abovementioned problems on the classification results, the MEQ method is proposed to standardize the leaf-sample datasets. Firstly, the RGB image of the leaf sample is converted into a grayscale image by eliminating the hue and saturation information while maintaining the brightness. In this process, RGB values are converted to gray values by calculating the weighted sum of \(R\), \(G\), and \(B\) components. The calculation method is given in Equation (1). \[Gray=0.299\times R+0.587\times G+0.114\times B \tag{1}\]  
where \(Gray\) represents the transformed gray value; and \(R\), \(G\), and \(B\) separately represent the red, green, and blue components. Secondly, the gray image is converted into a binary image to show the leaf contour more clearly. Before that, the Otsu [18] method is used to calculate the global threshold of the grayscale image. Otsu is an algorithm to determine the threshold of image binarization segmentation, and Otsu is used in this experiment to select the optimal threshold that minimizes the within-class variance of the thresholded black-and-white pixels. The principle of finding the best threshold, \(m^{*}\), is as follows. Let the gray level of a given image be denoted by \(N\), and there exists a threshold, \(m\), to classify the pixels in the image into 2 classes: class \(D_{1}\) and class \(D_{2}\). The pixels of class \(D_{1}\) have gray levels of \((1,\ldots,m)\), and the gray level of class \(D_{2}\) pixels is \((m+1,\ldots,N)\). The within-class variance, \(\sigma_{w}^{2}\), and between-class variance, \(\sigma_{B}^{2}\), are expressed as follows:  
\[\sigma_{W}^{2}=\omega_{1}\sigma_{1}^{2}+\omega_{2}\sigma_{2}^{2}, \tag{2}\]  
\[\sigma_{B}^{2}=\omega_{1}(\mu_{1}-\mu)^{2}+\omega_{2}(\mu_{2}-\mu)^{2} \tag{3}\]  
\[=\omega_{1}\omega_{2}(\mu_{2}-\mu_{1})^{2}.\]  
where \(\omega_{1}\) and \(\omega_{2}\) are the probabilities of occurrence of class \(D_{1}\) and \(D_{2}\), respectively; \(\sigma_{1}\) denotes the variance of class \(D_{1}\); and \(\sigma_{2}\) denotes the variance of class \(D_{2}\). In addition, \(\mu_{1}\) and \(\mu_{2}\), respectively, represent the average gray values of the two categories, and \(\mu\) represents the total average level of the grayscale image. Since \(\sigma_{W}^{2}+\sigma_{B}^{2}=\sigma^{2}\) is always true (where \(\sigma^{2}\) is the total variance), the sum of the within-class variance and the between-class variance is fixed, which means that the maximum between-class variance is the minimum within-class variance.