Nectarine Disease Detection based on Color Features and Label Sparse Dictionary Learning with Hyperspectral Images

: Fruit cracking and rust spot are common diseases of nectarine which would seriously affect its yield and quality. Therefore, it is essential to construct disease detection models for agricultural products with high speed and accuracy. In this paper, a sparse dictionary learning method was proposed to realize the rapid and nondestructive detection of nectarine disease based on the multiple color features combined with the improved K-SVD (K-Singular Value Decomposition). According to the color characteristics of nectarine itself and the significant color differences existing in the three categories of nectarine (diseased, normal and background parts), multiple color spaces of RGB, HSV, Lab and YCbCr were studied. It was concluded that the G channel in RGB space, Y channel in YCbCr space and L channel in Lab space can better distinguish the diseased part from the other parts. At the model training stage, pixels of the diseased, normal and background parts in the nectarine image were randomly selected as the initial training sets, then the neighborhood image block of the pixels were selected to construct the feature vectors based on the above color space channels. An improved LK-SVD (Label K-SVD) dictionary learning algorithm was proposed that integrating the category label into the process of dictionary learning, then an over-complete feature dictionary with significant discrimination was obtained. At the model testing stage, orthogonal matching pursuit (OMP) algorithm was used to sparse reconstruction the original data which can obtain the classification categories based on the optimized feature dictionary. Experimental results show that the sparse dictionary learning method based on multi-color features combined with improved LK-SVD can detect fruit cracking and rust spot diseases of nectarine quickly and accurately, and the average overall classification accuracies were 92.06% and 88.98% respectively, which was better than k-nearest neighbor (KNN) and support vector machine (SVM). It is demonstrated that this study can provide technical support for the diseases


Introduction
With high nutritional value, nectarine contains a variety of amino acids essential for human body.At the same time, it can enhance immunity which has high medicinal value.Hence, using hyperspectral imaging technology to realize the nondestructive detection for nectarine is a pivotal step in the process of nectarine industrialization [1] .In the process of picking, preservation and storage of nectarine, it is vulnerable to pests, diseases and microbial pollution, which would lead to a great decline in product quality.Therefore, disease detection for nectarine is of great significance to improve its quality and market competitiveness [2] .
Recently, as an efficient nondestructive detection tool, hyperspectral imaging has been widely used in quality analysis for agricultural products [3][4] .At present, several researches on internal and external nondestructive detection for nectarine have been conducted.Various dimensionality reduction methods [5] have been used to extract the feature vectors from the dielectric spectrum and near infrared spectrum, which can systematically reflect the advantages and disadvantages of the two spectrums in quality detection for nectarine.Hyperspectral image technology [6] combined with CARS-ELM (Competitive adaptive reweighted Sampling, CARS; Extreme learning machine, ELM) have been successfully applied to realize the variety identification for nectarine, which provides technical basis for nondestructive detection for fruit internal detection.
Nevertheless, most of the above studies aim at the detection of internal quality and variety identification for nectarine, and researches on disease detection are still in the theoretical analysis phase [7] , let alone the detection based on hyperspectral image technology.Since disease detection based on hyperspectral image belongs to the field of pattern recognition, and sparse representation combined with dictionary learning algorithm have been widely used in face recognition, image classification and other fields [8][9] , then how to effectively apply the sparse representation and dictionary learning methods to detect the diseased area is the focus of our study.
The objective of this work was to develop a method for detecting different nectarine diseases rapidly and nondestructively.
Nectarine with fruit cracking and rust spot of "Zhongyou NO.9" were taken as study objects, and then the visible hyperspectral images of the two diseases were collected by the hyperspectral imaging system.Firstly, aiming at the problems of high dimension and linear inseparable for hyperspectral image data, recognition model for nectarine common diseases based on dictionary learning and sparse representation was studied.Secondly, as feature extraction is the most important and difficult part in pattern recognition [10] , moreover, there were significant color differences among the diseased, normal and background parts.According to the influence of different color features on the recognition results we can get an optimal feature vector so as to enhance the reliability and robustness of the model.Finally, in the process of dictionary learning, as the recognition area included three categories: diseased, normal and background, an improved K-SVD algorithm was proposed that integrating the category label into the dictionary learning process, then a discriminant over-complete feature dictionary was obtained for sparse reconstruction the original data to obtain the classification categories.This study will provide a basis for nondestructive detection and on-line identification for nectarine and other agricultural products.
The paper is organized in the following manner: Section 2 presents the methodology, which includes the description of the improved LK-SVD sparse dictionary learning method and the implementation of our algorithm, Section 4 provides the experimental results.The conclusion is drawn in Section 5.

