Semen cassiae authenticity identification method based on hyperspectral imaging
Through hyperspectral imaging technology combined with deep learning and sparse coding, the problem of spectral data being easily disturbed in Cassia authenticity detection is solved, and high-precision Cassia authenticity recognition is achieved.
Patent Information
- Application Number
- CN202510056606.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2045-01-14
AI Technical Summary
The prior art spectral data in Cassia authenticity detection is susceptible to interference from ambient light, surface impurities and instrument drift, lack of feature extraction accuracy, lack of effective spectral segmentation and feature extraction methods, which limits detection performance.
Hyperspectral imaging equipment was used to collect hyperspectral images of Cassia sub-samples, and semantic segmentation was achieved through spectral baseline correction and KNet deep learning model, and effective spectral regions were extracted, spectral data was decoupled with combined sparse coding technology, key spectral features were extracted, and authenticity recognition models were trained based on LGBM algorithm.
The effectiveness of spectral data is improved, and interference factors such as ambient light changes, equipment deviations and surface impurities have been eliminated, which has significantly improved the classification accuracy and operating efficiency of Cassia's authenticity identification.
Smart Images

Figure CN119888358A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of detection and identification, and in particular to a method for identifying the authenticity of Cassia seeds based on hyperspectral imaging. Background Art
[0002] Since Cassia seed's appearance can easily be confused with other similar seeds, adulteration and counterfeiting often occur in the market, which not only reduces the quality and safety of Chinese medicinal materials, but also has an adverse impact on consumer rights and industry norms. Therefore, how to achieve rapid and accurate detection of Cassia seed's authenticity has become a problem that needs to be solved urgently.
[0003] At present, the methods for detecting the authenticity of Cassia seeds mainly include the following categories:
[0004] Chemical analysis method: Use chemical reagents or instruments to detect the components of Cassia seed, but this method is complicated to operate, has a long detection cycle, and is somewhat destructive to the sample, making it difficult to meet the needs of efficient detection.
[0005] Manual experience method: relies on manual visual identification of the appearance of Cassia seeds. The method is simple but highly subjective and can easily lead to misjudgment due to lack of experience or high similarity in sample appearance.
[0006] Spectroscopic analysis methods, such as near-infrared spectroscopy (NIR) or Raman spectroscopy, can achieve non-destructive testing, but are limited by the accuracy of feature extraction and are unable to cope with the tiny spectral differences between Cassia seed and counterfeits.
[0007] In recent years, hyperspectral imaging technology has gradually become an analytical tool with great potential. This technology combines spectral analysis and imaging technology, and can simultaneously obtain the spatial distribution and spectral characteristic information of samples, providing a new solution for the authenticity detection of Cassia seed. However, the application of hyperspectral imaging technology in the authenticity detection of Cassia seed still has the following problems:
[0008] Spectral data are easily affected by ambient light, surface impurities and instrument drift, resulting in insufficient feature extraction accuracy; there is a lack of spectral segmentation and feature extraction methods specific to the characteristics of Cassia seed, making it difficult to effectively separate the target area from the background area; there is a lack of efficient spectral feature analysis and classification models, making it impossible to fully utilize the rich information of hyperspectral data, limiting detection performance. Summary of the invention
[0009] In view of this, the present invention provides a method for identifying the authenticity of Cassia seed based on hyperspectral imaging to solve the above technical problems.
[0010] Based on the above purpose, the present invention provides a method for identifying the authenticity of Cassia seed based on hyperspectral imaging, comprising the following steps:
[0011] S1, Cassia seed spectral image acquisition: Use hyperspectral imaging equipment to collect hyperspectral images of Cassia seed samples;
[0012] S2, spectral image preprocessing: using spectral baseline correction method to correct the spectral drift of hyperspectral images;
[0013] S3, semantic segmentation of Cassia seed images based on KNet: The KNet (Kernel-based Network) deep learning model is used to segment the corrected spectral image, distinguish the target area and background area of the Cassia seed sample, and extract the effective spectral area of the Cassia seed sample based on the segmentation results;
[0014] S4, extracting the spectral curve of each Cassia seed sample and performing feature mapping conversion: extracting the spectral curve data of each Cassia seed sample according to the extracted effective spectral region to form a spectral curve matrix, performing feature mapping on the spectral curve matrix, and converting the spectral curve matrix into feature data in a high-dimensional feature space that can characterize the spectral features of Cassia seed; using joint sparse coding to decouple the spectral data in the high-dimensional feature space, separating the key spectral features related to the chemical components of Cassia seed and the redundant features affected by interference, and only retaining the key spectral features as the input of the subsequent model;
[0015] S5, establishment of Cassia seed authenticity identification model based on LGBM: using Cassia seed samples with known authenticity labels, using methods S1-S4 to capture hyperspectral images of Cassia seed samples with known authenticity labels and extract key spectral features as input data for the authenticity identification model, training the authenticity identification model based on the LGBM algorithm (lightweight gradient boosting machine, predicting by building an integrated model of decision trees), optimizing model parameters, and improving classification accuracy;
[0016] S6, authenticity identification and output: input the key spectral features of the Cassia seed sample to be tested in S4 into the authenticity identification model, and output the authenticity identification result.
[0017] Optionally, in S1, the sample is covered with a band range of 400-1000nm, and the line scan imaging mode is selected to obtain the spectral data of the Cassia seed sample in a line-by-line scanning manner, and the spectral resolution is controlled to be no higher than 5nm to ensure data accuracy. The data is collected in a constant temperature and humidity indoor environment to avoid interference with the spectral data due to changes in ambient light or fluctuations in sample water content.
[0018] Optionally, the S2 specifically includes:
[0019] S21, spectral baseline detection: by analyzing the spectral signal of each band in the hyperspectral image, the low-frequency part of the spectral data is identified as the spectral baseline, and the spectral baseline is fitted using the sliding window method;
[0020] S22, spectral drift estimation: compare the collected sample spectrum with the known reference sample spectrum to detect the shift of the spectral peak position; calculate the drift amplitude of each spectral band through cross-correlation analysis;
[0021] S23, correction function generation: based on the spectral drift estimation result, a spectral correction function adapted to each band is generated, and the correction function includes a piecewise smoothing function.
[0022] S24, baseline correction application: applying a correction function to each pixel spectrum in the hyperspectral image to correct baseline drift caused by changes in equipment or acquisition conditions, and generating corrected hyperspectral data.
[0023] Optionally, the S3 specifically includes:
[0024] S31, input data preparation: The hyperspectral image after spectral baseline correction is used as input data, and the spectral information of each pixel is used to construct a three-dimensional spectral data cube D∈R Q×W×B , where Q and W are the height and width of the image, respectively, and B is the number of spectral channels (number of bands).
[0025] S32, feature extraction: Use convolutional neural network to extract the spatial and spectral features of spectral images, and define the expression of feature extraction as: F = CNN(D; Θ), where F∈R Q×W×C is the extracted feature map, C is the number of feature channels, CNN is the convolutional neural network, and Θ is its parameter;
[0026] S33, semantic segmentation based on KNet: Use the KNet model to segment the target area and the background area on the feature map F, and output the segmentation mask M;
[0027] S34, effective spectral region extraction: based on the segmentation mask M, extract the target region of the Cassia subsample:
[0028] D effctive =D⊙M, where D effctive ∈R Q′×W′×B is the extracted effective spectral area, Q′ and W′ are the height and width of the segmented target area, and ⊙ represents pixel-by-pixel multiplication.
[0029] Optionally, the segmentation process of the semantic segmentation based on KNet in S33 includes:
[0030] Construct the kernel generation module K by dynamically generating kernel functions of a specific category:
[0031] K = DynamicKernel (F; φ), where DynamicKernel means generating a targeted kernel function on each input feature map, K is the dynamically generated kernel function, φ is the parameter of the kernel generation module, and the generated kernel function K is used to perform a convolution operation on the feature map F to output the segmentation mask M:
[0032] M=K*F,where M∈R H×W is the single-channel mask map after segmentation, and * represents the convolution operation.
[0033] Optionally, the S4 specifically includes:
[0034] S41, sort the spectral value of each pixel to form a sample spectral curve matrix X∈R N×B , where: X i,j =D effective (x i ,y i ,λ j ), where N = Q′·W′ represents the total number of pixels in the effective area, λ j is the wavelength corresponding to the jth band, X i,j is the spectral value of the i-th pixel in the j-th band;
[0035] S42, spectral curve matrix feature mapping: Use principal component analysis to reduce the dimension of the spectral curve matrix X, map it to the feature space, and obtain the reduced dimension feature matrix Z: Z = X·W PCA , where Z∈R N×K Represents the feature matrix after dimensionality reduction, K is the number of principal components, W PCA ∈R B×K The projection matrix representing the principal component analysis is solved by maximizing the variance, and the feature matrix Z is transformed into a high-dimensional feature space to obtain a high-dimensional feature space representation H: H = f(Z), where H∈R N×D represents the high-dimensional feature space representation, f is the nonlinear mapping function (Gaussian kernel mapping based on the kernel method), and D is the feature dimension of the high-dimensional space;
[0036] S43, joint sparse coding to decompose spectral features: Based on the high-dimensional feature space H, sparse coding is performed on it to decompose it into key spectral features H key and redundant spectral features H noise .
[0037] Optionally, the decomposition is into key spectral features H key and redundant spectral features H noise It is expressed as:
[0038] H=H key +H noise , where Hkey ∈R N×D represents the core spectral features related to the chemical components of Cassia seed, H noise ∈R N×D represents the redundant spectral features affected by interference;
[0039] The objective function of joint sparse coding is:
[0040] in, represents the Frobenius norm of the matrix, which is used to measure the reconstruction error, and ‖·‖1 represents the sparse regularization term, which controls H key The sparsity of λ1 and λ2 are regularization parameters. The sparsity and redundant feature retention are weighed and solved by alternating optimization methods. Finally, the decomposed H is obtained. key and H noise .
[0041] Optionally, the S5 specifically includes:
[0042] S51, build training data set Among them, h i ∈R D represents the key spectral feature vector of the i-th sample, y i ∈{0,1} represents the authenticity label of the i-th sample, 0 represents a fake, 1 represents a genuine product, S is the total number of training samples, and D is the feature dimension of the high-dimensional space;
[0043] S52, feature engineering: normalize the extracted key spectral features to ensure that the numerical ranges of different feature dimensions are consistent. The normalization formula is: Among them, min(h) and max(h) are the minimum and maximum values of each feature in the training set respectively;
[0044] S53, use the LGBM algorithm to train the authenticity recognition model. The objective function of the LGBM algorithm is:
[0045] in, Is the loss function, which is the logarithmic loss of the two categories: in, is the true or false probability predicted by the model, Θ is the parameter set of LGBM, is a regularization term used to prevent overfitting;
[0046] S54, Hyperparameter Optimization: Use cross-validation to tune the model's hyperparameters, including the learning rate η, decision tree depth, number of leaf nodes, and regularization coefficient λ0, using the training data set Train the model, use the validation set to evaluate the classification performance of the model, and calculate the classification accuracy.
[0047] Optionally, the authenticity identification model is expressed as:
[0048] in, is the predicted output of the i-th sample, indicating the probability that the Cassia seed sample is genuine, with a value range of [0,1]. i ∈R D represents the key spectral feature vector of the i-th sample, with dimension D, f(h i ; Θ) is the output function of the LGBM algorithm, which consists of multiple decision trees (weak learners) g t is a weighted combination of , T is the total number of decision trees, g t (h i ) is the t-th decision tree for sample h i The predicted value of t is the weight of the tth decision tree, Θ is all the parameters of the model, including the structure and weights of all decision trees.
[0049] Beneficial effects of the present invention:
[0050] The present invention realizes efficient semantic segmentation of Cassia seed samples through the combination of hyperspectral imaging equipment and KNet deep learning model, accurately distinguishes the target area from the background area, and improves the validity of spectral data. At the same time, through spectral baseline correction and joint sparse coding technology, the preprocessing and decoupling of spectral data are realized, and the core spectral features that are highly correlated with the chemical composition of Cassia seed are extracted, and the interference factors such as ambient light changes, equipment deviations and surface impurities are effectively eliminated, thereby providing high-quality input data for authenticity identification. This method can still maintain stable feature extraction accuracy when the sample data is highly complex, laying a solid foundation for model training and prediction.
[0051] The present invention trains an authenticity recognition model based on the LGBM algorithm, constructs an integrated model of multiple decision trees through a gradient boosting framework, and realizes efficient modeling of Cassia seed authenticity classification. The model makes full use of the high-dimensional spectral features after feature decoupling, avoids the influence of redundant features and noise interference on the classification results, and significantly improves the classification accuracy and operation efficiency compared with traditional authenticity recognition methods, and is suitable for large-scale Cassia seed authenticity detection tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only for the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0053] Figure 1 The figure is a schematic diagram of a method flow of an embodiment of the present invention. DETAILED DESCRIPTION
[0054] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. At the same time, it is explained here that in order to make the embodiments more detailed, the following embodiments are the best and preferred embodiments, and those skilled in the art may also adopt other alternatives to implement some known technologies; and the accompanying drawings are only for more specific description of the embodiments, and are not intended to specifically limit the present invention.
[0055] It should be noted that the references to "one embodiment", "an embodiment", "an exemplary embodiment", "some embodiments" and the like in the specification indicate that the embodiments described may include specific features, structures or characteristics, but not every embodiment may include the specific features, structures or characteristics. In addition, when a specific feature, structure or characteristic is described in conjunction with an embodiment, it should be within the knowledge of a person skilled in the art to implement such feature, structure or characteristic in conjunction with other embodiments (whether or not explicitly described).
[0056] In general, a term can be understood, at least in part, from its use in context. For example, depending, at least in part, on the context, the term "one or more" as used herein can be used to describe any feature, structure, or characteristic in the singular sense, or can be used to describe a combination of features, structures, or characteristics in the plural sense. Additionally, the term "based on" can be understood as not necessarily intended to convey an exclusive set of factors, but can instead, depending, at least in part, on the context, allow for the presence of other factors that are not necessarily explicitly described.
[0057] like Figure 1 As shown, the method for identifying the authenticity of Cassia seed based on hyperspectral imaging includes the following steps:
[0058] S1, Cassia seed spectral image acquisition: Use hyperspectral imaging equipment to collect hyperspectral images of Cassia seed samples;
[0059] S2, spectral image preprocessing: using spectral baseline correction method to correct the spectral drift of hyperspectral images and improve the accuracy and stability of data;
[0060] S3, semantic segmentation of Cassia seed images based on KNet: The KNet (Kernel-based Network) deep learning model is used to segment the corrected spectral image, distinguish the target area and background area of the Cassia seed sample, and extract the effective spectral area of the Cassia seed sample based on the segmentation results to ensure the accuracy and consistency of the segmentation;
[0061] S4, extracting the spectral curve of each Cassia seed sample and performing feature mapping conversion: extracting the spectral curve data of each Cassia seed sample according to the extracted effective spectral region to form a spectral curve matrix, performing feature mapping on the spectral curve matrix, and converting the spectral curve matrix into feature data in a high-dimensional feature space that can characterize the spectral features of Cassia seed; using joint sparse coding to decouple the spectral data in the high-dimensional feature space, separating the key spectral features related to the chemical components of Cassia seed and the redundant features affected by interference, and only retaining the key spectral features as the input of the subsequent model;
[0062] S5, establishment of Cassia seed authenticity identification model based on LGBM: using Cassia seed samples with known authenticity labels, using methods S1-S4 to capture hyperspectral images of Cassia seed samples with known authenticity labels and extract key spectral features as input data for the authenticity identification model, training the authenticity identification model based on the LGBM algorithm (lightweight gradient boosting machine, predicting by building an integrated model of decision trees), optimizing model parameters, and improving classification accuracy;
[0063] S6, authenticity identification and output: input the key spectral features of the Cassia seed sample to be tested in S4 into the authenticity identification model, and output the authenticity identification result.
[0064] In S1, the Cassia seed samples were evenly spread on the sampling platform of the hyperspectral imaging device, and the sample height was adjusted to ensure that all samples were within the focal plane. A uniformly distributed standard light source (such as a halogen lamp) was set to cover the samples in a band range of 400–1000 nm. The line scan imaging mode was selected to obtain the spectral data of the Cassia seed samples in a line-by-line scanning manner. The spectral resolution was controlled to be no higher than 5 nm to ensure data accuracy. The data were collected in a constant temperature and humidity indoor environment to avoid interference with the spectral data due to changes in ambient light or fluctuations in sample moisture content. The collected spectral image data was automatically stored, and spectral calibration was performed in combination with known Cassia seed sample category information to provide accurate raw data for subsequent spectral preprocessing and feature extraction.
[0065] S2 specifically includes:
[0066] S21, spectral baseline detection: by analyzing the spectral signal of each band in the hyperspectral image, identifying the low-frequency part of the spectral data as the spectral baseline, and using the sliding window method to fit the spectral baseline to ensure that the baseline curve can accurately reflect the change trend of the background signal of the sample;
[0067] Sliding window method: Use sliding window to detect baseline, the expression is: B(λ i )=min{S(λ k )|λ k ∈[λ i -w,λ i +w]}, where S(λ k ) is the wavelength λ k The corresponding original spectral signal, B(λ i ) is the wavelength λ i The baseline value of , w is the half-width of the sliding window, in wavelengths, which is determined experimentally.
[0068] S22, spectral drift estimation: compare the collected sample spectrum with the known reference sample spectrum to detect the shift of the spectral peak position; calculate the drift amplitude of each spectral band through cross-correlation analysis;
[0069] Spectral drift estimation: The cross-correlation analysis is used to calculate the spectral peak drift amplitude, the formula is:
[0070] Δλ=argmax Δ {∑ λ S1(λ)·S2(λ+Δ)}, where Δλ is the spectral drift amplitude in wavelength (nm), S1(λ) is the reference spectral signal, S2(λ) is the spectral signal to be corrected, and Δ is the wavelength offset, which is obtained by searching for the maximum correlation position.
[0071] S23, correction function generation: based on the spectral drift estimation result, a spectral correction function adapted to each band is generated, the correction function includes a piecewise smoothing function to ensure that the intensity distribution of the spectral signal is consistent with the real data;
[0072] Piecewise smoothing function: Smoothing correction is performed on each segment point in the band:
[0073] Where n represents the number of sampling points for piecewise smoothing, Δλ i is the wavelength λ i The corresponding drift amplitude.
[0074] S24, baseline correction application: applying a correction function to each pixel spectrum in the hyperspectral image to correct baseline drift caused by changes in equipment or acquisition conditions, and generating corrected hyperspectral data;
[0075] The corrected spectral signal is: S corrected (λ)=S(λ)-B(λ), where, S corrected (λ) is the corrected spectral signal, S(λ) is the original spectral signal, and B(λ) is the baseline signal.
[0076] S3 specifically includes:
[0077] S31, input data preparation: The hyperspectral image after spectral baseline correction is used as input data, and the spectral information of each pixel is used to construct a three-dimensional spectral data cube D∈R Q×W×B , where Q and W are the height and width of the image, respectively, and B is the number of spectral channels (number of bands).
[0078] S32, feature extraction: Use convolutional neural network to extract the spatial and spectral features of spectral images, and define the expression of feature extraction as: F = CNN(D; Θ), where F∈R Q×W×C is the extracted feature map, C is the number of feature channels, CNN is the convolutional neural network, and Θ is its parameter;
[0079] S33, semantic segmentation based on KNet: Use the KNet model to segment the target area and the background area on the feature map F, and output the segmentation mask M;
[0080] S34, effective spectral region extraction: based on the segmentation mask M, extract the target region of the Cassia subsample:
[0081] D effctive =D⊙M, where D effctive ∈R Q′×W′×B is the extracted effective spectral area, Q′ and W′ are the height and width of the segmented target area, and ⊙ represents pixel-by-pixel multiplication.
[0082] CNN is used to extract the hyperspectral image D∈R Q×W×B The spatial and spectral features can be extracted from the kernel. The operation can be decomposed into multi-layer convolution operations, as shown below:
[0083] Single-layer convolution operation: F l =σ(W l *D+b l ),in, The output feature map of layer l, The convolution kernel of the lth layer contains C l There are kernels, each of size k q ×k w , * indicates convolution operation, The bias vector of the lth layer, σ(·) is the activation function;
[0084] Multi-layer feature extraction: F = CNN(D; θ) = F u , where u is the total number of layers of CNN;
[0085] Θ={W1,W2,…′W n ; b1, b2, …, b n} represents all the parameters of CNN.
[0086] The segmentation process of KNet-based semantic segmentation in S33 includes:
[0087] Construct the kernel generation module K by dynamically generating kernel functions of a specific category:
[0088] K = DynamicKernal (F; Φ), where DynamicKernel means generating a targeted kernel function on each input feature map, K is the dynamically generated kernel function, Φ is the parameter of the kernel generation module, and the generated kernel function K is used to perform a convolution operation on the feature map F to output the segmentation mask M:
[0089] M=K*F,where M∈R H×W is the single-channel mask map after segmentation, and * represents the convolution operation.
[0090] S4 specifically includes:
[0091] S41, sort the spectral value of each pixel to form a sample spectral curve matrix X∈R N×B , where: X i,j =D effective (x i ,y i ,λ j ), where N = Q′·W′ represents the total number of pixels in the effective area, λ j is the wavelength corresponding to the jth band, X i,j is the spectral value of the i-th pixel in the j-th band;
[0092] S42, spectral curve matrix feature mapping: Use principal component analysis to reduce the dimension of the spectral curve matrix X, map it to the feature space, and obtain the reduced dimension feature matrix Z: Z = X·W PCA , where Z∈R N×K Represents the feature matrix after dimensionality reduction, K is the number of principal components, W PCA ∈R B×K The projection matrix representing the principal component analysis is solved by maximizing the variance, and the feature matrix Z is transformed into a high-dimensional feature space to obtain a high-dimensional feature space representation H: H = f(Z), where H∈R N×D represents the high-dimensional feature space representation, f is the nonlinear mapping function (Gaussian kernel mapping based on the kernel method), and D is the feature dimension of the high-dimensional space;
[0093] S43, joint sparse coding to decompose spectral features: Based on the high-dimensional feature space H, sparse coding is performed on it to decompose it into key spectral features H key and redundant spectral features H noise .
[0094] Decomposed into key spectral features H key and redundant spectral features H noise It is expressed as:
[0095] H=H key +H noise , where H key ∈R N×D represents the core spectral features related to the chemical components of Cassia seed, H noise ∈R N×D represents the redundant spectral features affected by interference;
[0096] The objective function of joint sparse coding is:
[0097] in, represents the Frobenius norm of the matrix, which is used to measure the reconstruction error, and ‖·‖1 represents the sparse regularization term, which controls H key The sparsity of λ1 and λ2 are regularization parameters. The sparsity and redundant feature retention are weighed and solved by alternating optimization methods. Finally, the decomposed H is obtained. key and H noise ;
[0098] Feature output: The decoupled key spectral feature H key The data is extracted into the format that is ultimately used as input for the authenticity recognition model.
[0099] S5 specifically includes:
[0100] S51, build training data set Among them, h i ∈R D represents the key spectral feature vector of the i-th sample, y i ∈{0,1} represents the authenticity label of the i-th sample, 0 represents a fake, 1 represents a genuine product, S is the total number of training samples, and D is the feature dimension of the high-dimensional space;
[0101] S52, feature engineering: normalize the extracted key spectral features to ensure that the numerical ranges of different feature dimensions are consistent. The normalization formula is: Among them, min(h) and max(h) are the minimum and maximum values of each feature in the training set respectively;
[0102] S53, use the LGBM algorithm to train the authenticity recognition model. The objective function of the LGBM algorithm is:
[0103] in, Is the loss function, which is the logarithmic loss of the two categories: in, is the true or false probability predicted by the model, Θ is the parameter set of LGBM, is a regularization term used to prevent overfitting;
[0104] S54, Hyperparameter Optimization: Use cross-validation to tune the model's hyperparameters, including the learning rate η, decision tree depth, number of leaf nodes, and regularization coefficient λ0, using the training data set The model is trained, and the classification performance of the model is evaluated using the validation set, and the classification accuracy is calculated; the optimal model parameters are saved for the authenticity identification task in the subsequent step S6.
[0105] The authenticity identification model is expressed as:
[0106] in, is the predicted output of the i-th sample, indicating the probability that the Cassia seed sample is genuine, with a value range of [0,1]. i ∈R D represents the key spectral feature vector of the i-th sample, with dimension D, f(h i ; Θ) is the output function of the LGBM algorithm, which consists of multiple decision trees (weak learners) g t is a weighted combination of , T is the total number of decision trees, g t (h i ) is the t-th decision tree for sample h i The predicted value of t is the weight of the t-th decision tree, which is dynamically optimized by the gradient boosting algorithm. Θ is all the parameters of the model, including the structure and weights of all decision trees.
[0107] The present invention covers any substitution, modification, equivalent method and scheme made on the essence and scope of the present invention. In order to make the public have a thorough understanding of the present invention, specific details are described in detail in the following preferred embodiments of the present invention, but those skilled in the art can fully understand the present invention without the description of these details. In addition, in order to avoid unnecessary confusion about the essence of the present invention, well-known methods, processes, procedures, components and circuits are not described in detail.
[0108] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for identifying the authenticity of Cassia seeds based on hyperspectral imaging, characterized in that: The following steps are involved: S1, hyperspectral images of Cassia seed samples were collected using a hyperspectral imaging device; S2, using spectral baseline correction method to correct the spectral drift of hyperspectral images; S3, using the KNet deep learning model to segment the corrected spectral image, distinguish the target area and background area of the Cassia seed sample, and extract the effective spectral area of the Cassia seed sample based on the segmentation results; S4, extracting the spectral curve data of each Cassia seed sample according to the extracted effective spectral region to form a spectral curve matrix, performing feature mapping on the spectral curve matrix, and converting the spectral curve matrix into feature data in a high-dimensional feature space that can characterize the spectral features of the Cassia seed; using joint sparse coding to decouple the spectral data in the high-dimensional feature space, and separating the key spectral features related to the chemical components of the Cassia seed from the redundant features affected by interference; S5, using the Cassia subsample with known authenticity labels, using the methods of S1-S4 to capture the hyperspectral image of the Cassia subsample with known authenticity labels and extract key spectral features, which are used as the input data of the authenticity recognition model, and the authenticity recognition model is trained based on the LGBM algorithm; S6, inputting the key spectral features of the Cassia seed sample to be tested in S4 into the authenticity identification model, and outputting the authenticity identification result.
2. The method for identifying the authenticity of Cassia seed based on hyperspectral imaging according to claim 1, characterized in that: In S1, the sample is covered with a band range of 400-1000nm, and the line scanning imaging mode is selected to obtain the spectral data of the Cassia seed sample in a line-by-line scanning manner. The data is collected in a constant temperature and humidity indoor environment to avoid interference with the spectral data due to changes in ambient light or fluctuations in sample water content.
3. The method for identifying the authenticity of Cassia seed based on hyperspectral imaging according to claim 1, characterized in that: The S2 specifically includes: S21, spectral baseline detection: by analyzing the spectral signal of each band in the hyperspectral image, the low-frequency part of the spectral data is identified as the spectral baseline, and the spectral baseline is fitted using the sliding window method; S22, spectral drift estimation: compare the collected sample spectrum with the known reference sample spectrum to detect the shift of the spectral peak position; calculate the drift amplitude of each spectral band through cross-correlation analysis; S23, correction function generation: based on the spectral drift estimation result, a spectral correction function adapted to each band is generated, the correction function includes a piecewise smoothing function; S24, baseline correction application: applying a correction function to each pixel spectrum in the hyperspectral image to correct baseline drift caused by changes in equipment or acquisition conditions, and generating corrected hyperspectral data.
4. The method for identifying the authenticity of Cassia seed based on hyperspectral imaging according to claim 1, characterized in that: The S3 specifically includes: S31, input data preparation: The hyperspectral image after spectral baseline correction is used as input data, and the spectral information of each pixel is used to construct a three-dimensional spectral data cube D∈R Q×W×B , where Q and W are the height and width of the image respectively, and B is the number of spectral channels; S32, feature extraction: Use convolutional neural network to extract the spatial and spectral features of spectral images, and define the expression of feature extraction as: F = CNN(D; Θ), where F∈R Q×W×C is the extracted feature map, C is the number of feature channels, CNN is the convolutional neural network, and Θ is its parameter; S33, semantic segmentation based on KNet: Use the KNet model to segment the target area and the background area on the feature map F, and output the segmentation mask M; S34, effective spectral region extraction: based on the segmentation mask M, extract the target region of the Cassia subsample: D effective =D⊙M, where D effective ∈R Q′×W′×B is the extracted effective spectral area, Q′ and W′ are the height and width of the segmented target area, and ⊙ represents pixel-by-pixel multiplication.
5. The method for identifying the authenticity of Cassia seed based on hyperspectral imaging according to claim 4, characterized in that: The segmentation process of the semantic segmentation based on KNet in S33 includes: Construct the kernel generation module K by dynamically generating kernel functions of a specific category: K = DynamicKernel (F; Φ), where DynamicKernel means generating a targeted kernel function on each input feature map, K is the dynamically generated kernel function, Φ is the parameter of the kernel generation module, and the generated kernel function K is used to perform a convolution operation on the feature map F to output the segmentation mask M: M=K*F,where M∈R H×W is the single-channel mask map after segmentation, and * represents the convolution operation.
6. The method for identifying the authenticity of Cassia seed based on hyperspectral imaging according to claim 1, characterized in that: The S4 specifically includes: S41, sort the spectral value of each pixel to form a sample spectral curve matrix X∈R N×B , where: X i,j =D effective (x i ,y i ,λ j ), where N = Q′·W′ represents the total number of pixels in the effective area, λ j is the wavelength corresponding to the jth band, X i,j is the spectral value of the i-th pixel in the j-th band; S42, spectral curve matrix feature mapping: principal component analysis is used to reduce the dimension of the spectral curve matrix X, and the matrix is mapped to the feature space to obtain the reduced dimension feature matrix Z, and the feature matrix Z is converted into a high-dimensional feature space by maximizing the variance method to obtain the high-dimensional feature space representation H; S43, joint sparse coding to decompose spectral features: Based on the high-dimensional feature space H, sparse coding is performed on it to decompose it into key spectral features H key and redundant spectral features H noise .
7. The method for identifying the authenticity of Cassia seed based on hyperspectral imaging according to claim 6, characterized in that: The decomposition is into key spectral features H key and redundant spectral features H noise It is expressed as: H=H key +H noise , where H key ∈R N×D represents the core spectral features related to the chemical components of Cassia seed, H noise ∈R N ×D represents the redundant spectral features affected by interference; The objective function of joint sparse coding is: in, represents the Frobenius norm of the matrix, which is used to measure the reconstruction error, and ‖·‖1 represents the sparse regularization term, which controls H key The sparsity of λ1 and λ2 are regularization parameters. The sparsity and redundant feature retention are weighed and solved by the alternating optimization method. Finally, the decomposed H is obtained. key and H noise .
8. The method for identifying the authenticity of Cassia seed based on hyperspectral imaging according to claim 6, characterized in that: The S5 specifically includes: S51, build training data set Among them, h i ∈R D represents the key spectral feature vector of the i-th sample, y i ∈{0,1} represents the authenticity label of the i-th sample, 0 represents a fake, 1 represents a genuine product, S is the total number of training samples, and D is the feature dimension of the high-dimensional space; S52, feature engineering: normalize the extracted key spectral features to ensure that the numerical ranges of different feature dimensions are consistent; S53, use the LGBM algorithm to train the authenticity recognition model. The objective function of the LGBM algorithm is: in, is the loss function, Θ is the parameter set of LGBM, is a regularization term used to prevent overfitting; S54, Hyperparameter Optimization: Use cross-validation to tune the model's hyperparameters, including the learning rate η, decision tree depth, number of leaf nodes, and regularization coefficient λ0, using the training data set Train the model, use the validation set to evaluate the classification performance of the model, and calculate the classification accuracy.
9. The method for identifying the authenticity of Cassia seed based on hyperspectral imaging according to claim 8, characterized in that: The authenticity identification model is expressed as: in, is the predicted output of the i-th sample, indicating the probability that the Cassia seed sample is genuine, with a value range of [0,1]. i ∈R D represents the key spectral feature vector of the i-th sample, with dimension D, f(h i ; Θ) is the output function of the LGBM algorithm, which consists of multiple decision trees g t is a weighted combination of , T is the total number of decision trees, g t (h i ) is the t-th decision tree for sample h i The predicted value of t is the weight of the tth decision tree, Θ is all the parameters of the model, including the structure and weights of all decision trees.
Citation Information
Patent Citations
Impurity removal system based on multi-view vision
CN111380833A
Space spectrum full convolution hyperspectral image classification method based on superpixel sample expansion
CN111695467A
Digital multi-dimensional image photon platform system and methods of use
US20160227185A1
Cited By
Anoectochilus formosanus plant leaf authenticity identification and strain classification method and system
CN120213831A
Intelligent blood smear quality detection method for clinical laboratory
CN120232823A
Grain producing area identification method, device and equipment based on hyperspectral image
CN121330523A