key: cord-0061043-liukp5tk authors: Chen, Yihao title: Identification of Tea Leaf Based on Histogram Equalization, Gray-Level Co-Occurrence Matrix and Support Vector Machine Algorithm date: 2020-06-08 journal: Multimedia Technology and Enhanced Learning DOI: 10.1007/978-3-030-51100-5_1 sha: 33a99070f0c7367b9404fc2d6c3e4afed6b0fb59 doc_id: 61043 cord_uid: liukp5tk To identify tea categories more automatically and efficiently, we proposed an improved tea identification system based on Histogram Equalization (HE), Gray-Level Co-Occurrence Matrix (GLCM) and Support Vector Machine (SVM) algorithm. In our previous project, 25 images per class might be not enough to classify, and a small size of dataset will cause overfitting. Therefore, we collected 10 kinds of typical processed Chinese tea, photographed 300 images each category by Canon EOS 80D camera, and regarded them as a first-hand dataset. The dataset was randomly divided into training set and testing set, which both contain 1500 images. And we applied data augmentation methods to augment the training set to a 9000-image training set. All the images were resized to 256 * 256 pixels as the input of feature extraction process. We enhanced the image features through Histogram Equalization (HE) and extracted features from each image which were trained through Gray-Level Co-Occurrence Matrix (GLCM). The results show that the average accuracy reached 94.64%. The proposed method is effective for tea identification process. Tea is a popular drink all over the world. There are a variety of functions and effects, such as promoting the absorption of iron in the body, helping to regulate cholesterol levels in the body, promoting metabolism, and even inhibiting the occurrence of cancer [1] . The record of the United Nations Food and Agriculture Organization and Wang' s researches on Chinese tea culture illustrate [2] that in China alone people grow, ferment and bake black tea, green tea, oolong tea, scented tea and other varieties of tea. The production process of tea is extremely complicated. Different production processes, time periods and fermentation levels will affect the properties of tea products. Moreover, there are many varieties of tea leaves, and even the tea products made with the same leaf through different processes have different characteristics, colors and fragrances [3] . Over the years, the computer processing and analysis of data more and more accurate and efficient, related algorithms are also improving. In the field of machine learning and artificial intelligence, image processing is one of the most studied topics, such as medical image analysis, biological image classification, etc. These advances are attributed to the formation of image analysis algorithm, the improvement of classifier and the development of convolutional neural network. The work of tea classification has been improved a lot, but they are based on different standards, original data types and algorithms, and the results are quite different. Since the appearance of processed tea leaves is quite different from that of fresh tea leaves, it can be further explored to use tea products as the research object. If the algorithm and results of this project can be applied to industrial production process or application development of mobile terminals, then this project might have a very good prospect. Previously, Wu, Chen (2009) [4] proposed a tea identification method using discrete cosine transform (DCT) and least squares-support vector machine (LS-SVM) based on multi-spectral digital image texture features. They used a multispectral digital imager to take images of different bands of tea leaves and combine them into a new image of one object. They trained the dataset with 80 filters and classified it with a classifier. Although the accuracy of this method can reach a considerable 100% due to the maturity of the filter and classifier design, it has the disadvantage that is requiring the use of additional scanning imagers. It means that the acquisition of data sets will cost too much. Similarly, Zhang and HE (2014) [5] designed a system for identifying green tea brands based on hyperspectral imaging techniques and the Gray-level Co-occurrence Matrix (GLCM) and LS-SVM classifier. In this system, the dataset and the algorithm are perfect, and the results are accurate. However, the collection of the data set still needs to be finished by peripheral devices. Zhao, Chen (2006) [6] used near-infrared spectroscopy to identify green tea, Oolong tea and black tea quickly. By collecting the different spectral features of each tea in the near-infrared spectroscopy, they used these features as input to the support vector machine (SVM) classifier. Their study was more than 90% accurate. All the above methods have achieved good recognition results, but they needed to collect data with additional equipment, which leads to the acquisition of data sets that require material and time. Therefore, we tried to use the image recognition technology to identify the common tea product image. The advantage of this approach is that it is simpler, more efficient and less costly without expensive equipment and cumbersome processes. For example, Borah, Hines (2007) [7] proposed an algorithm for image texture analysis based on wavelet transform. The technique directly processes the feature information of a group of images and then analyzes it. [8] created a system to identify green teas, Oolong teas and black teas based on wavelet packet entropy and fuzzy support vector machine. It was an efficient method and the accuracy was over 97%. Tang (2018) [9] experimented that tested Convolutional neural network provides us with an inspiration. In our previous study [10] , we used the Gray-Level Co-Occurrence Matrix (GLCM) model and k-nearest neighbors algorithm to extract features from images which were taken by ourselves. Moreover, we got a good result that showed the accuracy was over 86%. However, one of the disadvantages is that this project is not automatic enough because we just called in the classification function in MATLAB software to test the initial performance of GLCM on this set of images. In the previous study, since GLCM with fewer parameters and less operation can effectively extract features from images, we continued to use this model in this study. GLCM is a commonly used image processing technology, which can reflect the joint distribution between two pixel points with different spatial position relations [11] . In the feature extraction step, MATLAB was used to run GLCM algorithm to extract feature dataset, and the input images were digitized to obtain the feature matrix. Each of the characteristic values in these matrixes was a sorted input. After the training and testing of the classifier and the verification of the multi-fold cross-validation process, the accuracy of the test data set can be finally calculated. In this process, using GLCM algorithm to extract features was a key step. The aim of this study is to design a tea identification system based on traditional computer vision methods using our own dataset and to test the classification performance of a combination of Histogram Equalization (HE), Gray-Level Co-Occurrence Matrix (GLCM) and Support Vector Machine (SVM). In order to test the classification performance of our model, this study used the pictures of ten kinds of tea, which were, respectively, Anji White tea, Chrysanthemum Tea, Huangshanhoukui Green Tea, Jasmine Tea, Longjing Green Tea, Tawthron Black Tea, Tieguanyin, Xiangxin Black Tea, Yixing black tea and Zhengshanxiaozhong Black Tea, as the original data. For instance, there are three green teas which have similar features, such as leaf shape and color. However, there is a slight whitening change during the growth of white tea, and this feature still exists in the processed tea. In our previous study, the high-resolution tea pictures we photographed and collected by ourselves stored enough useful information, such as leaf texture feature, pixel value. Thus, we continued to use the similar set of pictures as the data set in this study. The categories of these teas are, respectively, Anji White tea, Chrysanthemum Tea, Huangshanhoukui Green Tea, Jasmine Tea, Longjing Green Tea, Tawthron Black Tea, Tieguanyin, Xiangxin Black Tea, Yixing black tea and Zhengshanxiaozhong Black Tea (10 categories tea). The tea leaves were photographed in two different shades of light, with half in the sun light and the other half in a warm LED light of 8 W. It was obvious to find that the tea images in these two environments were different, which are shown in Fig. 1 . To reduce the influence of the reflected light of the background, we placed all the tea leaves on dark background. Finally, 300 high-quality images were selected for each category of tea, and the images from different environments were selected randomly. The images we selected were approximately 4 MB in size and had a pixel value of about 4000 * 4000. These images contain enough tea information, such as color, leaf shape, texture, quantity, etc. Generally, image recognition only needs a small size to remain the program efficiency, so we resized these images to 256 * 256 pixels in batch through MATLAB software. In our last experiment, Although the program can be run in the previous experiment, the average accuracy is about 65% [10] . The insufficiently sized dataset may be a main reason for the low accuracy. Besides, overfitting might be caused by a small number of samples [12] . The raw data sets are divided into two parts randomly, which are used as training sets and test sets respectively. 1500 samples are in the training set, and rest of them are tested as the testing set. We used data augmentation technology to rotate, mirror, crop and other operations on the acquired images [13] . Since our data set was small before, we applied this technique to increase the training data set and make the data set diverse. Since the larger dataset can be show a better performance of classification, we augmented the training set from 1500 images to 9000 images. Some samples are shown in Fig. 2 : (i) is the raw image, (ii) is mirrored, (iii) is added zero-mean, Gaussian white noise with variance of 0.01, (iv) is enhanced contrast in a new range of intensity which is from 0.1 to 0.9, and (v), (vi) and (vii) are rotated 5 , 10 , 15 clockwise, respectively. These images were stored uniformly in a folder. (a) Anji white tea in the warm LED light. (b) Anji white tea in the sun light. To reduce the influence of different intensities of light and unify the overall grayscale of the images, we introduced the method of HE. It can enhance the local contrast without affecting the overall contrast to present details of images. The process of HE is as following: (1) The frequency of occurrence of each gray level of the histogram is counted and normalized to [0,1]. The probability of a pixel with a grayscale of i is where n represents the number of times a certain grayscale occurs, L represents gray level. (2) Accumulate normalization histogram: To summarize, the gray value is: where round() represents the returning the integral value that is nearest to the argument. M and N represent the number of pixels in length and width of the image. GLCM represents the correlation between different gray pixels in the image. Texture feature extraction [14] is divided into four parts: extraction of gray image, gray level quantization, calculation of eigenvalue, and generation of texture feature maps [14] . Compared with wavelet transform, GLCM can better describe spatial relations. By extracting the original three-channel image and then processing the gray level, we can obtain the required gray level image. This was useful for determining the grayscale value of each pixel in the image [15] . Suppose that f(x, y) presents a two-dimensional image, the size of which is M Â N. Then, relative frequencies in this image P(i, j) will satisfy the following condition: where #(x) presents the number of elements in the set. The adjacent relations between the gray values of different pixels, the features, can be extracted, and then stored in one matrix [16] [17] [18] [19] . The gray-level co-occurrence matrix can be obtained through this step. Through this process, we can represent larger color or gray images by images with smaller pixel features. If the gray value of pixels in the image are similar, the features in the matrix will be concentrated on the main diagonal. As shown in Fig. 3 , a window which is set as 1 Â 2 moves from the first two blocks to the end in horizontal direction, and the value of the step distance is 1. Many statistics can be used to describe texture features in GLCM, among which the more typical ones are contrast, correlation, energy and homogeneity. Contrast directly describes the brightness difference between pixels in an image. Mathematically, where G i; j ð Þ represents the relative frequencies, k represents the maximum number of pixels. Correlation indicates the similarity of features in horizontal and vertical directions. It can be calculated as, where The ASM (Angular second moment) energy reflects the stability of the grayscale change of the image texture. The higher the energy value is the more uniform the texture will be. Homogeneity describes the local stability of the image. Mathematically, In this project, we scanned the images in 0 , 45 , 90 , 135 respectively, so the feature map is a 4-channel matrix. It represents the preprocessed 256 * 256-pixels image as an 8 * 8 * 4-pixels image, and it is also an 8 * 8 * 4-matrix. Each number in the matrix represents the overall features and local features of the image. The four features mentioned above were also utilized. Different images of one same tea have similar texture characteristics, color and structure. Therefore, the feature matrix will have similar overall structure and specific feature values. In the future, we shall test other feature extraction methods, such as convolutional neural network [20] [21] [22] [23] [24] . Support vector machine (SVM) [25] is a popular learning model and classifier recently. The standard support vector machine mainly solves the binary classification problem, but after the algorithm improvement, the multi-classification problem can also be solved by it. We do not use deep learning methods [26] [27] [28] [29] [30] [31] or transfer learning methods [32] [33] [34] [35] since our dataset is small. The algorithm and steps of standard SVM can be used to construct multiple classification boundaries, so as to realize one-against-all multi-classification [36] . Although support vector machine cannot solve outliers and noise, the classic SVM is worth using because it can show a good performance in the small sample classifying experiments. In Wu, Chen (2009) [4] 's study, Least Squares-Support Vector Machine was applied well. In [8]'s research, they used fuzzy support vector machines and got good results. We suppose that there are a set of inputs called X ¼ X 1 ; X 2 ; . . .; X N f gand a goal called Y ¼ y 1 ; y 2 ; . . .; y N f g . Each item of data contains the feature space X i ¼ x 1 ; x 2 ; . . .; x N f gand the binary goal y ¼ À1; 1 f g. We suppose to regard the input feature space as a hyperplane of the decision boundary, and the goal set can be divided into positive and negative categories. The hyperplane can be represented as The point to the plane distance D can be represented as where x represents normal vector and b represents intercept to the hyperplane. In fact, the decision boundaries used to separate the samples were created. As shown in Fig. 4 , the positive class (Class B) corresponding to the boundary y i ¼ þ 1 is x T X i þ b ! þ 1. The negative class (Class A) corresponding to the boundary y i ¼ À1 is x T X i þ b À 1. We can deduce this method into multiple classification problems. Two interval boundaries are calculated for every two samples in the M groups of input samples, so that we can get [M * (M -1)]/2 boundaries totally. SVM has a good performance in both binary and multi-classification problems. The original Support vector machine (SVM) is designed for the binary classification projects. However, in our study we have 10 classes. One solution to multiclassification is to regards one class as the positive set and the rest of the classes are negative set and every class should be looped to train the model, which is one-versusrest (OVR). This system was developed via the Grayscale Processing Toolbox in MATLAB R2018b. The programs were run on the HP laptop with 2.30 GHz i5-8300H CPU, 8 GB RAM, and Windows 10 operating system. A set of raw images have been photographed by us via a digital camera with a 35-mm lens, which have 300 images in each class Inhibitory effect of green and black tea on tumor growth Tea and Chinese Culture Effect of drying methods on the aromatic character of Pu-erh Tea Application of multispectral image texture to discriminating tea categories based on DCT and LS-SVM Identification of green tea brand based on hyperspectra imaging technology Qualitative identification of tea categories by near infrared spectroscopy and support vector machine Wavelet transform based image texture analysis for size estimation applied to the sorting of tea granules Identification of green, Oolong and black teas in China via wavelet packet entropy and fuzzy support vector machine Twelve-layer deep convolutional neural network with stochastic pooling for tea category classification on GPU platform Tea leaves identification based on gray-level co-occurrence matrix and Knearest neighbors algorithm Novel method for color textures features extraction based on GLCM Neural network studies. 1. Comparison of overfitting and overtraining The calculation of posterior distributions by data augmentation Towards a new definition of areal surface texture parameters on freeform surface: Re-entrant features and functional parameters Texture descriptors for representing feature vectors A support-based reconstruction for SENSE MRI Segment-based coding of color images Pattern recognition via PCNN and tsallis entropy Improved image filter based on SPCNN Exploring a smart pathological brain detection method on pseudo Zernike moment Multiple sclerosis identification based on fractional Fourier entropy and a modified Jaya algorithm Preliminary study on angiosperm genus classification by weight decay and combination of most abundant color index with fractional Fourier entropy Pathological brain detection based on alexnet and transfer learning Preclinical diagnosis of magnetic resonance (MR) brain images via discrete wavelet packet transform with Tsallis entropy and generalized eigenvalue proximal support vector machine (GEPSVM) Partial least squares-least squares-support vector machine modeling of ATR-IR as a spectrophotometric method for detection and determination of iron in pharmaceutical formulations Image based fruit category classification by 13-layer deep convolutional neural network and data augmentation Teeth category classification via seven-layer deep convolutional neural network with max pooling and global average pooling Cerebral micro-bleeding detection based on densely connected neural network Five-category classification of pathological brain images based on deep stacked sparse autoencoder Cerebral micro-bleeding identification based on a nine-layer convolutional neural network with stochastic pooling Alcoholism identification via convolutional neural network based on parametric ReLU, dropout, and batch normalization Alcoholism identification based on an AlexNet transfer learning model. Front Detecting cerebral microbleeds with transfer learning Classification of Alzheimer's disease via eight-layer convolutional neural network with batch normalization and dropout techniques High performance multiple sclerosis classification by data augmentation and AlexNet transfer learning model A comparison of methods for multiclass support vector machines An empirical study of the naive Bayes classifier A survey of decision tree classifier methodology Classification and regression by randomForest