Data collection
The experimental nectarine was purchased from Yuncheng orchard of Shanxi Province.The samples were similar in shape and uniform in maturity and size.The HyperSIS (USA) hyperspectral image acquisition system used in this experiment was mainly composed of CMOS camera, Spectrograph, electronically controlled displacement platform of array detector, computer and darkroom, etc., as shown in figure 1.The spectral range was 874-1734nm, the resolution was 2.8nm, and the sampling interval was 0.59nm.The light was a 150W quartz halogen lamp.A total of 56 hyperspectral sample images were collected by the imaging system.The image size was 320×349, and each has 256 bands.After normalization, 60 images with fruit cracking and 65 images with rust spot were acquired respectively, and the image size was 256×256.The visible sample image of nectarine is shown in figure 2, which is a pseudo-color image synthesized by multiple bands.were obvious color differences among the diseased, normal and background parts.Therefore, this paper analyzed multiple color spaces of RGB, HSV, YCbCr and Lab [11] for feature extraction.It can be seen from figure 3, since HSV color space is composed of hue, saturation and lightness [12] , none of its channels can be used to detect the diseased part; The G channel in RGB (Figure 3b), Y channel in YCbCr (Figure 3g) and L channel in Lab (Figure 3j) can better distinguish the diseased part from the rest parts; As for the rest channels, the diseased part were similar to the normal one in color, and the boundaries were blurred, which cannot be used for identification.Therefore, the G channel in RGB, Y channel in YCbCr, and L channel in Lab were selected for color feature extraction.In general, color features were pixel-level and the feature dimension of each channel was 256×256, thus feature dimensionality reduction was necessary.Because moments can describe the image features, in which low-order moments can reflect the low-frequency (main) information, and high-order moments can reflect the high-frequency (detail) information [13] .Therefore, this paper intended to extract the first, second and third moments of the above-mentioned color channels as feature vectors for subsequent analysis.Then the feature vector "Clolor_features" was defined as RGB_G_FM，YCbCr_Y_FM，Lab_L_FM，RGB_G_SM， YCbCr_Y_SM，Lab_L_SM，RGB_G_TM，YCbCr_Y_TM，Lab_L_TM which contains 9 components.
2.3 Improved LK-SVD sparse dictionary learning method

Sparse dictionary learning
The main idea of dictionary learning is to use the dictionary matrix to linearly sparse represent the original samples [14]   , as shown below: where represents the original samples, m and n are the dimension and number of the samples respectively, k is the number of dictionary atoms, the essence is to find a X making D as sparse as possible.
Generally, sparse representation mainly includes two parts: sparse coding and dictionary updating [15] .In this paper, OMP [16] was used to sparse decompose the input information and calculate the reconstruction error; the improved LK-SVD algorithm was used to construct and update the dictionary.

Improved LK-SVD dictionary learning
The initial dictionary is not usually the optimal, and there will be large error between the data represented by sparse matrix that meets the sparseness with the original data.K-SVD algorithm takes the principle of minimum error as the basic idea [17] to update the dictionary, and its objective equation is given below: Where 0 T represents the upper limit of non-zero sparse coefficient.
The K-SVD algorithm can effectively reduce the within-class deviation, but its learning process is only for a certain category, and cannot increase the between-classes variance for multi-class problems.Therefore, a LK-SVD algorithm based on category label was proposed, which integrated the category information to modify the K-SVD.This paper was a three-category classification issue: diseased, nectarine and background parts.For this, sparse reconstruction mainly judges the type of test samples by solving the position where the minimum value of residual appears in the sparse expression.Thus the above problems can be replaced by a linear classifier, and then the classification can be expressed as ( 3): Where [0,1, 2] H  represents three categories; W represents the linear classification matrix; b is the bias term.
Integrating it into the process of dictionary learning, and the optimization of solving W can be converted to (4): Combined with formula (2), the above formula can be converted to (5)： Where 2 F W is the regular term;  and  are the contribution value of the corresponding term respectively.A dictionary can be considered as a combination of the primitive atoms Y , thus it can be expressed as D Y    ，in which  is the transformation matrix, then the above formula can be simplified as ( 6): By solving the above problems, the obtained H is the measured category.

