A method, medium and system for predicting fresh tobacco leaf chlorophyll concentration
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-22
- Publication Date
- 2026-08-11
AI Technical Summary
[0005]有鉴于此,本发明提供一种鲜烟叶叶绿素浓度预测方法、介质及系统,能够解决现有技术中难以实现对鲜烟叶叶绿素浓度快速精确预测的技术问题
[0016] Compared with existing technologies, this invention provides a method, medium, and system for predicting chlorophyll concentration in fresh tobacco leaves. This invention proposes a method for predicting chlorophyll concentration in fresh tobacco leaves based on convolutional neural networks and feature fusion. This method innovatively combines image analysis and spectral analysis techniques, achieving automatic feature extraction and fusion through a deep learning model. The standardized data acquisition process and multiple preprocessing techniques effectively reduce interference from environmental factors and improve data quality.
Smart Images

Figure CN120031822B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of electronic digital data processing technology, and specifically relates to a method, medium and system for predicting the chlorophyll concentration of fresh tobacco leaves. Background Technology
[0002] Chlorophyll concentration in fresh tobacco leaves is a key indicator for evaluating leaf maturity and quality, and is of great significance for guiding tobacco harvesting and improving leaf quality. Traditional methods for determining chlorophyll concentration mainly include two categories: chemical extraction and spectroscopic methods. Chemical extraction involves extracting chlorophyll using organic solvents such as ethanol or acetone, and then calculating the chlorophyll concentration by measuring the absorbance using a spectrophotometer. While this method offers high accuracy, it suffers from drawbacks such as sample destructiveness, high reagent consumption, complex operation, and long measurement cycles, making it difficult to meet the rapid detection needs in tobacco production. Spectroscopic methods, on the other hand, involve collecting the reflectance spectrum of leaves and establishing a mathematical model to predict chlorophyll concentration. This method offers the advantage of non-destructive testing, but it is significantly affected by factors such as ambient light and measurement angle, and professional spectrometers are expensive.
[0003] In recent years, with the development of computer vision technology, image analysis-based methods for measuring chlorophyll concentration have gradually attracted attention. These methods extract features such as color and texture from leaf images to build predictive models, offering advantages such as low cost and ease of operation. However, methods relying solely on image features are easily affected by shooting conditions and cannot obtain information about the internal structure of the leaf, leading to unstable prediction accuracy. Furthermore, while portable chlorophyll meters are convenient to operate, their measurement principle is too simplistic, estimating chlorophyll content only by measuring reflectance at a specific wavelength, resulting in low accuracy and unsuitability for precise measurement.
[0004] Existing measurement methods suffer from either inefficiency or insufficient accuracy, making it difficult to simultaneously achieve a balance between speed and precision. This is particularly true in large-scale tobacco production, where real-time monitoring of numerous samples is required, placing high demands on both efficiency and accuracy. Furthermore, most existing prediction models employ single feature sources or simple statistical methods, failing to fully utilize the complementary advantages of multi-source data and lacking effective feature extraction and fusion mechanisms. In summary, existing technologies struggle to achieve rapid and accurate prediction of chlorophyll concentration in fresh tobacco leaves. Summary of the Invention
[0005] In view of this, the present invention provides a method, medium and system for predicting the chlorophyll concentration of fresh tobacco leaves, which can solve the technical problem that it is difficult to achieve rapid and accurate prediction of the chlorophyll concentration of fresh tobacco leaves in the prior art.
[0006] The present invention is implemented as follows: The first aspect of the present invention provides a method for predicting chlorophyll concentration in fresh tobacco leaves, comprising the following steps: collecting fresh tobacco leaf samples and taking pictures to obtain fresh tobacco leaf images; collecting near-infrared spectral data of the fresh tobacco leaf samples to generate a spectral data matrix; the method constructs a feature correlation matrix based on Pearson correlation analysis and uses recursive feature elimination to select the optimal feature combination to form an optimal image feature dataset; simultaneously, it uses a competitive adaptive reweighting algorithm, a continuous projection algorithm, and a sparse representation algorithm to extract features from the preprocessed spectral data matrix to form an optimal spectral feature dataset; based on matrix decomposition, it determines the fusion weight coefficients, calculates the feature interaction matrix between the optimal image feature dataset and the optimal spectral feature dataset, and generates a multi-source feature fusion dataset; it constructs a combined model of a convolutional neural network and a long short-term memory network, the combined model including a sequence folding layer, a convolutional layer, a global average pooling layer, a channel attention layer, a defolding layer, a long short-term memory layer, a fully connected layer, and a regression layer; the weights of the channel attention layer of the combined model are adjusted according to the importance scoring matrix to generate a chlorophyll concentration prediction model.
[0007] The steps of collecting fresh tobacco leaf samples and taking pictures to obtain fresh tobacco leaf images specifically involve collecting 50 samples of fresh tobacco leaves at each of the four stages of immaturity, semi-ripeness, moderate ripeness, and maturity. The fresh tobacco leaf samples are then photographed using a smartphone or digital camera in a darkroom environment. The background of the fresh tobacco leaf images is segmented using a color segmentation method based on the Ycbcr color space. The feature values of the R, G, B, L, a, and b color channels and the texture feature values based on the gray-level co-occurrence matrix are extracted to generate an initial image feature dataset.
[0008] Specifically, the step of collecting near-infrared spectral data of the fresh tobacco leaf sample involves collecting near-infrared spectral data of the fresh tobacco leaf sample in the 900 to 1700 nanometer wavelength range. Six measurement points are collected at the leaf tip, leaf middle, and both sides of the leaf base of the fresh tobacco leaf sample, avoiding the main vein and branch veins. The average value of the six measurement points is calculated as the initial near-infrared spectral data.
[0009] Specifically, the step of generating the spectral data matrix involves preprocessing the initial near-infrared spectral data using normalization, standard normal variable transformation, and multivariate scattering correction methods to generate a preprocessed spectral data matrix. Then, competitive adaptive reweighting, continuous projection, and sparse representation algorithms are used to extract features from the preprocessed spectral data matrix. Finally, the feature combination with the best training performance is selected to generate an optimal spectral feature dataset.
[0010] Specifically, the step of determining the fusion weight coefficients based on matrix factorization involves calculating the correlation coefficients between each feature value and chlorophyll concentration in the initial image feature dataset using Pearson correlation analysis, constructing a feature correlation matrix, processing the feature correlation matrix using recursive feature elimination, selecting the feature combination with the best training performance, and forming an optimized image feature dataset.
[0011] Specifically, the step of generating a multi-source feature fusion dataset involves calculating the feature interaction matrix between the preferred image feature dataset and the preferred spectral feature dataset, and then performing vector multiplication and fusion on the preferred image feature dataset and the preferred spectral feature dataset according to the fusion weight coefficient.
[0012] The step of generating a chlorophyll concentration prediction model specifically involves using a spectrophotometer to measure the absorbance of the fresh tobacco leaf sample at wavelengths of 649 nm and 665 nm, generating a chlorophyll concentration measurement dataset based on the chlorophyll content calculation formula, and establishing an importance score matrix for each feature in the multi-source feature fusion dataset.
[0013] Specifically, the step of using the chlorophyll concentration prediction model involves obtaining fresh tobacco leaves to be tested, repeating the steps described in claims 1 to 6, generating a multi-source feature fusion dataset of the fresh tobacco leaves to be tested, inputting the multi-source feature fusion dataset of the fresh tobacco leaves to be tested into the chlorophyll concentration prediction model, and outputting the predicted chlorophyll concentration value of the fresh tobacco leaves to be tested.
[0014] A second aspect of the present invention provides a computer-readable storage medium storing program instructions that, when executed in a computer, are used to perform the above-described method for predicting the chlorophyll concentration of fresh tobacco leaves.
[0015] A third aspect of the present invention provides a fresh tobacco leaf chlorophyll concentration prediction system, comprising the aforementioned computer-readable storage medium, wherein the system is any one of a computer, a server, or a microcontroller, the computer-readable storage medium is disposed within the system, and the system is provided with a microprocessor that executes program instructions stored in the computer-readable storage medium.
[0016] Compared with existing technologies, this invention provides a method, medium, and system for predicting chlorophyll concentration in fresh tobacco leaves. This invention proposes a method for predicting chlorophyll concentration in fresh tobacco leaves based on convolutional neural networks and feature fusion. This method innovatively combines image analysis and spectral analysis techniques, achieving automatic feature extraction and fusion through a deep learning model. The standardized data acquisition process and multiple preprocessing techniques effectively reduce interference from environmental factors and improve data quality.
[0017] The feature extraction and fusion scheme designed in this invention fully considers the characteristics of different feature sources. It selects the optimal feature combination through recursive feature elimination and competitive adaptive reweighting algorithms, avoiding interference from redundant information. A matrix factorization-based fusion strategy is adopted, preserving the physical meaning of the original features while achieving effective feature fusion. Simultaneously, a channel attention mechanism is introduced, enabling the model to adaptively adjust the weights of different features, thus improving the robustness of prediction.
[0018] This invention successfully solves the problem of balancing speed and accuracy by leveraging the powerful feature learning capabilities of deep learning models. This method not only inherits the speed and simplicity of image analysis but also overcomes the instability of accuracy inherent in single-feature methods, achieving rapid and accurate prediction of chlorophyll concentration in fresh tobacco leaves. The entire measurement process requires no complex sample pretreatment and can be performed online, significantly improving detection efficiency. It solves the technical problem of achieving rapid and accurate prediction of chlorophyll concentration in fresh tobacco leaves. Attached Figure Description
[0019] Figure 1 This is a flowchart of the method of the present invention;
[0020] Figure 2 The flowchart shows a method for predicting chlorophyll concentration in fresh tobacco leaves based on convolutional neural networks and feature fusion.
[0021] Figure 3 This is a diagram of the CNN-LSTM architecture;
[0022] Figure 4 This is a schematic diagram of vector multiplication fusion features;
[0023] Figure 5 Image feature evaluation results;
[0024] Figure 6 The evaluation results of nine combinations of the preprocessing-key point selection algorithm are shown in the figure.
[0025] Figure 7 The image shows the evaluation results of CNN-LSTM based on fusion features.
[0026] Figure 8 The image features are evaluated using CNN-LSTM.
[0027] Figure 9 The image shows the CNN-LSTM evaluation results for near-infrared spectral features. Detailed Implementation
[0028] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.
[0029] like Figure 1 The diagram shown is a flowchart of a method for predicting chlorophyll concentration in fresh tobacco leaves according to the first aspect of this invention. This method includes the following steps:
[0030] S01. Collect 50 fresh tobacco leaf samples at each of the four stages of immature, semi-mature, moderately mature, and mature. Take photos of the fresh tobacco leaf samples using a smartphone in a darkroom environment to obtain images of the fresh tobacco leaves.
[0031] S02. Use the color segmentation method based on the Ycbcr color space to perform background segmentation on the fresh tobacco leaf image, extract the feature values of the R, G, B, L, a, and b color channels and the texture feature values based on the gray-level co-occurrence matrix, and generate an initial image feature dataset.
[0032] S03. Calculate the correlation coefficients between each feature value and chlorophyll concentration in the initial image feature dataset based on Pearson correlation analysis, and construct a feature correlation matrix;
[0033] S04. The feature correlation matrix is processed using the recursive feature elimination method, and the feature combination with the best training performance is selected to form an optimal image feature dataset.
[0034] S05. Collect near-infrared spectral data of the fresh tobacco leaf sample in the 900 to 1700 nanometer band. Collect 6 measurement points on both sides of the leaf tip, leaf middle and leaf base of the fresh tobacco leaf sample, avoiding the main vein and branch veins, and calculate the average value of the 6 measurement points as the initial near-infrared spectral data.
[0035] S06. The initial near-infrared spectral data are preprocessed using the normalization method, the standard normal variable transformation method, and the multivariate scattering correction method to generate a preprocessed spectral data matrix.
[0036] S07. The preprocessed spectral data matrix is subjected to feature extraction using the competitive adaptive reweighting algorithm, the continuous projection algorithm, and the sparse representation algorithm, respectively. The feature combination with the best training performance is selected to generate the preferred spectral feature dataset.
[0037] S08. Calculate the feature interaction matrix between the preferred image feature dataset and the preferred spectral feature dataset, and determine the fusion weight coefficients based on matrix decomposition;
[0038] S09. Perform vector multiplication and fusion on the preferred image feature dataset and the preferred spectral feature dataset according to the fusion weight coefficient to generate a multi-source feature fusion dataset;
[0039] S10. The absorbance of the fresh tobacco leaf sample was measured at wavelengths of 649 nm and 665 nm using a spectrophotometer, and a chlorophyll concentration measurement dataset was generated based on the chlorophyll content calculation formula.
[0040] S11. Construct a combined model of convolutional neural network and long short-term memory network, wherein the combined model includes sequence folding layer, convolutional layer, global average pooling layer, channel attention layer, defolding layer, long short-term memory layer, fully connected layer and regression layer;
[0041] S12. Establish the importance score matrix of each feature in the multi-source feature fusion dataset;
[0042] S13. Adjust the channel attention layer weights of the combined model according to the importance scoring matrix, and train the combined model using the multi-source feature fusion dataset and the measured chlorophyll concentration dataset to obtain the chlorophyll concentration prediction model.
[0043] S14. Obtain the fresh tobacco leaves to be tested, and repeat steps S01 to S09 to generate a multi-source feature fusion dataset of the fresh tobacco leaves to be tested.
[0044] S15. Input the multi-source feature fusion dataset of the fresh tobacco leaves to be tested into the chlorophyll concentration prediction model, and output the predicted value of chlorophyll concentration of the fresh tobacco leaves to be tested.
[0045] The specific implementation methods of the above steps are described in detail below.
[0046] The specific implementation of step S01 involves acquiring high-quality fresh tobacco leaf image samples by constructing a standardized data acquisition environment. First, four maturity levels of fresh tobacco leaves are determined: underripe, partially ripe, moderately ripe, and mature. Fifty samples are collected from each level to ensure data representativeness and statistical significance. A standardized darkroom environment is used during acquisition. The interior of the darkroom is coated with matte black paint to avoid ambient light interference. An LED light source is installed at the top of the darkroom, with a color temperature of 5500K and an illuminance of 1000 lux. A smartphone with a camera of at least 12 megapixels is used for shooting. The shooting parameters are fixed as follows: ISO 100, shutter speed 1 / 60 second, aperture f / 2.0, and automatic white balance. During shooting, the fresh tobacco leaf sample is laid flat at the center of the bottom of the darkroom, ensuring the leaf surface is perpendicular to the camera. The shooting distance is fixed at 30 cm. After shooting, the images undergo preliminary inspection. Images with quality problems such as blurriness or improper exposure are discarded, and qualified images are numbered and archived. The purpose of this step is to establish a standardized image acquisition process to ensure the data quality for subsequent analysis.
[0047] The specific implementation of step S02 involves background segmentation and feature extraction of the acquired fresh tobacco leaf image. First, image segmentation is performed using the Ycbcr color space. This color space was chosen because it can better separate luminance and chromaticity information and has strong robustness to changes in illumination. By adaptively adjusting the Y component threshold, with a threshold range of 16 to 235, initial separation of the background and target is achieved. Subsequently, morphological operations are used for edge optimization, including opening operations using circular structuring elements with a radius of 3 pixels to remove noise, and closing operations using circular structuring elements with a radius of 5 pixels to fill small holes. In the feature extraction stage, the mean values of the R, G, and B channels in the RGB color space and the mean values of the L, a, and b channels in the Lab color space are calculated. Simultaneously, texture features, including statistics such as energy, contrast, correlation, and entropy, are calculated based on the gray-level co-occurrence matrix. The distance parameter of the matrix is set to 1, and the direction angles are set to 0 degrees, 45 degrees, 90 degrees, and 135 degrees. The average value of the four directions is taken as the final feature value. These processes yield an initial image feature dataset, laying the foundation for subsequent feature selection.
[0048] The specific implementation of step S03 involves using Pearson correlation analysis to assess the correlation between image features and chlorophyll concentration. First, all feature values are standardized to a mean of 0 and a standard deviation of 1. Then, the Pearson correlation coefficient between each feature value and chlorophyll concentration is calculated. The correlation coefficient ranges from -1 to 1, with the absolute value closer to 1 indicating a stronger correlation. Based on empirical thresholds, features with an absolute correlation coefficient greater than 0.3 are defined as moderately correlated, greater than 0.5 as strongly correlated, and greater than 0.7 as extremely strongly correlated. This method constructs a feature correlation matrix, where each element represents the degree of correlation between the corresponding feature and chlorophyll concentration, providing an important reference for subsequent feature selection.
[0049] The specific implementation of step S04 involves using a recursive feature elimination method to filter features. This method first constructs an initial model using a support vector machine (SVM) with a radial basis function kernel, a kernel parameter gamma of 0.1, and a penalty parameter C of 100. Then, the least important features are progressively removed based on their weights. After each removal, the model is retrained and performance metrics are recorded. The performance of different feature combinations is evaluated using cross-validation, with a validation set ratio of 30%, and validation is repeated 10 times, with the average value taken. Finally, the feature combination with the smallest root mean square error on the validation set is selected as the preferred feature set. Typically, the number of features is reduced from approximately 20 initially to 5-8. This significantly reduces feature dimensionality while maintaining model performance.
[0050] The specific implementation of step S05 involves collecting near-infrared spectral data from fresh tobacco leaf samples. A near-infrared spectrometer is used, with the wavelength range set to 900 to 1700 nanometers, the spectral resolution to 2 nanometers, and the number of scans set to 32 to improve the signal-to-noise ratio. Six measurement points are set at each tobacco leaf: one at the tip, one in the middle, and one on each side of the leaf base. The distance between each measurement point and the midrib and secondary veins is no less than 5 millimeters. Each measurement point is recorded three times, and the average value is taken as the spectral data for that point. Finally, the arithmetic mean of the six measurement points is calculated to obtain the initial near-infrared spectral data for the tobacco leaf. During the data collection process, the ambient temperature is maintained at 25 ± 2 degrees Celsius, and the relative humidity at 60% ± 5%.
[0051] The specific implementation of step S06 involves preprocessing the initial near-infrared spectral data. First, a normalization method is used to linearly map the data to the 0-1 interval, eliminating the influence of dimensions. Then, a standard normal variable transformation method is applied to convert the data into a distribution with a mean of 0 and a standard deviation of 1, reducing noise. Finally, a multivariate scattering correction method is used to establish a linear regression equation for correction by calculating the deviation of each wavelength point from the average spectrum, eliminating the influence of sample thickness and surface scattering. After these three processing methods, a preprocessed spectral data matrix is obtained, where the number of rows equals the number of samples, and the number of columns equals the number of spectral wavelength points.
[0052] The specific implementation of step S07 involves extracting key features from the preprocessed spectral data. The competitive adaptive reweighting algorithm selects features using Monte Carlo sampling and exponentially decaying adaptive weights, with 500 sampling iterations and a weight decay coefficient of 0.95. The continuous projection algorithm selects wavelengths with minimal collinearity using orthogonal projection, with a projection threshold of 0.0001. The sparse representation algorithm uses LASSO regression for feature compression, with the regularization parameter determined through cross-validation, typically 0.01. These three algorithms are applied to spectral data preprocessed using different methods, resulting in nine feature combinations. The performance of each combination is evaluated using a backpropagation (BP) neural network. The network contains one hidden layer with twice the number of neurons as input features, a learning rate of 0.01, and 1000 training epochs. The feature combination with the highest determination coefficient on the test set is selected as the preferred spectral feature dataset.
[0053] The specific implementation of step S08 involves calculating the interaction relationships between preferred features. First, image features and spectral features are standardized, and then the mutual information matrix between the two types of features is calculated. This matrix is then subjected to singular value decomposition to obtain a left singular matrix, a singular value matrix, and a right singular matrix. Important feature combinations are determined based on the magnitude of the singular values, typically retaining singular values with a cumulative contribution rate reaching 85%. The fusion weight coefficients are obtained in this way; the coefficient values are between 0 and 1, reflecting the importance of different features in the fusion process.
[0054] The specific implementation of step S09 is based on feature fusion using fusion weight coefficients. Vector multiplication is used, multiplying the image feature vector with its corresponding weight coefficient, and also multiplying the spectral feature vector with its respective weight coefficient. The two weighted vectors are then concatenated to form a fused feature vector. This fusion method preserves the physical meaning of the original features while reflecting the relative importance of different features. The final multi-source feature fusion dataset has a dimension equal to the sum of the dimensions of the two types of features.
[0055] The specific implementation of step S10 involves establishing a chlorophyll concentration measurement dataset. A spectrophotometer is used, with a wavelength accuracy of ±0.1 nm and a wavelength repeatability of ±0.05 nm. A 0.2 g sample is taken from each tobacco leaf and placed in a test tube containing 25 mL of 95% ethanol, and extracted for 24 hours at 4°C in the dark. The absorbance at wavelengths of 649 nm and 665 nm is then measured, with each sample measured three times and the average value taken. The concentration value is calculated according to the chlorophyll content calculation formula, with the absorbance measurement accuracy being ±0.002 absorbance units.
[0056] The specific implementation of step S11 involves constructing a deep learning model. The sequence folding layer reorganizes one-dimensional data into a two-dimensional form, facilitating subsequent convolutional operations. The convolutional layers use 1×1 kernels, with 32 channels in the first layer and 64 in the second, employing the ReLU activation function. The global average pooling layer averages each feature map, compressing the spatial dimension. The channel attention layer contains two fully connected layers: the first layer has 1 / 16 the number of channels, and the second layer has the same number of channels, finally normalized using the sigmoid function. The defolding layer restores the two-dimensional features to a sequence form. The long short-term memory layer has 6 hidden units and uses the tanh activation function. The fully connected layers have 32 neurons and use the ReLU activation function. The regression layer outputs a single predicted value.
[0057] Step S12 involves evaluating feature importance. A random forest algorithm is used to calculate the importance score for each feature. The number of trees is set to 500, the maximum tree depth is the square root of the number of features, and the minimum number of splits is 2. An importance score matrix is formed by calculating the contribution of each feature to the model's performance improvement. The score ranges from 0 to 1, with values closer to 1 indicating greater importance.
[0058] The specific implementation of step S13 involves optimizing the model parameters. The initial weights of the channel attention layer are adjusted based on the feature importance matrix, with channels corresponding to features of higher importance receiving larger initial weights. The Adam optimizer is used to train the model, with an initial learning rate of 0.001, a batch size of 32, and 200 training epochs. An early stopping strategy is used to prevent overfitting; training stops when the validation set loss fails to improve for 10 consecutive epochs. The final model achieves a determination coefficient of no less than 0.75 and a root mean square error of no more than 0.18 on the test set.
[0059] Step S14 involves processing the test samples. The aforementioned image acquisition, feature extraction, and data preprocessing steps are repeated for the fresh tobacco leaves to be tested, ensuring that the processing method is completely consistent with the training samples. The generated multi-source feature fusion dataset has the same dimensions and scale as the training data.
[0060] The specific implementation of step S15 is to predict chlorophyll concentration. The multi-source feature fusion data of the sample to be tested is input into the trained model. The model automatically completes feature transformation and weight calculation, and outputs the predicted concentration value. The calculation time for the prediction process is usually no more than 1 second, enabling real-time prediction.
[0061] The key calculation processes and matrix representations involved in this scheme are explained below:
[0062] The method for calculating texture feature values based on the gray-level co-occurrence matrix is specifically expressed as follows:
[0063]
[0064] In the formula, F texture P is the composite value of texture features. ij E represents the elements of the gray-level co-occurrence matrix. ij Energy characteristic value; C ij H represents the contrast characteristic value. ij I is the entropy eigenvalue. ij Let be the eigenvalues of the moment of inertia; α1, α2, α3, and α4 are weighting coefficients, and satisfy . n represents the gray level.
[0065] The specific method for calculating the correlation coefficient in the Pearson correlation analysis is as follows:
[0066]
[0067] In the formula, r xy The correlation coefficient; x i y i These are the observed values of the two variables, respectively. These are the averages of the two variables; n is the sample size.
[0068] The specific method for calculating the feature fusion weight coefficients is as follows:
[0069]
[0070] W fusion =λ1W image +λ2W spectral ;
[0071] In the formula, W is the weight matrix; w ij W represents the weight of the i-th feature on the j-th output; fusion For fusion weights; W image Image feature weights; W spectral λ1 and λ2 are the spectral feature weights; λ1 and λ2 are the fusion coefficients, and λ1 + λ2 = 1.
[0072] The specific formula for calculating chlorophyll concentration is as follows:
[0073]
[0074] In the formula, C chl This represents the chlorophyll concentration value, expressed in milligrams per gram; A 649 A 665 The absorbance values are 649 nm and 665 nm, respectively; k1 and k2 are the absorption coefficients, with values of 18.16 and 6.63, respectively; V is the volume of the extract in liters; D is the dilution factor; m is the sample mass in grams; δ is the systematic error correction term, with a value ranging from 0.001 to 0.01.
[0075] The specific method for calculating the channel attention weights is as follows:
[0076]
[0077] α c =σ(W2δ(W1M) c ));
[0078] In the formula, M c For the global features of channel c; F c (i, j) represents the value of the feature map at position (i, j); H and W represent the height and width of the feature map, respectively; W1 and W2 are the weights of the fully connected layer; δ is the ReLU activation function; σ is the sigmoid function; α c This represents the channel attention weight.
[0079] The specific method for calculating the feature importance score is as follows:
[0080]
[0081] In the formula, Si The importance score for the i-th feature; ΔI ij denoted as , where is the reduction in impurity of feature i in decision tree j; T is the total number of decision trees; and n is the total number of features.
[0082] The principles and significance of constructing these equations are explained below:
[0083] 1. The texture feature value calculation equation comprehensively considers four main texture features: energy, contrast, entropy, and moment of inertia. It achieves adaptive feature fusion through weighting coefficients, which can more comprehensively describe image texture information.
[0084] 2. The Pearson correlation coefficient calculation equation measures the degree of linear correlation between variables through standardized covariance, with the value range limited to -1 to 1, which facilitates the judgment and comparison of correlation strength;
[0085] 3. The feature fusion weight matrix adopts a linear weighting method and introduces fusion coefficients to achieve adaptive fusion of image features and spectral features, which can dynamically adjust the weights according to the importance of different features;
[0086] 4. The chlorophyll concentration calculation equation is based on Beer-Lambert's law, takes into account the influence of experimental conditions such as sample mass and extraction volume, and introduces a systematic error correction term to improve the calculation accuracy.
[0087] 5. The channel attention weight calculation equation adopts a two-layer neural network structure, and obtains channel features through global average pooling to achieve adaptive learning of feature channel importance;
[0088] 6. The feature importance scoring equation is based on the random forest algorithm. It evaluates the importance of a feature by calculating the reduction in impurity of the feature across all decision trees, ensuring the reliability and stability of the scoring results.
[0089] The derivation process and parameter sources of each equation in this scheme are explained below:
[0090] Derivation of the equation for calculating texture feature values:
[0091] First, construct the gray-level co-occurrence matrix P. ij The statistical distribution of pixel pairs is obtained by scanning the image;
[0092] Then, the four basic characteristics are calculated separately: energy characteristics. Contrast characteristics Entropy features Moment of inertia characteristics
[0093] Finally, weighting coefficients are introduced for weighted fusion. The weighting coefficients are determined by minimizing the prediction error, with initial values set to 0.25. The optimal values are obtained through iterative optimization.
[0094] The advantage of this equation is that it comprehensively considers multiple texture features, and the weights can be adjusted according to specific application scenarios.
[0095] Derivation of the equation for calculating the Pearson correlation coefficient:
[0096] First, the original data is centered, and the deviation of each variable from its mean is calculated.
[0097] Then calculate the sum of the products of the deviations of the two variables, and use it as the numerator;
[0098] Calculate the square root of the sum of squares of the deviations of the two variables respectively, and use it as the denominator.
[0099] Finally, the correlation coefficient was normalized using fractional form to ensure that it was within the range of -1 to 1.
[0100] This equation can effectively eliminate the influence of dimensions and highlight the linear correlation between variables.
[0101] Derivation of the feature fusion weight matrix:
[0102] First, an initial weight matrix is constructed, with element values generated through random initialization.
[0103] Then, feature importance is calculated based on singular value decomposition: W = USV T , where S is the singular value matrix;
[0104] The fusion coefficient is determined based on the magnitude of the singular values: λ2=1-λ1, where σ i is the singular value, and k is the number of image features;
[0105] This equation enables adaptive feature fusion, dynamically adjusting weights based on feature importance.
[0106] Derivation of the equation for calculating chlorophyll concentration:
[0107] Based on Beer-Lambert's law, the relationship between absorbance and concentration is derived as: A = εbc;
[0108] Consider the dilution effect during sample extraction:
[0109] Introducing absorption coefficients at different wavelengths: k1 = 18.16 corresponds to a wavelength of 649 nm, and k2 = 6.63 corresponds to a wavelength of 665 nm;
[0110] Add a systematic error correction term δ, and determine its range by calibration with standard samples;
[0111] This equation takes into account the influence of experimental conditions, thus improving the accuracy of concentration determination.
[0112] Derivation of the equation for calculating channel attention weights:
[0113] First, global average pooling is used to compress the spatial dimension and extract channel-level features;
[0114] Then, a two-layer neural network structure was designed: the first layer reduced the dimensionality, with the number of neurons being 1 / 16 of the number of channels; the second layer increased the dimensionality, restoring the original number of channels.
[0115] The ReLU activation function provides non-linear transformation capabilities, while the Sigmoid function normalizes the weights to the range of 0 to 1.
[0116] This equation can adaptively learn the importance of different channels, thereby improving the efficiency of feature extraction.
[0117] Derivation of the feature importance score calculation equation:
[0118] Calculating node impurity based on the Gini coefficient:
[0119] Calculate the reduction in impurity before and after eigenvalue splitting:
[0120] The statistical feature represents the reduction in impurity across all decision trees, and is then normalized.
[0121] This equation improves the stability and reliability of feature importance assessment through early learning.
[0122] Additional notes on parameter acquisition methods:
[0123] The gray level n is determined by the image bit depth, with a typical value of 256.
[0124] The sample size n is determined according to the experimental design; in this scheme, it is 200.
[0125] The feature map sizes H and W are determined by the network structure, with a typical value of 32×32;
[0126] Setting the number of decision trees T to 500 achieves a balance between computational efficiency and model performance.
[0127] A second aspect of the present invention provides a computer-readable storage medium storing program instructions that, when executed in a computer, are used to perform the above-described method for predicting the chlorophyll concentration of fresh tobacco leaves.
[0128] A third aspect of the present invention provides a fresh tobacco leaf chlorophyll concentration prediction system, comprising the aforementioned computer-readable storage medium, wherein the system is any one of a computer, a server, or a microcontroller, the computer-readable storage medium is disposed within the system, and the system is provided with a microprocessor that executes program instructions stored in the computer-readable storage medium.
[0129] Specifically, the principle of this invention is based on multi-source information fusion and feature extraction capabilities of deep learning. At the data acquisition level, a standardized image acquisition environment and near-infrared spectroscopy measurement scheme are employed to ensure data consistency and reliability. Image data contains the morphological features and color information of the leaves, which are directly physically related to chlorophyll concentration, as changes in chlorophyll content directly affect the optical properties of the leaves. Spectral data reflects the molecular vibrations and chemical bonds of the leaf tissue, particularly the spectral response in the near-infrared region, which reveals changes in the internal structure of the leaves.
[0130] At the feature processing level, this invention employs a multi-level feature extraction and selection strategy. Image features are extracted through color space transformation and texture analysis, and background interference is eliminated using various spectral preprocessing methods. The feature selection process is based on correlation analysis between features and target variables and a recursive elimination strategy, ensuring the representativeness and effectiveness of the selected features. Feature fusion employs a matrix factorization-based method, which can capture the nonlinear relationships between features and reflects the essential characteristics of the data better than simple feature concatenation.
[0131] In terms of model structure design, this invention adopts a combined architecture of convolutional neural networks and long short-term memory networks, which can capture both the local correlation of features and handle the long-range dependencies between sequential features. The introduction of the channel attention mechanism enables the model to dynamically adjust weights according to the contribution of different features to the prediction results, improving the model's adaptability and prediction accuracy. The entire prediction process forms an end-to-end learning system, realizing the automatic mapping from raw data to prediction results.
[0132] The following provides a specific embodiment 1 of the present invention, and the specific implementation of each step in this embodiment 1 is described in detail below.
[0133] The specific implementation of step S01 involves acquiring high-quality fresh tobacco leaf image samples by constructing a standardized data acquisition environment. First, environmental parameters are set: the interior of the darkroom is coated with matte black paint, with a reflectivity of less than 3%; the LED light source has a color temperature of 5500K, an illuminance of 1000 lux, and a fluctuation range of ±50 lux. Four maturity levels of fresh tobacco leaves are determined: underripe, moderately ripe, adequately ripe, and mature. Fifty samples are collected for each level, for a total sample size of n = 200. Images are taken using a smartphone with a camera resolution of at least 12 megapixels. Shooting parameters are fixed as follows: ISO 100, shutter speed 1 / 60 second, aperture f / 2.0, and automatic white balance. The shooting distance is maintained at 30 cm, with an allowable error of ±1 cm, ensuring the leaf surface is perpendicular to the camera, with a perpendicularity error controlled within ±2 degrees. The acquired image resolution is 4000×3000 pixels, color depth is 24 bits, and the storage format is lossless compressed PNG. The purpose of this step is to establish a standardized image acquisition process to ensure the data quality for subsequent analysis. Image quality assessment metrics include: sharpness no less than 0.8 (normalized value), exposure uniformity deviation no more than ±0.2, and color saturation within the range of 0.4 to 0.8. The ambient temperature throughout the acquisition process is controlled at 25±2 degrees Celsius, and the relative humidity at 60%±5%.
[0134] The specific implementation of step S02 involves background segmentation and feature extraction of the acquired fresh tobacco leaf image. First, the RGB image is converted to the Ycbcr color space, and the conversion matrix is:
[0135]
[0136] The Y component represents luminance, with values ranging from 16 to 235, while the Cb and Cr components represent chrominance, with values ranging from 16 to 240. An adaptive thresholding method is used to process the Y component image, with an initial threshold T0 set to 128. The iterative update formula is as follows: Where μ1(T) k ) and μ2(T k ) are the thresholds T k The average gray values of the segmented foreground and background regions are used as the iteration termination condition, which is |T|. k+1 -T k |<0.5. After obtaining the binary mask, morphological operations are used to optimize the edges, including: using a circular structuring element with a radius of 3 pixels for opening operations to remove noise, and using a circular structuring element with a radius of 5 pixels for closing operations to fill small holes. Color features are calculated for the segmented image, including the mean values of the R, G, and B channels in the RGB space and the mean values of the L, a, and b channels in the Lab space. Texture features are calculated based on the gray-level co-occurrence matrix, and the formula for calculating texture feature values is:
[0137]
[0138] In this model, the gray level n is set to 256, the matrix distance parameter is 1, and the orientation angles are 0 degrees, 45 degrees, 90 degrees, and 135 degrees. The weight coefficients α1 to α4 are determined through cross-validation, with an initial value of 0.25 for each. The optimization objective is to minimize the prediction error. The main purpose of this step is to extract an image dataset that can characterize the features of fresh tobacco leaves, providing a foundation for subsequent feature selection. The calculated feature data needs to be normalized using the min-max normalization method. Where x min and x max These are the minimum and maximum values of the feature, respectively.
[0139] The specific implementation of step S03 involves evaluating the correlation between image features and chlorophyll concentration. Pearson correlation analysis is used, and the correlation coefficient is calculated using the following formula:
[0140]
[0141] Where, x i and y i These are the characteristic value and the chlorophyll concentration value, respectively. and The corresponding average value is given, and the sample size n is 200. Features are categorized into three levels based on the absolute value of the correlation coefficient: weak correlation (less than 0.3), moderate correlation (0.3 to 0.5), and strong correlation (greater than 0.5). A feature correlation matrix R = [r...] is constructed. ij ] m×m , where r ij Let represent the correlation coefficient between the i-th feature and the j-th feature, and m be the total number of features. Feature clustering is used to address collinearity: when the absolute value of the correlation coefficient between two features is greater than 0.8, the feature with a stronger correlation to chlorophyll concentration is retained.
[0142] The specific implementation of step S04 involves using a recursive feature elimination method for feature selection. This method constructs a feature importance evaluation model based on support vector machines, and the kernel function is a radial basis function.
[0143] K(x i x j )=exp(-γ||x i -x j || 2 );
[0144] The kernel parameter γ is set to 0.1, and the penalty parameter C is set to 100. The feature importance score is calculated using the following formula:
[0145]
[0146] Among them, w ij Let be the weight coefficient of the i-th feature on the j-th classification surface, and k be the number of classification surfaces. In each iteration, the feature with the lowest importance score is removed, the model is retrained, and its performance is evaluated. Model performance is evaluated using 5-fold cross-validation, and the performance metric is root mean square error.
[0147]
[0148] Among them, y i For the true value, The predicted value is used. The feature set with the smallest root mean square error on the validation set is selected as the preferred feature set, and the number of features is usually reduced from the initial 20 to 5 to 8.
[0149] The specific implementation of step S05 involves acquiring near-infrared spectral data. A near-infrared spectrometer is used, with a wavelength range of 900 to 1700 nanometers and a sampling interval of 2 nanometers, resulting in 401 wavelength points. Fresh tobacco leaf samples are placed flat on the stage, ensuring close contact between the leaf surface and the detection window. Measurement points are set at the leaf tip, middle, and both sides of the leaf base, with a distance of at least 5 millimeters from the midrib and secondary veins. Each measurement point is sampled three times, with a 10-second interval between adjacent scans to eliminate the influence of instrument noise. During the acquisition process, the ambient temperature is maintained at 25 ± 2 degrees Celsius, and the relative humidity at 60% ± 5%, avoiding interference from external light sources. The three spectral data points for each measurement point are averaged.
[0150]
[0151] Among them, S p S is the average spectrum at measurement point p. pi This represents the spectral data acquired in the i-th measurement. Then, the arithmetic mean of the six measurement points is calculated as the initial near-infrared spectral data for this tobacco leaf:
[0152]
[0153] The specific implementation of step S06 involves preprocessing the initial near-infrared spectral data. First, a normalization method is used for processing:
[0154]
[0155] Where X represents the original spectral data, X min and X max These represent the minimum and maximum values of the spectral data, respectively. Then, the standard normal variable transformation method is applied:
[0156]
[0157] Among them, Xi Let be the absorbance value at the i-th wavelength. Here, n represents the sample mean, and n is the number of wavelength points. Finally, the multivariate scattering correction method is used, and the calculation formula is:
[0158] X msc = a + bX;
[0159] Where a and b are regression coefficients, solved using the least squares method:
[0160]
[0161] Among them, X ref For reference spectra, the average spectrum of all samples is typically chosen. The preprocessed spectral data matrix has dimensions of m×n, where m is the number of samples and n is the number of wavelength points.
[0162] The specific implementation of step S07 involves extracting key features from the preprocessed spectral data. The competitive adaptive reweighting algorithm achieves feature selection through Monte Carlo sampling and exponentially decaying weights. The number of samplings N is set to 500, and the weight decay coefficient β is set to 0.95. The weight update formula for each iteration is as follows:
[0163]
[0164] in, p is the weight of the i-th feature in the t-th iteration. i The penalty factor is used. The continuous projection algorithm selects the wavelength point through orthogonal projection, and the projection matrix is calculated using the following formula:
[0165] P = IX(X) T X) -1 X T ;
[0166] Where I is the identity matrix and X is the data matrix of selected wavelength points. The sparse representation algorithm uses LASSO regression to achieve feature compression, and the objective function is:
[0167]
[0168] Where y is the response variable, β is the regression coefficient, and λ is the regularization parameter, the optimal value is determined through cross-validation.
[0169] The specific implementation of step S08 involves calculating the interaction relationships between features. First, the image features and spectral features are standardized, and then the feature interaction matrix is calculated:
[0170] M = XX T ;
[0171] Where X is the standardized feature matrix. Singular value decomposition is then performed on this matrix:
[0172] M=U∑V T ;
[0173] Where U and V are the left and right singular vector matrices, and ∑ is the singular value diagonal matrix. The importance of features is determined based on the magnitude of the singular values, and the cumulative contribution rate is calculated:
[0174]
[0175] Where, σ i For the i-th singular value, select the top k features that make the cumulative contribution rate reach 85%.
[0176] The specific implementation of step S09 is based on feature fusion using fusion weight coefficients. The formula for calculating the weight coefficient matrix is as follows:
[0177]
[0178] Among them, w ij This represents the weight of the i-th feature in relation to the j-th output. The fusion process uses vector multiplication.
[0179] F = X1W1 + X2W2;
[0180] Where X1 and X2 are the image feature vector and spectral feature vector, respectively, and W1 and W2 are the corresponding weight matrices.
[0181] The specific implementation of step S10 involves establishing a dataset of measured chlorophyll concentrations. Chlorophyll concentrations are measured using a spectrophotometer at wavelengths of 649 nm and 665 nm, with a measurement accuracy of ±0.002 absorbance units. The formula for calculating chlorophyll concentration is:
[0182]
[0183] Where k1 and k2 are 18.16 and 6.63 respectively, V is the extraction liquid volume, D is the dilution factor, m is the sample mass, and δ is the systematic error correction term. Each sample was measured three times, and the average value was taken as the final result.
[0184] The specific implementation of step S11 is to construct a deep learning model. Sequence folding layers reorganize one-dimensional input data into a two-dimensional form:
[0185] X reshape =reshape(X,[batch,height,width,channel]);
[0186] Here, `batch` is the batch size, set to 32; `height` and `width` are determined by the feature dimensions; and `channel` is initially set to 1. The convolutional layer uses a 1×1 convolutional kernel for feature extraction. The mathematical expression for the convolution operation is:
[0187]
[0188] Among them, W i Here, is the kernel weight, b is the bias term, the number of channels in the first layer is set to 32, and the number of channels in the second layer is 64. The formula for calculating the global average pooling layer is:
[0189]
[0190] Among them, X c Let H be the feature map of the c-th channel, and H and W be the height and width of the feature map. The formula for calculating the weights of the channel attention layer is:
[0191] α c =σ(W2δ(W1F) c ));
[0192] Where W1 and W2 are the weight matrices of the fully connected layer, δ is the ReLU activation function, and σ is the sigmoid function.
[0193] The specific implementation of step S12 involves establishing a feature importance scoring matrix. Feature importance is calculated based on the random forest algorithm, and the scoring formula is as follows:
[0194]
[0195] Among them, S i For the importance score of the i-th feature, ΔI ij Let T be the reduction in impurity of feature i in decision tree j, where T is the total number of decision trees (set to 500) and n is the total number of features. Impurity is calculated using the Gini coefficient.
[0196]
[0197] The reduction in impurity before and after the characteristic split is:
[0198]
[0199] The specific implementation of step S13 is to optimize the model parameters. The weights of the channel attention layer are adjusted according to the feature importance matrix, using the following formula:
[0200] w new =w old ×(1+αS);
[0201] Among them, w oldLet S be the original weights, S be the feature importance score, and α be the adjustment coefficient, ranging from 0.1 to 0.5. The Adam optimizer is used to train the model, with an initial learning rate η of 0.001, momentum parameters β1 and β2 of 0.9 and 0.999 respectively. The weight update formula is as follows:
[0202] m t =β1m t-1 +(1-β1)g t ;
[0203]
[0204] Among them, g t Let ∈ be the gradient, and ∈ be the numerical stability constant, set to 10. -8 .
[0205] The specific implementation of step S14 involves processing the test sample. The aforementioned feature extraction process is repeated on the fresh tobacco leaves to be tested to generate a multi-source feature fusion data matrix for the test sample:
[0206] X test = [x1, x2, ..., x n ];
[0207] Where, x i Let be the value of the i-th feature, and n be the total number of features. Normalization is then performed.
[0208]
[0209] Where μ and δ are the mean and standard deviation of the corresponding features in the training set, respectively.
[0210] The specific implementation of step S15 is to predict chlorophyll concentration. The standardized features are input into the trained model, and the predicted value is calculated using the following formula:
[0211] y pred =f(W n f(W n-1 …f(W1x)));
[0212] Among them, W i Let f be the weight matrix of the i-th layer, and f be the activation function. The final predicted output needs to be denormalized.
[0213] y final =y pred ×δ y +μ y ;
[0214] Where, δ y and μ y The standard deviation and mean of chlorophyll concentration in the training set are used. The confidence interval for the prediction results is:
[0215] [y final -1.96σ error y final +1.96σ error ];
[0216] Where, σ error This represents the standard error of the model's predictions on the validation set.
[0217] To better understand and implement this invention, the following is a specific application scenario of this invention, Example 2:
[0218] A tobacco research institute conducted a study on the rapid detection of chlorophyll concentration in fresh tobacco leaves. The study selected fresh tobacco leaves of two mainstream varieties, K326 and ZC100, from the Yunnan-Guizhou region as the research subjects, and conducted sampling and analysis at different stages of their growth. The specific implementation process is as follows:
[0219] The sample collection phase was meticulously controlled. Sampling was conducted on a sunny morning between 9:00 AM and 11:00 AM at a standardized planting base in the Yuxi tobacco region of Yunnan Province, covering an area of 20 hectares. Fifty fresh tobacco leaves from each of the K326 and ZC100 varieties were collected at four stages: underripe, partially ripe, moderately ripe, and mature, for a total of 400 samples. Sampling was performed on the 8th to 12th leaves from the middle of the tobacco plant, removing leaves damaged by pests, diseases, or mechanical damage. The collected samples were immediately placed in a temperature- and humidity-controlled incubator, set at 25 ± 1 degrees Celsius and 65% ± 3% relative humidity, with transportation time limited to within 30 minutes.
[0220] The image acquisition environment was standardized. A professional darkroom measuring 80cm × 60cm × 60cm was used, with the inner walls treated with a matte black coating with a reflectivity of less than 3%. A 5500K LED ring light was used as the light source, and the illuminance was adjusted to 1000±20 lux using a professional lux meter. A Samsung Galaxy S21 Ultra was used for shooting, with a 108MP camera. Shooting parameters were set as follows: ISO 100, shutter speed 1 / 60 second, aperture f / 2.2, auto white balance, and resolution 4000×3000 pixels. The shooting distance was controlled at 30±0.5cm using a laser rangefinder. The sample was laid flat on an anti-reflective black background, and a level was used to ensure the leaf surface was perpendicular to the lens within ±1 degree.
[0221] Image preprocessing employs a multi-step strategy. First, color space conversion is performed, transforming the RGB image to the Ycbcr color space. The conversion matrix is as follows:
[0222]
[0223] Adaptive threshold segmentation is performed on the Y component, with the initial threshold T0 set to 128. The iterative update formula is as follows:
[0224]
[0225] Where μ1(T) k ) and μ2(T k ) are the thresholds T k The average gray values of the segmented foreground and background regions, when satisfying |T k+1 -T k Iteration stops when |<0.5. The segmented image undergoes morphological processing to optimize edges, uses a circular structuring element with a radius of 3 pixels for opening operations to remove noise, and uses a circular structuring element with a radius of 5 pixels for closing operations to fill small holes.
[0226] The feature extraction process involves multiple dimensions. It extracts the mean values of the R, G, and B channels in the RGB space, and the mean values of the L, a, and b channels in the Lab space, calculating composite feature values such as 2G-RB, R / G, GR, and a / b. Texture features are calculated based on the gray-level co-occurrence matrix, including energy, average gray level, average gradient, gray-level non-uniformity, gradient non-uniformity, correlation, gray-level entropy, gradient entropy, moment of inertia, and inverse difference moment. The formula for calculating the comprehensive texture feature value is:
[0227]
[0228] The weighting coefficients, after optimization through cross-validation, were determined to be: α1 = 0.32, α2 = 0.28, α3 = 0.24, and α4 = 0.16.
[0229] Spectral data acquisition employed a precise positioning scheme. Near-infrared spectral data were acquired using an ASD FieldSpec 4 spectrometer, covering a wavelength range of 900 to 1700 nm, with a sampling interval of 1 nm and a spectral resolution of 2 nm, resulting in data from 801 wavelength points. Measurement points were set at the tip, middle, and both sides of the base of each tobacco leaf. A laser positioning device was used to ensure that the distance between the measurement point and the midrib and side veins was greater than 5 mm. Each point was scanned three times with a 10-second interval, and the average value was taken as the spectral data for that point. The formula for calculating the average spectrum is:
[0230]
[0231] The spectral data preprocessing employs a strategy combining three methods. First, normalization is performed:
[0232]
[0233] Eliminate the influence of dimensions. Then perform a standard normal transformation:
[0234]
[0235] To reduce the impact of noise, a multivariate scattering correction method is finally used.
[0236] X msc = a + bX,
[0237] The regression coefficients are calculated using the least squares method:
[0238]
[0239] The feature selection process employs a multi-step screening strategy. First, Pearson correlation analysis is used to calculate the correlation coefficient between the feature and chlorophyll concentration:
[0240]
[0241] Features with an absolute correlation coefficient greater than 0.3 were retained as candidate features. Then, a competitive adaptive reweighting algorithm was used for feature extraction, with 500 sampling iterations, a weight decay coefficient of 0.95, and the weight update formula as follows:
[0242]
[0243] Simultaneously, a continuous projection algorithm is used to select wavelength points, and the projection matrix is calculated as follows:
[0244] P = IX(X) T X) -1 X T .
[0245] Feature fusion employs an adaptive weighting method based on matrix factorization. First, a feature interaction matrix is constructed:
[0246] M = XX T ,
[0247] Then perform singular value decomposition:
[0248] M=U∑V T .
[0249] Calculate the cumulative contribution rate based on singular values:
[0250]
[0251] Feature combinations with a cumulative contribution rate of 85% are selected. The fusion weight coefficient is calculated using the following formula:
[0252] W fusion =λ1W image +λ2W spectral ,
[0253] λ1 and λ2 are dynamically adjusted according to the importance of the features, with initial values set to 0.45 and 0.55 respectively.
[0254] Chlorophyll concentration was determined using a spectrophotometer. 0.2 g of sample was added to 25 mL of 95% ethanol and extracted for 24 hours at 4°C in the dark. The absorbance was measured at wavelengths of 649 nm and 665 nm using a UV-2600 spectrophotometer. Measurements were repeated three times, and the average value was taken. The formula for calculating chlorophyll concentration is:
[0255]
[0256] Where V is the volume of the extract (0.025 L), D is the dilution factor (1), m is the sample mass (0.2 g), and δ is the systematic error correction term, ranging from 0.001 to 0.01.
[0257] Deep learning model construction employs a multi-module combination strategy. Sequence folding layers reorganize one-dimensional features into a two-dimensional form:
[0258] X reshape =reshape(X,[32,8,8,1]).
[0259] The two convolutional layers use 1×1 convolutional kernels with 32 and 64 channels respectively, and the activation function is ReLU. The global average pooling layer is calculated as follows:
[0260]
[0261] The channel attention layer weights are calculated as follows:
[0262] α c =σ(W2δ(W1F) c )).
[0263] The long short-term memory layer has 6 hidden units and uses the tanh activation function.
[0264] The model training parameters are set as follows:
[0265] 1. The optimizer used is Adam, with an initial learning rate of 0.001;
[0266] 2. Batch size 32, training epochs 200;
[0267] 3. Employ an early stopping strategy: stop training when the validation set loss fails to improve for 10 consecutive rounds.
[0268] 4. The loss function uses root mean square error:
[0269]
[0270] The experimental results are shown in Table 1-3 below:
[0271] Table 1. Predicted chlorophyll concentration results for different varieties at different maturity stages.
[0272] K326 immature 50 3.85 3.92 1.79 0.932 K326 Still familiar 50 3.18 3.24 1.85 0.928 K326 ripe 50 2.45 2.51 2.39 0.921 K326 Mature 50 1.88 1.93 2.59 0.915 ZC100 immature 50 3.76 3.82 1.57 0.935 ZC100 Still familiar 50 3.12 3.18 1.89 0.927 ZC100 ripe 50 2.38 2.44 2.46 0.918 ZC100 Mature 50 1.82 1.87 2.67 0.912
[0273] Table 2 Comparison of model performance with different feature combinations and algorithms
[0274] Image features BP neural network 0.285 0.232 0.845 Image features SVM 0.276 0.225 0.852 Image features CNN-LSTM 0.245 0.198 0.876 Spectral characteristics BP neural network 0.256 0.208 0.862 Spectral characteristics SVM 0.248 0.201 0.868 Spectral characteristics CNN-LSTM 0.218 0.175 0.892 Feature fusion BP neural network 0.198 0.162 0.901 Feature fusion SVM 0.189 0.155 0.908 Feature fusion CNN-LSTM 0.175 0.138 0.923
[0275] Table 3 Comparison of feature extraction effects of different spectral preprocessing methods
[0276] Normalization CARS 0.245 0.868 Normalization SPA 0.238 0.875 Normalization LASSO 0.232 0.882 SNV CARS 0.228 0.885 SNV SPA 0.225 0.888 SNV LASSO 0.221 0.892 MSC CARS 0.218 0.895 MSC SPA 0.212 0.898 MSC LASSO 0.208 0.902
[0277] Compared with traditional technologies, this embodiment has the following significant advantages:
[0278] 1. In terms of detection efficiency: Traditional chemical extraction methods require multiple steps such as sample pretreatment, extraction, and determination, taking 2 to 3 hours in total, and requiring a professional laboratory environment and technical personnel. This method can complete the detection of a sample in only 4 to 6 minutes, greatly improving detection efficiency.
[0279] 2. Regarding detection accuracy: The relative error of portable chlorophyll meters is typically between 8% and 12%, while the relative error using image analysis or spectral analysis alone is between 4% and 6%. This method, through multi-source feature fusion and a deep learning model, controls the relative error to within 3%, significantly improving detection accuracy.
[0280] 3. Generality: This method achieved good predictive results for both K326 and ZC100, indicating its strong generality. The prediction results for different maturity stages maintained high accuracy, demonstrating the method's strong adaptability to sample variation.
[0281] 4. Practicality: This method adopts a standardized data acquisition process, is simple to operate, has low equipment requirements, and is easy to promote and apply. It automates feature extraction and prediction through a deep learning model, eliminating the need for manual intervention and improving the reliability and stability of detection.
[0282] Technical Results Summary: This embodiment successfully solved the technical problem of rapid and accurate prediction of chlorophyll concentration in fresh tobacco leaves. By innovatively fusing image and spectral features, a complete method for feature extraction, selection, fusion, and prediction was established. This method not only ensures rapid detection but also achieves high-precision prediction, providing strong technical support for quality evaluation and harvesting decisions in tobacco production.
[0283] The following is a specific application scenario of the present invention, embodiment 3: (Refer to...) Figure 2 As shown, the chlorophyll concentration prediction method in Example 3 includes the following steps:
[0284] S1. Collect fresh tobacco leaves at different stages, take photos to obtain images, and then perform preprocessing and extract image features. The specific steps are as follows:
[0285] S1.1. Take 50 fresh tobacco leaves each of the four stages of immature, semi-mature, moderately mature and mature, number the tobacco leaves, and then put them into a dark box in sequence and take pictures with a smartphone. The parameters remain unchanged during the taking process.
[0286] S2.2. The acquired image is processed using MATLAB's built-in color segmenter based on the Ycbcr color space to remove background and reduce redundant information in the image;
[0287] S2.3. Using an algorithm, based on the R, G, B, L, a, b color channels, extract the R, G, B, L, a, b color feature values of the corresponding image, and then perform combination operations to obtain the 2G-RB, R / G, GR, and a / b feature values.
[0288] S2.4. Using the algorithm, based on the gray-level co-occurrence matrix, extract the corresponding image energy, gray-level average, gradient average, gray-level non-uniformity, gradient non-uniformity, correlation, gray-level entropy, gradient entropy, moment of inertia, and inverse difference moment feature values;
[0289] S2.5. A total of 20 image features are extracted from S2.2 and S2.3 above. The feature selection method is used to reduce the dimensionality of the image features. The dimensionality reduction process specifically includes the following steps:
[0290] S2.5.1. Using Pearson correlation analysis, the correlation coefficients between 20 image features and the measured values of chlorophyll concentration were analyzed, and features with moderate or higher correlation were retained.
[0291] S2.5.2. Using the recursive feature elimination method, the number of variables to be retained is set to 1-19;
[0292] S2.5.3. Input the features obtained by Pearson correlation analysis and recursive feature elimination, along with the corresponding measured chlorophyll concentration values, into the BP model for training. The training results for different features are as follows: Figure 5 As shown, features with good training model performance are selected as the image feature dataset.
[0293] S2. Near-infrared spectral features of tobacco leaves at 900-1700 nm were collected sequentially, totaling 228 wavelength points. The original spectra were then denoised using preprocessing methods. Three algorithms were then used to extract key near-infrared spectral features. The specific steps are as follows:
[0294] S2.1. Measure the near-infrared spectral characteristic value of each tobacco leaf in sequence. Measure 6 points on each tobacco leaf, located at the leaf tip, leaf middle and leaf base on both sides of the tobacco leaf. Avoid the main vein and branch veins during measurement. Take the average value of the six points as the near-infrared spectral characteristic value of the tobacco leaf.
[0295] S2.2. The original spectrum is preprocessed using three methods: normalization (NOR), standard normal variable transformation (SNV), and multivariate scattering correction (MSC) to remove noise from the original spectrum.
[0296] S3.3. Competitive Adaptive Reweighting (CARS), Continuous Projection (SPA), and Sparse Representation-based (Lasso) algorithms were used to extract key near-infrared spectral features from the above three preprocessed spectra, resulting in nine combinations: NOR-CARS, NOR-SPA, NOR-Lasso, SNV-CARS, SNV-SPA, SNV-Lasso, MSC-CARS, MSC-SPA, and MSC-Lasso.
[0297] S4.4. Input the obtained 9 combinations of data and the corresponding measured values of chlorophyll concentration into the BP training model. The training results are as follows: Figure 6 As shown, the best-performing data was selected as the near-infrared spectral feature dataset.
[0298] S3. The image feature dataset and the near-infrared spectral dataset are fused using vector multiplication to obtain a fused feature dataset. The fusion process is as follows: Figure 4 As shown.
[0299] S4. The chlorophyll concentration of fresh tobacco leaf samples was determined using a spectrophotometer. 0.2g of fresh tobacco leaves were taken from each sample and soaked in a 95% alcohol solution as the test solution. The test solution was placed in a dark place until the tobacco leaves turned white. A portion of the test solution was placed in a cuvette and the absorbance was measured at wavelengths of 649nm and 665nm using a spectrophotometer. The chlorophyll concentration was calculated according to the formula, and a dataset of measured chlorophyll concentration values was constructed.
[0300] Chlorophyll content = (18.16A) 649 +6.63A 665 × Extract volume × Dilution factor / Sample fresh weight
[0301] Among them, A 649 and A 665 The absorbance of the solution at wavelengths of 649 nm and 665 nm is given. In this invention, the extraction volume is 0.025 L, the dilution factor is 1, and the fresh weight of the sample is 0.2 g.
[0302] S5. Construct a combined CNN and LSTM model, and add a dot product attention mechanism. The model structure is as follows: Figure 3 As shown, the specific steps are as follows:
[0303] S5.1 consists of an input layer and a sequence folding layer, which are used to adjust the input sequence data to 2D, making it compatible with 2D convolution.
[0304] S5.2. Then add two convolutional layers with a kernel size of 1×1 and 32 and 64 channels respectively. Then use the ReLU activation function to extract the local features of the input using the two convolutional layers.
[0305] S5.3. Use global average pooling to generate a global description for each channel, then use two fully connected layers to generate attention weights. Finally, normalize the weights using the sigmoid function to serve as channel attention weights. Finally, multiply the channel attention weights element-wise with the convolutional features to implement the attention mechanism, and finally output the feature map.
[0306] S5.4. The weighted feature map is restored to sequence data through the defolding layer, and then input into the LSTM layer for processing. The LSTM hidden unit is set to 6, and the state of the last time step is output.
[0307] S5.5. Finally, set up fully connected layers and regression layers to map the features extracted by LSTM to the output of the regression task. This completes the construction of the CNN-LSTM model.
[0308] S6. Train a CNN-LSTM model based on image features, near-infrared spectral features, and fused features. Train CNN, LSTM, BP, and SVM models based on fused features, and evaluate their performance. The specific steps are as follows:
[0309] S6.1. Train and validate the CNN-LSTM model using image feature datasets, near-infrared spectral feature datasets, and fused feature data along with their corresponding measured chlorophyll concentration datasets. The ratio of training to test sets is 7:3. Use the coefficient of determination (R²) and root mean square error (RMSE) to evaluate the models built with the three different datasets. Each model is trained 16 times. The formulas for calculating the R² and RMSE are as follows:
[0310]
[0311] Where n is the number of samples, y i These are measured values. For predicted values, This represents the average of the measured values.
[0312] S6.2. Train and validate CNN-LSTM, CNN, LSTM, BP, and SVM models using the fused feature dataset and the corresponding measured chlorophyll concentration dataset. The ratio of training set to test set is 7:3. Use the coefficient of determination, mean absolute error, and root mean square error to evaluate the models with different structures. The formula for calculating the mean absolute error (MAE) is as follows:
[0313]
[0314] Where n is the number of samples, y i These are measured values. These are predicted values.
[0315] In this embodiment, the model validation results trained on three different datasets are as follows: Figures 7-9 As shown, the validation results indicate that the R² of the model based on feature fusion is 0.75833, which is greater than the R² of the model based on image features and near-infrared spectral features. The RMSE of the model based on fused features is 0.17482, comparable to the RMSE of the model based on image features, but lower than the RMSE of the model based on near-infrared spectral features. These results demonstrate that using a feature model built by fusing image features and near-infrared spectral features can improve the model's predictive ability.
[0316] The model validation results based on fusion feature training are shown in Table 4. The validation results show that the CNN-LSTM model has higher prediction performance, lower prediction error and prediction bias than the single model (R2 = 0.74763, MAE = 0.13809, RMSE = 0.17721).
[0317] Table 4. Evaluation results of CNN-LSTM, CNN, LSTM, BP, and SVM models
[0318] CNN-LSTM 0.74763±0.03136a 0.13809±0.00458c 0.17721±0.01500c CNN 0.71633±0.03395a 0.14368±0.01152bc 0.18846±0.01313bc LSTM 0.63592±0.12233c 0.16019±0.03073ab 0.20638±0.03739ab BP 0.64944±0.09055bc 0.16999±0.02736a 0.22552±0.03665a SVM 0.70320±0.04369ab 0.14715±0.00732bc 0.19627±0.01050bc
[0319] It should be noted that the variables involved in this invention are explained in detail in Table 5 below.
[0320] Table 5. Variable Explanation Table
[0321]
[0322]
[0323] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A fresh tobacco leaf chlorophyll concentration prediction method based on convolutional neural network and feature fusion, characterized in that, Includes the following steps: S01. Collect 50 fresh tobacco leaf samples at each of the four stages of immature, semi-mature, moderately mature, and mature. Take photos of the fresh tobacco leaf samples using a smartphone in a darkroom environment to obtain images of the fresh tobacco leaves. S02. Use the color segmentation method based on the Ycbcr color space to perform background segmentation on the fresh tobacco leaf image, extract the feature values of the R, G, B, L, a, and b color channels and the texture feature values based on the gray-level co-occurrence matrix, and generate an initial image feature dataset. S03. Calculate the correlation coefficients between each feature value and chlorophyll concentration in the initial image feature dataset based on Pearson correlation analysis, and construct a feature correlation matrix; S04. The feature correlation matrix is processed using the recursive feature elimination method, and the feature combination with the best training performance is selected to form an optimal image feature dataset. S05. Collect near-infrared spectral data of the fresh tobacco leaf sample in the 900 to 1700 nanometer band. Collect 6 measurement points on both sides of the leaf tip, leaf middle and leaf base of the fresh tobacco leaf sample, avoiding the main vein and branch veins, and calculate the average value of the 6 measurement points as the initial near-infrared spectral data. S06. The initial near-infrared spectral data are preprocessed using the normalization method, the standard normal variable transformation method, and the multivariate scattering correction method to generate a preprocessed spectral data matrix. S07. The preprocessed spectral data matrix is subjected to feature extraction using the competitive adaptive reweighting algorithm, the continuous projection algorithm, and the sparse representation algorithm, respectively. The feature combination with the best training performance is selected to generate the preferred spectral feature dataset. S08. Calculate the feature interaction matrix between the preferred image feature dataset and the preferred spectral feature dataset, and determine the fusion weight coefficients based on matrix decomposition; S09. Perform vector multiplication and fusion on the preferred image feature dataset and the preferred spectral feature dataset according to the fusion weight coefficient to generate a multi-source feature fusion dataset; S10. The absorbance of the fresh tobacco leaf sample was measured at wavelengths of 649 nm and 665 nm using a spectrophotometer, and a chlorophyll concentration measurement dataset was generated based on the chlorophyll content calculation formula. S11. Construct a combined model of convolutional neural network and long short-term memory network, wherein the combined model includes sequence folding layer, convolutional layer, global average pooling layer, channel attention layer, defolding layer, long short-term memory layer, fully connected layer and regression layer; S12. Establish the importance score matrix of each feature in the multi-source feature fusion dataset; S13. Adjust the channel attention layer weights of the combined model according to the importance scoring matrix, and train the combined model using the multi-source feature fusion dataset and the measured chlorophyll concentration dataset to obtain the chlorophyll concentration prediction model. S14. Obtain the fresh tobacco leaves to be tested, and repeat steps S01 to S09 to generate a multi-source feature fusion dataset of the fresh tobacco leaves to be tested. S15. Input the multi-source feature fusion dataset of the fresh tobacco leaves to be tested into the chlorophyll concentration prediction model, and output the predicted value of chlorophyll concentration of the fresh tobacco leaves to be tested. Specifically, the step of determining the fusion weight coefficients based on matrix factorization involves calculating the correlation coefficient between each feature value and chlorophyll concentration in the initial image feature dataset using Pearson correlation analysis, constructing a feature correlation matrix, processing the feature correlation matrix using recursive feature elimination, selecting the feature combination with the best training performance, and forming an optimized image feature dataset. The specific calculation method for the fusion weight coefficient is as follows: ; ; wherein is a weight matrix; is a weight of the th feature to the th output; is a fusion weight; is an image feature weight; is a spectral feature weight; is a fusion coefficient, and ; The specific formula for calculating chlorophyll concentration is as follows: ; wherein is the chlorophyll concentration value in milligrams per gram; are the absorbance values at 649 nm and 665 nm wavelength, respectively; are the absorption coefficients, taking values of 18.16 and 6.63, respectively; is the extraction liquid volume in liters; is the dilution factor; is the sample mass in grams; is the system error correction term, taking values in the range of 0.001 to 0.01; The specific method for calculating channel attention weights is as follows: ; ; In the formula, For channel Global features; For feature map at location The value at; These are the height and width of the feature map, respectively; These are the weights for the fully connected layer; It is the ReLU activation function; It is the sigmoid function; This represents the channel attention weight.
2. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program instructions, which, when executed in a computer, are used to perform the method for predicting the chlorophyll concentration of fresh tobacco leaves as described in claim 1.
3. A system for predicting chlorophyll concentration in fresh tobacco leaves, characterized in that, The system includes the computer-readable storage medium of claim 2, wherein the system is any one of a computer, a server, or a microcontroller, the computer-readable storage medium is disposed within the system, and the system is provided with a microprocessor that executes the program instructions stored in the computer-readable storage medium.
Citation Information
Patent Citations
Tobacco leaf classification method based on spectrum and machine vision coupling
CN110705655A
Denitration system gas concentration prediction method, device, equipment and storage medium
CN116312861A
Wine geographical indication product identification method and system
CN117351316A
Fresh tobacco leaf maturity discrimination method, medium and system based on information fusion
CN118501088A