Exocarpium citri grandis year identification method based on hyperspectral imaging and machine learning model
Through hyperspectral imaging and machine learning models, the accurate identification of the year of Huajuhong is achieved, which solves the problem of identifying the age of Huajuhong in the existing technology, provides a fast, accurate and non-destructive detection method, and ensures the authenticity and authenticity of Huajuhong products. Quality control.
Patent Information
- Application Number
- CN202410743547.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-11
- Publication Date
- 2024-09-10
Smart Images

Figure CN118629030A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of food detection and relates to a method for identifying the age of tangerine peel, and specifically relates to a method for identifying the age of tangerine peel based on hyperspectral imaging and machine learning models. Background Art
[0002] Huajuhong, also known as Huazhou tangerine peel, is a specialty of Huazhou City, Maoming City, Guangdong Province, and is a Chinese national geographical indication product. It is made from the immature or nearly mature dried outer peel of the Rutaceae plant Huazhou pomelo or pomelo. "Compendium of Materia Medica" records that tangerine peel has the effects of resolving phlegm and relieving cough, and wind-cold cough, and has significant therapeutic effects on cold cough or dry cough. In addition, it can also be used for symptoms such as spleen and stomach qi stagnation, abdominal distension, loss of appetite, indigestion, dryness and phlegm, nausea and vomiting, and heaviness of limbs. Similar to tangerine peel and post-fermented tea, Huajuhong is also believed to be "the older the better".
[0003] However, there are few studies on the identification of the age of Huajuhong, and it is difficult to identify the exact age of Huajuhong on the market with the naked eye. This is not conducive to protecting the interests of consumers and the interests of farmers who grow excellent varieties. Therefore, conducting research on the age quality of Huajuhong is of great significance to understand the authenticity of Huajuhong sold on the market, so as to provide consumers with authentic Huajuhong products.
[0004] The prior art (Xiong Xiaoxiao. Analysis of effective components and year identification of Huajuhong [D], Huazhong Agricultural University, 2012) discloses that the composition and content of the main effective components of Huajuhong of different storage years are different. The sensory evaluation of Huajuhong of different storage years is carried out by fuzzy mathematics method, and the electronic tongue and electronic nose technology are used to perform principal component analysis (PCA) and discriminant factor analysis (DFA), which can better identify the year of Huajuhong.
[0005] The prior art CN 117233298A discloses a method for identifying the year of Huazhou tangerine peel based on metabolomics. The tangerine peel is ground into powder and its chemical composition is analyzed. Based on non-targeted metabolomics, orthogonal partial least squares discriminant analysis (OPLS-DA) is used to analyze the metabolite data of Huazhou tangerine peel samples of different years. The process is relatively cumbersome.
[0006] In the prior art (Xie Baiheng et al. Hyperspectral combined with Harris Hawk optimized kernel extreme learning machine to identify the age of Huajuhong embryo slices [J]. Spectroscopy and Spectral Analysis, 2024, 44(05)), it is disclosed that Huajuhong embryo slices are used as the research object, and the sample data are directly collected by using hyperspectral imaging technology (spectral range 400-1000nm). The performance of the KELM model established by the reflectance spectrum data obtained without preprocessing, Savitzky-Golay smoothing, multivariate scattering correction (MSC), and standard normal variable exchange (SNV) is compared. The modeling effects of full-band, competitive adaptive reweighting algorithm (CARS) and Monte Carlo non-information variable elimination (MCUVE) for screening characteristic bands are compared, and the Harris Hawk optimized kernel extreme learning machine (HHO-KELM) model is further established to improve the discrimination accuracy of KELM and provide a rapid detection method for the identification of the age of Huajuhong embryos.
[0007] None of the above technologies discloses the method for identifying the age of Huajuhong based on hyperspectral imaging and machine learning models. Summary of the invention
[0008] The present invention aims to solve the problems in the prior art and provides a method for identifying the year of Huajuhong based on hyperspectral imaging and machine learning models. The method has simple operation steps and can accurately identify the year of Huajuhong.
[0009] To achieve the above purpose, the technical solution adopted by the present invention is as follows:
[0010] The present invention provides a method for identifying the age of tangerine peel based on hyperspectral imaging and machine learning model, characterized in that it comprises the following steps:
[0011] Step 1) Data collection: Take slice samples of tangerine peel from different years and collect hyperspectral image data of two sections of the slice samples;
[0012] Step 2) Data preprocessing: ROI region selection is performed on the hyperspectral image data, the hyperspectral curve of the ROI region is extracted, and feature dimension reduction is performed to obtain a preprocessed hyperspectral curve;
[0013] Step 3) Establishing a classification model: using the preprocessed hyperspectral curve as an input variable of the discriminant model, training a machine learning multi-classifier, and evaluating the machine learning results to obtain the optimal year classification model of the Huajuhong slices, that is, the year classification model of the Huajuhong slices;
[0014] Step 4) The year of tangerine peel is calculated by the year classification model of tangerine peel slices.
[0015] The hyperspectral image data includes: sample year, spectral band and spectral reflectance. Preferably, the hyperspectral image data also includes a sample number. Preferably, the spectral band is a 930-1700nm short-wave near-infrared spectral band.
[0016] In the step 1), data collection is performed in a dark box, using a halogen tungsten lamp as a light source, the spectral resolution of the hyperspectral camera is higher than 3 nm, the spatial resolution is ≥333×320, and the hyperspectral image data of two sections of the tangerine peel slice are collected using an orthophoto method.
[0017] Preferably, the collected hyperspectral image data is subjected to correction processing and denoising processing in sequence to obtain hyperspectral data. The correction processing includes: performing correction processing using the following formula:
[0018]
[0019] Among them, I(i,j) is the spectral reflectance of the (i,j) pixel in the hyperspectral image at a certain wavelength after correction, and R raw (i, j) is the original grayscale value of (i, j) in the corresponding hyperspectral image; R black (i, j) is the gray value of the dark noise corresponding to (i, j) in the hyperspectral image; R white (i, j) is the grayscale value of the standard plate in the hyperspectral image corresponding to (i, j).
[0020] The denoising process includes: using the SG smoothing algorithm to perform denoising on the corrected hyperspectral image data.
[0021] In the step 2), ROI region selection is performed on the hyperspectral image data to extract the hyperspectral curve of the ROI region. The ROI region selection is specifically as follows: a hyperspectral image with a spectral band of 930-1700nm, preferably a 1040nm hyperspectral image, is used to perform threshold segmentation using the Otsu threshold method to obtain a ROI region mask, and then the mask is used to segment the ROI region in each spectral image in the same spectral cube.
[0022] Then extract the hyperspectral curve of the ROI area, specifically: take the average spectral reflectance of the ROI area of the two sections of the sliced sample as the feature of the sliced sample, and obtain the average spectral reflectance curve, which is the hyperspectral curve of the ROI area. The peak value of the hyperspectral curve of the extracted ROI area is ≥45000, and the difference in grayscale values of adjacent bands is ≤210. If the peak value of the hyperspectral curve of the extracted ROI area is <45000, or the difference in grayscale values of adjacent bands of the hyperspectral curve of the extracted ROI area is >210, the data collection is unqualified and the sample hyperspectral image data needs to be recollected.
[0023] Finally, the hyperspectral curve in the ROI area is subjected to feature dimensionality reduction, and the feature dimensionality reduction is performed using the PCA algorithm, specifically: the year of the training set samples is assigned a category; the extracted hyperspectral data is standardized: the PCA algorithm is used, and the hyperspectral image data obtained in step 1) is used as the input variable of the PCA algorithm to perform feature dimensionality reduction to obtain the preprocessed hyperspectral curve.
[0024] In the analysis of hyperspectral images, the rich spectral information may lead to information overload and waste of computing resources. Therefore, after collecting hyperspectral image data, selecting the region of interest (ROI) becomes a key step. The selection of ROI is to remove non-important areas in the image, reduce the impact of noise, and ensure that the analysis results are more accurate and reliable. By selecting ROI, the analysis can be focused on a specific area, improve the pertinence of the analysis, and reduce the amount of data processed, thereby improving processing efficiency.
[0025] The step 3) uses the pre-treated hyperspectral curve as the input variable of the discriminant model to train a machine learning multi-classifier, and the multi-classifier is preferably OutputCodeClassifier, OneVsOneClassifier or OneVsRestClassifier, and more preferably OutputCodeClassifier. The multi-classifier uses LogisticRegression, Support Vector Machines, Random Forest or Gradient Boosting algorithm for machine learning. The machine learning result is evaluated, and the evaluation is evaluated by one or more standards including accuracy, confusion matrix, precision, recall rate, and F1 score, preferably using precision to evaluate, so as to obtain the optimal classification model of the sample year of the tangerine peel slices, that is, the year classification model of the tangerine peel slices, preferably, the OutputCodeClassifier multi-classifier is the year classification model of the tangerine peel slices.
[0026] In the step 4), the year of Huajuhong is calculated by the year classification model of Huajuhong slices.
[0027] Compared with the prior art, the present invention has the following beneficial effects:
[0028] The method for identifying the year of Huajuhong based on hyperspectral imaging and machine learning model provided by the present invention uses a hyperspectral camera to respectively collect hyperspectral image data of two sections of Huajuhong slices, performs ROI region selection on the hyperspectral image data, and then extracts the hyperspectral curve of the ROI region. The spectral feature dimension reduction is performed on the hyperspectral curve by taking the average spectral curve reflectance of the two sections of the slice sample as the feature of the slice sample. The pre-processed hyperspectral curve is used as the input variable of the discriminant model, the machine learning multi-classifier is trained, and the classification accuracy is evaluated, and finally the year classification model of Huajuhong slices is obtained to achieve year identification.
[0029] The invention has simple operation steps and can quickly and accurately identify the year of Huajuhong.
[0030] Compared with the traditional method of grinding the drug into powder to analyze its chemical composition, the slicing operation used in the present invention belongs to non-destructive testing. The non-destructive testing mode can retain the original form and structure of the drug through the slicing operation, and will not damage or change the physical properties and shape of the drug. This is very important for the quality control and characterization of drugs, because the form and structure of the drug are closely related to its performance and efficacy. The slicing operation in the non-destructive testing mode can maintain the uniformity of the distribution of the internal components of the drug and ensure the representativeness of the drug sample. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 A flow chart of a method for identifying the age of tangerine peel based on hyperspectral imaging and machine learning models provided in an embodiment of the present invention;
[0032] Figure 2 This is a short-wave (930-1700nm band) near-infrared hyperspectral image of a cut surface of a Huajuhong sample (2011 vintage) after reflectance calibration;
[0033] Figure 3 For the corresponding Figure 2 Short-wave (930-1700nm band) near-infrared hyperspectral image of the other side of the cross section of the Huajuhong sample;
[0034] Figure 4 To use 1040nm image, Figure 2 The medium and high spectral images were threshold segmented using the Otsu threshold method, and the ROI area mask was obtained;
[0035] Figure 5 The spectral reflectance curve is drawn from the average value of the spectral reflectance data of the short-wave near-infrared image in the 930-1700nm band after calibration of the spectral reflectance data of samples from different years;
[0036] Figure 6It is a curve graph showing the accuracy of the OutputCodeClassifier (LinearSVC (random_state = 0), code_size = 30, random_state = 0) classifier on the short-wave (930-1700nm band) near-infrared test set as a function of the dimension of PCA dimensionality reduction;
[0037] Figure 7 This is the confusion matrix obtained by the OutputCodeClassifier(LinearSVC(random_state=0),code_size=30,random_state=0) classifier classifying the shortwave (930-1700nm band) near infrared test set. DETAILED DESCRIPTION
[0038] It is worth noting that, unless otherwise specified, the raw materials used in the present invention are all common commercially available products, and their sources are not specifically limited.
[0039] Example 1
[0040] The identification method of Huajuhong year based on hyperspectral imaging and machine learning model is as follows: Figure 1 shown.
[0041] The specific steps for identifying the year of Huajuhong are as follows:
[0042] Step 1), data acquisition: slice the samples of Citrus aurantium, and the sample years in the sample set are 2011, 2013, 2016, 2019, 2021, and 2022. Collect hyperspectral image data of two sections of the sliced samples, and the hyperspectral image data include: sample number, sample year, spectral band, and spectral reflectance. The shooting operation is carried out in a dark box with a halogen tungsten lamp as the light source. The spectral resolution of the hyperspectral camera is higher than 3nm, and the spatial resolution is ≥333×320. Its spectral range is 930-1700nm, and the spectral resolution is 3.2nm@500nm, containing 256 bands. The orthographic method is used to collect hyperspectral image data of two sections of Citrus aurantium slices, and the hyperspectral image data include: sample number, year information, band data, and spectral reflectance value. The obtained hyperspectral image data is subsequently processed. First, the hyperspectral image data of the samples in the sample set are corrected:
[0043]
[0044] Among them, I(i,j) is the spectral reflectance of the (i,j) pixel in the hyperspectral image at a certain wavelength after correction, and R raw (i, j) is the original grayscale value of (i, j) in the corresponding hyperspectral image; R black(i, j) is the gray value of the dark noise corresponding to (i, j) in the hyperspectral image; R white (i, j) is the grayscale value of the standard plate in the hyperspectral image corresponding to (i, j).
[0045] The calibrated hyperspectral image data is obtained. As an example: the spectral reflectance data of two sections of the Huajuhong sample (2011) are calibrated to produce short-wave near-infrared images in the 930-1700nm band. Figure 2 and 3 shown.
[0046] The calibrated hyperspectral image data is denoised using the SG smoothing algorithm to obtain the hyperspectral image data.
[0047] Step 2) Data preprocessing: In the analysis of hyperspectral images, the rich spectral information may lead to information overload and waste of computing resources. Therefore, after collecting the hyperspectral image data, the region of interest (ROI) is selected to remove non-important areas in the image, reduce the impact of noise, and ensure that the analysis results are more accurate and reliable. By selecting ROI, the analysis can be focused on a specific area, improve the pertinence of the analysis, and reduce the amount of data processed, thereby improving processing efficiency. ROI area selection is performed on the hyperspectral image data, and a 1040nm hyperspectral image is used. The Otsu threshold method is used to perform threshold segmentation on it to obtain a ROI area mask, and then the mask is used to segment the ROI area in each spectral image in the same spectral cube. Use the relevant library functions of the spectral library in Python to extract the hyperspectral curve of the ROI area. Its peak value should be ≥45000, and the difference in grayscale values between adjacent bands should be ≤210. If the peak value of the hyperspectral curve of the extracted ROI area is <45000, or the difference in grayscale values between adjacent bands of the hyperspectral curve of the extracted ROI area is >210, the data collection is unqualified and the sample hyperspectral image data needs to be recollected. As an example: Figure 2 The mask obtained by this algorithm for medium and high spectral images is visible Figure 4 ; Figure 4 To use 1040nm image, Figure 2 The medium and high spectral images are threshold segmented using the Otsu threshold method to obtain the ROI area mask.
[0048] By extracting the spectral reflectance of the ROI area of the two slices of the sample, the average spectral reflectance is calculated, and the average spectral reflectance is used as the feature of the slice sample to obtain the average spectral reflectance curve. The average spectral reflectance curves of samples from different years are shown in the figure: Figure 5 As shown, Figure 5The spectral reflectance curve is drawn based on the average value of the shortwave near-infrared image spectral reflectance data in the 930-1700nm band after calibrating the spectral reflectance data of samples from different years. 62 slice samples from different years are used as the test set. The specific samples are: 11 Huajuhong slice samples from 2011, 11 Huajuhong slice samples from 2013, 8 Huajuhong slice samples from 2016, 9 Huajuhong slice samples from 2019, 12 Huajuhong slice samples from 2021 and 11 Huajuhong slice samples from 2022. Subsequently, the PCA algorithm was used to reduce the spectral feature dimension of the obtained average reflectance curve. Specifically, the orange peel samples were divided into training set and test set samples. The ratio of training set to test set was 8:2, and the years of the training set samples were assigned categories; the extracted hyperspectral data were standardized: the PCA algorithm was used, and the hyperspectral image data obtained in step 1) was used as the input variable of the PCA algorithm to perform feature dimension reduction to obtain the preprocessed hyperspectral curve.
[0049] Step 3) Establishing a classification model: After preprocessing the hyperspectral curve, the training set data is input as input variables into the discriminant model constructed next, and the ratio of the training set to the test set is 8:2.
[0050] Classification model establishment: The preprocessed hyperspectral curve obtained in step 2) is used as the input variable of the discriminant model to train the machine learning multi-classifier. Not all classification prediction models support multi-class classification. Algorithms such as perceptron, logistic regression and support vector machine are designed for binary classification and do not support classification tasks of more than two categories.
[0051] One way to use binary classification algorithms for multi-classification problems is to split the multi-class classification dataset into multiple binary classification datasets and fit a binary classification model on each dataset. Several different examples of this approach are one-to-many, one-to-one, and output encoding strategies.
[0052] In this embodiment, OneVsOneClassifier (one-to-one classifier), OutputCodeClassifier (output code classifier), and OneVsRestClassifier (one-to-other classifier) are established respectively.
[0053] OneVsOneClassifier is a multi-class classification method based on binary classifiers. For N categories, it constructs N×(N-1) / 2 binary classifiers, each of which is responsible for distinguishing a pair of categories. OneVsRestClassifier is a multi-class classification method based on binary classifiers. For N categories, it constructs N binary classifiers, each of which takes one category as a positive example and all other categories as negative examples. OutputCodeClassifier is a multi-class classification method based on output encoding. It uses binary encoding to represent the label of each category, and then trains a binary classifier to predict the encoding. OutputCodeClassifier can adapt to large-scale classification problems and is also effective for cases with unbalanced categories.
[0054] The classification results obtained by combining different multi-classifiers with their corresponding different binary classifier kernels are shown in Table 1.
[0055] Table 1 Different classifiers and classification results
[0056]
[0057]
[0058] The results in Table 1 show that compared with the other two multi-classifiers, the performance (accuracy) of the OutputCodeClassifier classifier is better and more stable. Therefore, the OutputCodeClassifier classifier is selected as the final machine learning model as the year classification model of tangerine peel slices. The year of tangerine peel is calculated through the year classification model of tangerine peel slices to achieve year identification.
[0059] To demonstrate the effect of the PCA algorithm, the PCA algorithm is used in this embodiment to reduce the dimension of the characteristic wavelength from the original number of bands to 1-20 dimensions. The accuracy of the OutputCodeClassifier (LinearSVC (random_state = 0), code_size = 30, random_state = 0) classifier on the short-wave (930-1700nm band) near-infrared test set changes with the dimension of PCA dimensionality reduction. Figure 6 As shown, the results show that the PCA algorithm is used to reduce the dimension of the characteristic wavelength from the original number of bands to 1-20 dimensions, and the OutputCodeClassifier (LinearSVC (random_state = 0), code_size = 30, random_state = 0) classifier has a high accuracy.
[0060] Step 4) In multi-classification problems, the evaluation criteria include accuracy, confusion matrix, precision, recall, F1 score and other indicators.
[0061] In this embodiment, the best classifier OutputCodeClassifier (LinearSVC (random_state = 0), code_size = 30, random_state = 0) is used as the year classification model of the tangerine peel slices, and the tangerine peel slices of 62 different years are used as the test set. The year of the test set is detected in the shortwave (930-1700nm band) near infrared band. The specific confusion matrix obtained can be seen Figure 7 , precision, recall, and f1-score (F value) are all 1. The results show that the year classification model of Huajuhong slices obtained in this embodiment can accurately detect the year of Huajuhong.
[0062] Finally, it should be noted that, unless otherwise specifically stated, the relative arrangement of the components and steps, the numerical expressions and the numerical values described in these embodiments do not limit the scope of the present application. At the same time, it should be understood that, for ease of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship. The techniques, methods and devices known to ordinary technicians in the relevant field may not be discussed in detail, but in appropriate cases, the techniques, methods and devices should be regarded as part of the authorization specification. In all examples shown and discussed here, any specific value should be interpreted as merely exemplary, not as a limitation. Therefore, other examples of the exemplary embodiments may have different values. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further discussed in the subsequent drawings. The above is only a preferred embodiment of the present invention, and is not intended to limit the present invention. For those skilled in the art, the present invention may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention, and do not depart from the essence and scope of the technical solution of the present invention.
Claims
1. A method for identifying the age of tangerine peel based on hyperspectral imaging and machine learning model, characterized in that: The following steps are involved: Step 1) Data collection: Take slice samples of tangerine peel from different years and collect hyperspectral image data of two sections of the slice samples; Step 2) Data preprocessing: ROI region selection is performed on the hyperspectral image data, the hyperspectral curve of the ROI region is extracted, and feature dimension reduction is performed to obtain a preprocessed hyperspectral curve; Step 3) Establishing a classification model: using the preprocessed hyperspectral curve as an input variable of the discriminant model, training a machine learning multi-classifier, and evaluating the machine learning results to obtain the optimal year classification model of the Huajuhong slices, that is, the year classification model of the Huajuhong slices; Step 4) The year of tangerine peel is calculated by the year classification model of tangerine peel slices.
2. The method for identifying the year of Huajuhong according to claim 1, characterized in that: The hyperspectral image data includes: sample year, spectral band and spectral reflectance.
3. The method for identifying the year of Huajuhong according to claim 2, characterized in that: In step 1), the hyperspectral image data is collected in a dark box with a halogen tungsten lamp as the light source. The spectral resolution of the hyperspectral camera is higher than 3 nm, and the spatial resolution is ≥333×320. The orthographic method is used to collect the hyperspectral image data of two sections of the sliced sample of Citrus aurantium.
4. The method for identifying the year of Huajuhong according to claim 2 or 3, characterized in that: In the step 1), the hyperspectral image data is sequentially subjected to correction processing and denoising processing; The correction process includes: using the following formula to perform correction process: Among them, I(i,j) is the spectral reflectance of the (i,j) pixel in the hyperspectral image at a certain wavelength after correction, and R raw (i, j) is the original grayscale value of (i, j) in the corresponding hyperspectral image; R black (i, j) is the gray value of the dark noise corresponding to (i, j) in the hyperspectral image; R white (i, j) is the gray value of the standard plate in the hyperspectral image corresponding to (i, j); The denoising process includes: using the SG smoothing algorithm to perform denoising on the corrected hyperspectral image data.
5. The method according to claim 1, characterized in that In the step 1), the spectral band is the short-wave near-infrared spectral band of 930-1700nm.
6. The method according to claim 1, characterized in that In the step 2), the ROI region selection is specifically as follows: a hyperspectral image with a spectral band of 930-1700nm is used, and threshold segmentation is performed on it using the Otsu threshold method to obtain a ROI region mask, and then the mask is used to segment the ROI region in each spectral image in the same spectral cube.
7. The method according to claim 2, characterized in that: In the step 2), extracting the hyperspectral curve of the ROI region specifically comprises: taking the average spectral reflectance of the ROI region of the two sections of the slice sample as the feature of the slice sample, and obtaining the average reflectance curve, which is the hyperspectral curve of the ROI region.
8. The method according to claim 7, characterized in that In the step 2), the peak value of the hyperspectral curve of the ROI area extracted is ≥45000, and the difference between the grayscale values of adjacent bands is ≤210.
9. The method according to claim 1, wherein in step 2), feature dimensionality reduction is performed using a PCA algorithm.
10. The method according to claim 1, wherein in step 3), the multiple classifiers are OutputCodeClassifier, OneVsOneClassifier or OneVsRestClassifier, and the evaluation is performed using one or more criteria including accuracy, confusion matrix, precision, recall, and F1 score.
Citation Information
Patent Citations
Identification method of components of exocarpium
CN106404689A
Hyperspectral identification method and system for aging years of citrus chachiensis hortorum
CN115909324A