Algorithm implementation process
Nectarine disease identification based on sparse dictionary learning was a method of unsupervised learning.Figure 4 shows The training process of nectarine diseases mainly included four processes: feature point extraction, feature vector construction, feature dictionary initialization and dictionary learning.(3) Feature dictionary initialization: Generally, certain columns of the initial sample were selected as the initial feature dictionary.In this paper, K features of each category in (2) were randomly selected as the initial dictionary.By generating the transformation matrix between the dictionary and the initial sample randomly, the initial feature dictionary D was constructed, and its dimension was 9 3K  .
(4) Dictionary learning: It was generally considered that there was a linear classification relationship between features and categories, so a linear classification model can be constructed by the category label H with the feature dictionary D .Here, the over-complete dictionary was obtained by the KL-SVD algorithm iteratively.

Model testing process
The testing process of nectarine diseases mainly included four processes: feature point extraction, feature vector construction, sparse representation and sparse reconstruction.(4) Sparse reconstruction: Inputting the sparse expression obtained in (3) into the linear classification model, the test category can be obtained.

Model evaluation
In this paper, the confusion matrix, overall accuracy of classification, user accuracy, producer accuracy and kappa coefficient were used to evaluate the classification results.Confusion matrix is mainly used to compare the classification results with the actual measured values [18].Here, r is category, ij X represents the percentage of category i judged as the category j by the classifier in the total number of category i ; ii X is the number of pixels in row i and column i in the confusion matrix ( the number of correct classifications);  i X and i X  are the total number of pixels in row i and column i respectively; N is the total pixels.Overall classification accuracy [19] (OA) is equal to the sum of correctly classified pixels divided by the total pixels, as shown in formula (7): User accuracy [20] (UA) indicates the probability that a certain type of sample is correctly classified, as shown in formula (8): Producer accuracy [21] (PA) represents the probability that a certain type of sample in the classification diagram is correctly classified, as shown in formula (9): Kappa coefficient [22] can make full use of the information of confusion matrix.It can be used as a comprehensive index for the evaluation of classification accuracy.Table 1 shows the relationship between classification quality and kappa statistics, and the calculation formula of kappa coefficient is (10): (3) The initial dimension of feature vector was 9; (4) The initial dictionary size was 300, 100 features of each category were randomly selected as the initial dictionary.

Disease recognition results
Figure 5 shows the recognition results of nectarine disease.Figure 5(c) shows the recognition result of fruit cracking with feature vector dimension of 9, table 2 and table 3 show the corresponding confusion matrix results which are respectively expressed in numerical form and percentage form.As can be seen from table 2, the sum of rows is the total number of other categories classified into this category, the sum of columns is the total number of true values for each category, and the diagonal elements are the correct number of each category.By calculating the sum of diagonal elements, it can be concluded that the correct number of all the categories is 61910, and then the OA is 94.47%.Table 3 shows the percentages of correct and incorrect classifications for each category, it can be seen that the classification accuracies of diseased, normal, and background are relatively high which can achieve more than 91%, and the classification accuracy of background is the highest of 98.10%, proving that this method has a better effect.The UA and PA of each category can also be calculated by the confusion matrix, table 4 shows the UA and PA corresponding to figure 5(c).It can be seen that the UA and PA of background and normal pats are both higher, which can reach over 91%; the UA of the diseased part is the lowest of 55.34%, this is mainly because that the border between the nectarine and the background is blurred with shadows, and it is easy to be confused with the diseased part, therefore, most of the edge of the nectarine part and a few background part are identified as the diseased.In order to verify the influence of the dimension of feature vector, the number of feature points extracted, and the size of the neighborhood image block on the classification results, comparative analysis were conducted to obtain the optimal parameters.In this paper, three features with the first moment, six features with the first and second moments and nine feature vectors with the first, second and third moments were constructed respectively.The feature points of 1500, 2400 and 3000 were respectively selected; the neighborhood image block sizes of 3  3、5  5 and 7  7 were respectively selected.Figure 5 shows the results of disease recognition with different feature vector dimensions, and table 5 is the statistical results of different testing parameters.As can be seen from figure 5, the classification results of figure 5  In order to verify the influence of dictionary size on the classification results, this paper compared results of different dictionary size, as shown in table 6. Figure 7 is a line chart of the average OA of different dictionary size.It can be seen from table 6 and figure 7, the average OA of fruit cracking disease is higher than that of rust spot, the effect of dictionary size on fruit cracking is obvious than that of rust spot.When the dictionary size of fruit cracking disease is 1350, the average OA and kappa coefficient are both the highest, respectively of 92.06% and 0.92%.When the dictionary size of rust spot disease is 450, the average OA is the highest of 88.98%.With the size of the dictionary increasing, the average OA and kappa coefficient of rust spot disease changes smoothly.Table 7 is the Classification results compared with SVM and KNN, in which the kernel function of SVM is Gaussian kernel, and the optimal value of penalty parameter and γ were obtained by network searching algorithm and 10-fold cross validation method, which were 32 and 0.005.Compared with the other methods, the identification results of fruit cracking and rust spot disease are the highest, which are 92.06% and 88.98% respectively.The experimental results show that the method proposed in this paper can effectively identify the disease nectarine images, and that the reconstructed image of fruit cracking is better than rust spot disease.Combined with the color characteristics of nectarine itself and the disease parts, a feature vector construction method based on multi-color space was proposed.At the same time, the statistical characteristics of image blocks were fully considered in the process of feature dimension reduction, and it was concluded that the 6 feature vector dimensions with first and second moments, the image block size of 7  7 were the optimal feature parameters, which lays a foundation for the subsequent experiments.
2) An improved LK-SVD algorithm was proposed to integrate the category labels of the diseased, normal and background parts into the process of dictionary learning so as to obtain an over-complete dictionary.The experimental results show that: when the dictionary size is 1350 for the cracking fruit disease, the recognition results is the best, and the average OA and Kappa coefficient are 92.06% and 0.92 respectively; For the rust spot disease, when the dictionary size is 450, the recognition results is the best, and the average OA and Kappa coefficient are 88.98% and 0.87, respectively.
3) The experimental results show that when the feature vector dimension is 6 and the image block size is 7  7, the sparse reconstruction of the original nectarine fruit cracking and rust spot disease using OMP is the best, and the average OA and kappa coefficient are higher than SVM and KNN, which indicates that the method proposed in this paper can effectively identify the disease of nectarine, and the reconstructed image of fruit cracking is better than that of rust spot.

1 .
Fig.1 Hyperspectral image acquisition system Figure 3 shows the results of different color spaces with fruit cracking.(a) R channel of RGB color space (b) G channel of RGB color space (c) B channel of RGB color space (d) H channel of HSV color space (e) S channel of HSV color space (f) V channel of HSV color space (g) Y channel of YCbCr color space (h) Cb channel of YCbCr color space (i) Cr channel of YCbCr color space (j) L channel of Lab color space (k) a channel of Lab color space (l) b channel of Lab color space

Fig. 3
Fig.3 Different color space images of fruit cracking

Fig. 4
Fig.4 Flow chart of nectarine disease identification based on label sparse dictionary learning 2.4.1 Model training process

( 1 ) 2 )
Feature point extraction: N feature points were respectively selected from the diseased, normal, and background areas as the initial training sets, then the initial dimension of the training sets were 3N .For each pixel, the M M  neighborhood image block was extracted for recognition, then the size of the training sets were 3 Feature vector construction: the data of G channel in RGB, Y channel in YCbCr and L channel in Lab of each image block were extracted respectively.Then the first, second and third moment features of each channel were extracted.Finally, the dimension of the feature vectors were 9 3N  .

( 1 ) 2 ) 3 )
Feature point extraction: Referring to 1.4.1(1),all the pixels of the disease image were extracted, then the size of the Feature vector construction: The construction process was as 1.4.1(2),then the dimension of the feature vectors were Sparse representation: The sparse representation matrix was obtained by adopting the OMP algorithm using the over-complete dictionary obtained in 1.4.1(3) and the feature vectors in(2).
Fig.5 Classification results of nectarine with different feature vector dimensions

Fig. 7
Fig.7 Average OA of different dictionary size 3.4 Identification results of different methods

Table . 1
Classification quality and kappa statistics

Table . 2
Confusion matrix of classification results for 9 feature vectors (numerical)

Table . 3
Confusion matrix of classification results for 9 feature vectors (Percentage)

Table . 4
UA and PA of classification prediction results for 9 feature vectors

Table . 5
Statistical results of different parameters

Table . 7
Classification results of different methods