A nondestructive testing method for strawberry quality by fusing image and spectral features
By fusing image and spectral features and using hybrid modeling methods, the accuracy and cost issues of strawberry quality detection have been solved, enabling efficient, non-destructive detection and accurate prediction of strawberry internal quality.
Patent Information
- Application Number
- CN202610654659.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-13
- Publication Date
- 2026-11-06
- Estimated Expiration
- 2046-05-13
AI Technical Summary
Existing strawberry quality testing technologies suffer from insufficient accuracy, difficulty in achieving non-destructive testing, high costs, insufficient generalization ability of single-spectral detection models, and high complexity in fusing image and spectral information.
By employing image normalization, three-point spectral acquisition and averaging, spectral smoothing and noise reduction and outlier removal, spectral feature learning and image feature extraction, feature-level fusion, and a hybrid modeling method based on partial least squares regression and random forest, the prediction of internal quality indicators of strawberries is achieved.
It improves the accuracy and stability of internal quality detection of strawberries, reduces the interference of complex backgrounds, light fluctuations, spectral noise and abnormal samples on the model, improves the effectiveness of feature expression and model calculation efficiency, and enhances the prediction accuracy of indicators such as soluble solids, pH, and hardness.
Smart Images

Figure CN122595074B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of agricultural product quality testing technology, and in particular to a non-destructive testing method for strawberry quality that integrates image and spectral features. Background Technology
[0002] With the development of fruit and vegetable quality testing and intelligent sorting technologies, rapid assessment of the internal quality of fragile fruits such as strawberries has become an important application scenario in agricultural production and circulation. Currently, strawberry quality testing relies heavily on manual experience judgment or single information analysis methods based on spectral data, combined with chemical testing methods to obtain physicochemical indicators.
[0003] Existing strawberry quality testing technologies still have significant limitations in terms of accuracy and application efficiency. On the one hand, methods based on human sensory judgment are highly subjective and difficult to standardize, while traditional chemical testing methods, although highly accurate, suffer from long testing cycles, high costs, and sample damage, making them unsuitable for large-scale non-destructive testing. On the other hand, single-spectral detection methods can only reflect the average chemical information of a local area, making it difficult to characterize the spatial distribution differences within the fruit. Furthermore, they are easily affected by changes in sample size, color, and surface condition, resulting in insufficient model generalization ability. While hyperspectral imaging can fuse spatial and spectral information, its high equipment cost, large data redundancy, and high processing complexity limit its practical application. Therefore, the key challenge is how to effectively fuse image and spectral information under low-cost conditions and improve the accuracy and stability of strawberry internal quality testing.
[0004] Therefore, how to provide a non-destructive testing method for strawberry quality that integrates image and spectral features is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0005] One objective of this invention is to propose a non-destructive testing method for strawberry quality that integrates image and spectral features. By introducing image standardization processing, three-point spectral acquisition and averaging processing, spectral smoothing and noise reduction and outlier sample removal, spectral feature learning and image feature extraction, feature-level fusion, and a hybrid modeling method based on partial least squares regression and random forest, the method can predict internal quality indicators of strawberries such as soluble solids content, pH, and firmness.
[0006] A non-destructive testing method for strawberry quality based on the fusion of image and spectral features according to an embodiment of the present invention includes the following steps: S1. Number and register multiple varieties of strawberries and enter their information, record the cold storage and rewarming time parameters, and form a set of samples to be tested; S2. Acquire strawberry RGB images, use the mobile terminal camera component to obtain sample image data, perform background segmentation, scale unification and illumination normalization on the image data, and generate standardized image data. S3. Collect near-infrared spectral data. Under constant temperature and light conditions, set up three equiangularly spaced collection positions along the equatorial direction of strawberry, acquire three spectral curves respectively, and calculate the average spectrum to form the average spectral data corresponding to the sample. S4. The Savitzky-Golay filtering algorithm is used to smooth and reduce noise in the spectrum. Sample projection features are constructed based on partial least squares regression scores. Abnormal samples are removed by interquartile range threshold discrimination mechanism to obtain an effective spectral dataset. S5. Construct a spectral feature learning network and an image feature extraction network to encode and select features from the effective spectral dataset, output spectral feature vectors, and extract features from standardized image data and output image feature vectors through global average pooling. S6. Perform feature-level concatenation of the spectral feature vector and the image feature vector to form a fused feature vector, and output the predicted value of strawberry quality index.
[0007] Optionally, S1 includes: S11. Select strawberry samples of various varieties that are intact in appearance, without mechanical damage or signs of rot, mark each strawberry sample with a single fruit number, write the number information into the sample information record table, and establish the correspondence between the sample number and the variety name. S12. Place the numbered strawberry samples in a cold storage environment for unified storage. After the cold storage is completed, take out the samples and place them in a room temperature environment for rewarming. Record the start time of cold storage, the end time of cold storage, the start time of rewarming, and the end time of rewarming for each sample. Fill the cold storage duration and the rewarming duration into the sample information record table. S13. Perform consistency verification on the recorded sample information, remove sample numbers that are missing refrigeration or rewarming time, have incomplete records, or have obvious abnormalities, and retain samples with complete time parameters and normal status. S14. The verified samples are grouped and organized according to the numbering order to form a structured sample data list containing sample number, variety category, cold storage duration and rewarming duration. S15. Based on the structured sample data list, determine the sample range to be included in the subsequent image acquisition and spectral acquisition process, and determine the strawberry set corresponding to the above sample number as the sample set to be detected.
[0008] Optionally, S2 includes: S21. Place a single strawberry sample on a fixed shooting platform, set the shooting distance of the mobile terminal camera component to be consistent with the downward angle, turn on the autofocus function to obtain the original RGB image, and store the original RGB image as image data in the form of a three-channel matrix. S22. Perform color space conversion on the original RGB image, converting the RGB color space to the HSV color space. Generate a binary mask image by setting a threshold range based on the hue and saturation components. Perform connected component analysis on the binary mask image, extract the connected region with the largest area as the main strawberry region, and set the background pixels to zero to complete the background segmentation process. S23. Calculate the minimum bounding rectangle for the image with completed background segmentation, and crop the strawberry main image based on the rectangular region to obtain a cropped image containing only the strawberry region. S24. Perform scale unification processing on the cropped image and resample the cropped image to a preset resolution size. The target pixel values are calculated using a bilinear interpolation algorithm to obtain an image of uniform size; S25. Perform illumination normalization on the image of uniform size and calculate the pixel mean for each color channel. with standard deviation According to the normalization formula A linear transformation is performed on the pixel values of each channel, where These are the original pixel values. Normalized image data is generated from the normalized pixel values.
[0009] Optionally, S3 includes: S31. Fix the strawberry sample posture in the constant temperature and light acquisition area, fix the distance between the portable near-infrared spectrometer probe and the strawberry surface, and mark three acquisition positions in sequence on the same horizontal cross section of the strawberry equator. S32. At each acquisition location, execute the acquisition process: first, acquire the dark reference signal and store it as a dark reference curve, then acquire the white reference signal and store it as a white reference curve, and continuously acquire the original reflectance spectrum curve multiple times at the acquisition location. Each acquisition records the wavelength sampling point sequence and the corresponding intensity sequence. S33. Perform correction processing on the original reflectance spectrum curves obtained from each acquisition: use the dark reference curve to perform dark current subtraction, use the white reference curve to perform white plate normalization, obtain the corrected reflectance spectrum curve, and align the corrected reflectance spectrum curves of each acquisition according to the same wavelength sampling point sequence to generate the spectrum sequence of the acquisition location. S34. Perform recursive least squares update on the spectral sequence of the acquisition location to obtain a stable spectrum: take the first corrected reflectance spectrum curve as the initial estimated spectrum, initialize the covariance matrix as a diagonal matrix, take each subsequent corrected reflectance spectrum curve as a new observation input, calculate the observation residual, and adaptively adjust the forgetting factor according to the residual. S35. In each recursive update, the gain calculation, estimated spectral correction, and covariance matrix update are performed sequentially. The gain calculation uses: ; in, Indicates the first Gain coefficient during recursive update This represents the covariance estimate obtained after the (t-1)th recursive update. Indicates the first The weighted observation noise term corresponding to each observation, and with The current observation residuals are weighted and corrected to estimate the spectrum. At the same time, observations whose residuals exceed the consistency judgment criteria are marked as invalid and skipped in this update. S36. After obtaining the stable spectra at the three acquisition locations, the three stable spectra are averaged point by point at the corresponding wavelength sampling points to generate the average spectral data corresponding to the sample, and the average spectral data is associated with the sample number and written into the spectral dataset.
[0010] Optionally, S4 includes: S41. Read the average spectral data of the samples, sort the average spectrum of each sample in ascending order of wavelength, construct the sample spectral matrix, and perform linear interpolation to complete the data with missing wavelength points. S42. Perform Savitzky-Golay filtering on each sample spectral vector, setting the sliding window length to... The order of the polynomial is Select continuous within the current window Using the spectral intensity values of each wavelength point as fitting samples, a local polynomial model is constructed with the center point of the window as the origin of the independent variable. The polynomial coefficients are solved using the least squares method, and the fitted value of the center point of the window is used as the smoothed value of the wavelength point. The window is moved point by point along the wavelength direction, and the fitting and replacement process is repeated until the smoothing of the entire spectrum is completed, resulting in a smoothed spectral matrix. S43. Input the smoothed spectral matrix into the partial least squares regression modeling process, perform centering processing on the spectral matrix and the corresponding quality index vector respectively, extract the direction of the first latent variable according to the covariance maximization criterion, calculate the score value of each sample in the direction of the latent variable, and form a sample score sequence. S44. Sort the sample score sequence in ascending order, and determine the score value at the 25th percentile as the lower quartile. The score value located at the 75th percentile was determined as the upper quartile. Calculate the interquartile range And calculate the lower limit of anomaly judgment according to the judgment rules respectively. and the upper limit of anomaly judgment ; S45. Compare the score of each sample with the upper and lower limits for anomaly detection, and select samples with scores less than the lower limit. or greater than the upper limit The samples are marked as anomalous and removed from the smoothed spectral matrix, while the remaining samples are retained to form a valid spectral dataset.
[0011] Optionally, S5 includes: S51. Construct a spectral input matrix by aligning the effective spectral dataset according to the sample number, construct an image input tensor by aligning the standardized image data according to the sample number, and establish a pairing relationship between spectral input and image input under the same sample number; S52. Construct a spectral feature learning network with three cascaded sparse autoencoder networks. Set the input layer dimension of the first-level autoencoder network to be consistent with the number of columns of the spectral input matrix. Set the encoding layer and decoding layer and initialize the network parameters. Input the spectral input matrix into the first-level autoencoder network in batches. Perform forward reconstruction calculation and update the network parameters in reverse according to the reconstruction error. After reaching the preset convergence condition, fix the parameters of the first-level encoding layer and output the first-level encoded features. S53. Use the first-level encoding features as input to the second-level autoencoder network, and repeatedly execute the network initialization, batch training, convergence determination and encoding layer parameter fixing process to output the second-level encoding features. Use the second-level encoding features as input to the third-level autoencoder network, and repeatedly execute the network initialization, batch training, convergence determination and encoding layer parameter fixing process to output the third-level encoding features. S54. Perform feature selection on the third-level coding features, calculate the variance between samples according to the feature dimension of the third-level coding features and sort them, delete the feature dimensions with zero variance, retain the remaining feature dimensions to form a spectral feature vector, and store the spectral feature vector with the corresponding sample number. S55. Construct an image feature extraction network based on EfficientNet-B0, building it sequentially from input to output: the input convolutional layer performs convolution, batch normalization, and non-linear activation on the image input tensor to obtain the initial feature map; the hierarchically stacked MBConv module sequence extracts features level by level, wherein each MBConv module sequentially performs 1×1 convolution with channel expansion, 3×3 or 5×5 convolution with channel-wise depth separability, SE channel attention submodule, and 1×1 convolution with channel compression, and performs residual addition when the number of input and output channels of the module is consistent and the stride is 1; the head convolutional layer performs convolution, batch normalization, and non-linear activation on the final feature map to obtain the high-dimensional feature map. S56. Perform fine-tuning training on EfficientNet-B0 using strawberry samples, replace the classification layer at the end of the network with a regression training head, input standardized image data and perform loss calculation by associating the corresponding quality index ground value with the sample number, update the network parameters based on the loss, remove the regression training head after training and retain the feature extraction backbone parameters. S57. Based on the fine-tuned EfficientNet-B0 output image feature vector, the standardized image data is input into the feature extraction backbone to obtain a high-dimensional feature map. Global average pooling is performed on the high-dimensional feature map to generate image feature vectors, and the image feature vectors are stored in correspondence with the sample numbers. S58. Under the same sample number, establish a pairing index for the spectral feature vector and the image feature vector, and output the spectral feature vector and the image feature vector fused at the feature level.
[0012] Optionally, S6 includes: S61. Read the spectral feature vector and the image feature vector, align them according to the sample number, and then perform feature-level concatenation. Concatenate the spectral feature vector and the image feature vector under the same sample number in dimensional order to generate a fused feature vector, and construct a fused feature matrix. S62. Construct a random forest regressor based on the fused feature matrix, set the number of regression trees and the maximum depth of a single regression tree, use the bootstrap sampling method to extract training subsets from the fused feature matrix to train each regression tree, and randomly extract candidate feature subsets from all feature dimensions during the node splitting process of each regression tree to complete the regression tree training and form a random forest model. S63. Calculate the importance score of each feature dimension in the fused feature matrix using the random forest model, sort the importance scores from largest to smallest to generate an importance sequence, and construct a dynamic threshold search sequence. By taking the threshold values from high to low, filter the set of feature dimensions with importance scores not lower than the current threshold to form a subset of candidate features. S64. Perform cross-validation evaluation for each candidate feature subset: Divide the fused feature matrix into training fold and validation fold according to the sample number. Train a partial least squares regression model based on the candidate feature subset on the training fold and calculate the prediction error on the validation fold. Determine the threshold corresponding to the minimum prediction error as the optimal threshold, and use the optimal threshold to filter to obtain the final feature subset and the corresponding filtered fused feature matrix. S65. Based on the fused feature matrix after screening, a partial least squares regression model is trained. After centering, latent variables are extracted and regression coefficients are calculated. The regression coefficients are used to output linear prediction results for each sample, and a linear prediction residual sequence is constructed. The linear prediction residuals are then calculated according to... Calculations show that This represents the true value of the quality index for the corresponding sample. This represents the linear prediction result output by the partial least squares regression model. S66. Using the latent variable scores extracted by the partial least squares regression model as the input for residual learning, and using the linear prediction residual sequence as the supervision label, a random forest residual regression model is constructed. Multiple regression trees are trained using the bootstrap sampling method, and the residual compensation results are output. S67. For each sample, combine the linear prediction result with the residual compensation result to obtain the predicted value of the strawberry quality index, and output the predicted value of the strawberry quality index corresponding to the sample number. The beneficial effects of this invention are: This invention performs background segmentation, scale unification, and illumination normalization on strawberry images, and performs smoothing and noise reduction, sample projection analysis, and outlier sample removal on near-infrared spectral data. This reduces the interference of complex backgrounds, illumination fluctuations, spectral noise, and outlier samples on subsequent modeling, making the input data more standardized and consistent, thereby improving the accuracy of strawberry quality index prediction results.
[0013] This invention constructs a spectral feature learning network and an image feature extraction network to extract deep spectral features and high-dimensional image features, respectively. Furthermore, it uses feature-level concatenation, feature importance calculation, and dynamic threshold screening to obtain a fused feature subset. This reduces the impact of redundant features on model training while retaining key features that are highly correlated with strawberry quality indicators, thereby improving the effectiveness of feature representation and the computational efficiency of the model.
[0014] This invention combines a partial least squares regression model with a random forest model. First, the partial least squares regression model is used to reduce the dimensionality of the fused features and obtain linear prediction results. Then, the random forest model is used to compensate for the prediction residuals, so that the model has both the ability to model linear relationships and the ability to correct nonlinear errors, thereby improving the prediction accuracy of internal quality indicators of strawberries such as soluble solids, pH, and hardness. Attached Figure Description
[0015] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 The overall flowchart proposed in this invention Figure 2 This is a spectral image of a strawberry sample collected according to the present invention; Figure 3 This invention proposes a bar chart of the top 50 features of SSC, PH, and hardness fusion regression. Figure 4 This is the SSC, PH, and hardness fusion regression radar chart proposed in this invention. Detailed Implementation
[0016] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0017] refer to Figure 1 - Figure 4A non-destructive testing method for strawberry quality that integrates image and spectral features includes the following steps: S1. Establish a strawberry sample management unit, number and register multiple varieties of strawberries and enter information, record cold storage and rewarming time parameters, and form a set of samples to be tested; S2. Acquire strawberry RGB images, use the mobile terminal camera component to obtain sample image data, perform background segmentation, scale unification and illumination normalization on the image data, and generate standardized image data. S3. Collect near-infrared spectral data. Under constant temperature and light conditions, set up three equiangularly spaced collection positions along the equatorial direction of strawberry, acquire three spectral curves respectively, and calculate the average spectrum to form the average spectral data corresponding to the sample. S4. The average spectral data is preprocessed and anomaly removal is performed. The Savitzky-Golay filtering algorithm is used to smooth and reduce noise in the spectrum. Sample projection features are constructed based on partial least squares regression scores. Anomalies are removed using the interquartile range threshold discrimination mechanism to obtain an effective spectral dataset. S5. Construct a spectral feature learning network and an image feature extraction network. The spectral feature learning network consists of three cascaded sparse autoencoder networks, which are used to encode and select features from the effective spectral dataset and output spectral feature vectors. The image feature extraction network is based on the EfficientNet-B0 architecture and fine-tuned by strawberry samples. It is used to extract features from standardized image data and output image feature vectors through global average pooling. S6. Perform feature fusion and quality prediction. Concatenate the spectral feature vector and the image feature vector at the feature level to form a fused feature vector. Calculate the feature importance based on the random forest regressor and filter the feature subset through dynamic threshold search. Input the filtered feature subset into the partial least squares regression model to extract latent variables and obtain linear prediction results. Input the linear prediction residuals into the random forest model to obtain residual compensation results. Combine the linear prediction results and residual compensation results to output the predicted value of strawberry quality index.
[0018] In this embodiment, S1 includes: S11. Select strawberry samples of various varieties that are intact in appearance, without mechanical damage or signs of rot, mark each strawberry sample with a single fruit number, write the number information into the sample information record table, and establish the correspondence between the sample number and the variety name. S12. Place the numbered strawberry samples in a cold storage environment for unified storage. After the cold storage is completed, take out the samples and place them in a room temperature environment for rewarming. Record the start time of cold storage, the end time of cold storage, the start time of rewarming, and the end time of rewarming for each sample. Fill the cold storage duration and the rewarming duration into the sample information record table. S13. Perform consistency verification on the recorded sample information, remove sample numbers that are missing refrigeration or rewarming time, have incomplete records, or have obvious abnormalities, and retain samples with complete time parameters and normal status. S14. The verified samples are grouped and organized according to the numbering order to form a structured sample data list containing sample number, variety category, cold storage duration and rewarming duration. S15. Based on the structured sample data list, determine the sample range to be included in the subsequent image acquisition and spectral acquisition process, and determine the strawberry set corresponding to the above sample number as the sample set to be detected.
[0019] In this embodiment, S2 includes: S21. Place a single strawberry sample on a fixed shooting platform, set the shooting distance of the mobile terminal camera component to be consistent with the downward angle, turn on the autofocus function to obtain the original RGB image, and store the original RGB image as image data in the form of a three-channel matrix. S22. Perform color space conversion on the original RGB image, converting the RGB color space to the HSV color space. Generate a binary mask image by setting a threshold range based on the hue and saturation components. Perform connected component analysis on the binary mask image, extract the connected region with the largest area as the main strawberry region, and set the background pixels to zero to complete the background segmentation process. S23. Calculate the minimum bounding rectangle for the image with completed background segmentation, and crop the strawberry main image based on the rectangular region to obtain a cropped image containing only the strawberry region. S24. Perform scale unification processing on the cropped image and resample the cropped image to a preset resolution size. The target pixel values are calculated using a bilinear interpolation algorithm to obtain an image of uniform size; S25. Perform illumination normalization on the image of uniform size and calculate the pixel mean for each color channel. with standard deviation According to the normalization formula A linear transformation is performed on the pixel values of each channel, where These are the original pixel values. Normalized image data is generated from the normalized pixel values.
[0020] In this embodiment, S3 includes: S31. Fix the strawberry sample posture in the constant temperature and light acquisition area, fix the distance between the portable near-infrared spectrometer probe and the strawberry surface, and mark three acquisition positions in sequence on the same horizontal cross section of the strawberry equator. The azimuth angle of the three acquisition positions is determined at 120° equal angular intervals with the first acquisition position as the reference. S32. At each acquisition location, execute the acquisition process: first, acquire the dark reference signal and store it as a dark reference curve, then acquire the white reference signal and store it as a white reference curve, and then continuously acquire the original reflectance spectrum curve multiple times at the acquisition location. Each acquisition records the wavelength sampling point sequence and the corresponding intensity sequence. S33. Perform correction processing on the original reflectance spectrum curves obtained from each acquisition: use the dark reference curve to perform dark current subtraction, use the white reference curve to perform white plate normalization, obtain the corrected reflectance spectrum curve, and align the corrected reflectance spectrum curves of each acquisition according to the same wavelength sampling point sequence to generate the spectrum sequence of the acquisition location. S34. Perform recursive least squares update on the spectral sequence of the acquisition location to obtain a stable spectrum: take the first corrected reflectance spectrum curve as the initial estimated spectrum, initialize the covariance matrix as a diagonal matrix, take each subsequent corrected reflectance spectrum curve as the new observation input, calculate the observation residual, and adaptively adjust the forgetting factor according to the residual so that the observation weight corresponding to the residual automatically decays according to the update rule. S35. In each recursive update, the gain calculation, estimated spectral correction, and covariance matrix update are performed sequentially. The gain calculation uses... ; and with The current observation residuals are weighted and corrected to estimate the spectrum. At the same time, observations whose residuals exceed the consistency judgment criteria are marked as invalid and skipped in this update. S36. After obtaining the stable spectra at the three acquisition locations, the three stable spectra are averaged point by point at the corresponding wavelength sampling points to generate the average spectral data corresponding to the sample, and the average spectral data is associated with the sample number and written into the spectral dataset.
[0021] In this embodiment, S4 includes: S41. Read the average spectral data of the samples, sort the average spectrum of each sample in ascending order of wavelength, construct the sample spectral matrix, and perform linear interpolation to fill in the missing wavelength points to ensure that all samples have a consistent intensity value sequence at the same wavelength sampling point. S42. Perform Savitzky-Golay filtering on each sample spectral vector, setting the sliding window length to... The order of the polynomial is Select continuous within the current window The spectral intensity values of each wavelength point are used as fitting samples to construct a local polynomial model with the center point of the window as the origin of the independent variable. The least squares method is used to solve the polynomial coefficients to minimize the sum of squares of the fitting residuals within the window. The fitting value of the center point of the window is used as the smoothing value of that wavelength point. Then, the window is moved point by point along the wavelength direction, and the fitting and replacement process is repeated until the smoothing of the entire spectrum is completed, and the smoothed spectral matrix is obtained. S43. Input the smoothed spectral matrix into the partial least squares regression modeling process. First, center the spectral matrix and the corresponding quality index vector respectively. Then, extract the direction of the first latent variable according to the covariance maximization criterion, calculate the score value of each sample in the direction of the latent variable, and form a sample score sequence. S44. Sort the sample score sequence in ascending order, and determine the score value at the 25th percentile as the lower quartile. The score value located at the 75th percentile was determined as the upper quartile. Calculate the interquartile range And calculate the lower limit of anomaly judgment according to the judgment rules respectively. and the upper limit of anomaly judgment ; S45. Compare the score of each sample with the upper and lower limits for anomaly detection, and select samples with scores less than the lower limit. or greater than the upper limit The samples are marked as anomalous and removed from the smoothed spectral matrix, while the remaining samples are retained, thus forming a valid spectral dataset. The valid spectral dataset is then saved with the corresponding sample numbers for subsequent feature learning processing.
[0022] In this embodiment, S5 includes: S51. Read the valid spectral dataset and construct the spectral input matrix by aligning the sample numbers. Construct the image input tensor by aligning the standardized image data by the sample numbers, and establish a pairing relationship between the spectral input and the image input under the same sample number. S52. Construct a spectral feature learning network with three cascaded sparse autoencoder networks. Set the input layer dimension of the first-level autoencoder network to be consistent with the number of columns of the spectral input matrix. Set the encoding layer and decoding layer and initialize the network parameters. Input the spectral input matrix into the first-level autoencoder network in batches. Perform forward reconstruction calculation and update the network parameters in reverse according to the reconstruction error. After reaching the preset convergence condition, fix the parameters of the first-level encoding layer and output the first-level encoded features. S53. Use the first-level encoding features as input to the second-level autoencoder network, and repeatedly execute the network initialization, batch training, convergence determination and encoding layer parameter fixing process to output the second-level encoding features. Use the second-level encoding features as input to the third-level autoencoder network, and repeatedly execute the network initialization, batch training, convergence determination and encoding layer parameter fixing process to output the third-level encoding features. S54. Perform feature selection on the third-level coding features, calculate the variance between samples according to the feature dimension of the third-level coding features and sort them, delete the feature dimensions with zero variance, retain the remaining feature dimensions to form a spectral feature vector, and store the spectral feature vector with the corresponding sample number. S55. Construct an image feature extraction network based on EfficientNet-B0, building it sequentially from input to output: the input convolutional layer performs convolution, batch normalization, and non-linear activation on the image input tensor to obtain the initial feature map; the hierarchically stacked MBConv module sequence extracts features level by level, wherein each MBConv module sequentially performs 1×1 convolution with channel expansion, 3×3 or 5×5 convolution with channel-wise depth separability, SE channel attention submodule, and 1×1 convolution with channel compression, and performs residual addition when the number of input and output channels of the module is consistent and the stride is 1; the head convolutional layer performs convolution, batch normalization, and non-linear activation on the final feature map to obtain the high-dimensional feature map. S56. Perform fine-tuning training on EfficientNet-B0 using strawberry samples, replace the classification layer at the end of the network with a regression training head, input standardized image data and perform loss calculation by associating the corresponding quality index ground value with the sample number, update the network parameters based on the loss, remove the regression training head after training and retain the feature extraction backbone parameters. S57. Based on the fine-tuned EfficientNet-B0 output image feature vector, the standardized image data is input into the feature extraction backbone to obtain a high-dimensional feature map. Global average pooling is performed on the high-dimensional feature map to generate image feature vectors, and the image feature vectors are stored in correspondence with the sample numbers. S58. Under the same sample number, establish a pairing index for the spectral feature vector and the image feature vector, and output the spectral feature vector and the image feature vector fused at the feature level.
[0023] In this embodiment, S6 includes: S61. Read the spectral feature vector and the image feature vector, align them according to the sample number, and then perform feature-level concatenation. Concatenate the spectral feature vector and the image feature vector under the same sample number in dimensional order to generate a fused feature vector, and construct a fused feature matrix. S62. Construct a random forest regressor based on the fused feature matrix, set the number of regression trees and the maximum depth of a single regression tree, use the bootstrap sampling method to extract training subsets from the fused feature matrix to train each regression tree, and randomly extract candidate feature subsets from all feature dimensions during the node splitting process of each regression tree to complete the regression tree training and form a random forest model. S63. Calculate the importance score of each feature dimension in the fused feature matrix using the random forest model, sort the importance scores from largest to smallest to generate an importance sequence, and construct a dynamic threshold search sequence. By taking the threshold values from high to low, filter the set of feature dimensions with importance scores not lower than the current threshold to form a subset of candidate features. S64. Perform cross-validation evaluation for each candidate feature subset: Divide the fused feature matrix into training fold and validation fold according to the sample number. Train a partial least squares regression model based on the candidate feature subset on the training fold and calculate the prediction error on the validation fold. Determine the threshold corresponding to the minimum prediction error as the optimal threshold, and use the optimal threshold to filter to obtain the final feature subset and the corresponding filtered fused feature matrix. S65. Based on the fused feature matrix after screening, a partial least squares regression model is trained. After centering, latent variables are extracted and regression coefficients are calculated. The regression coefficients are used to output linear prediction results for each sample, and a linear prediction residual sequence is constructed. The linear prediction residuals are then calculated according to... Calculations show that This represents the true value of the quality index for the corresponding sample. This represents the linear prediction result output by the partial least squares regression model. S66. Using the latent variable scores extracted by the partial least squares regression model as the input for residual learning, and using the linear prediction residual sequence as the supervision label, a random forest residual regression model is constructed. Multiple regression trees are trained using the bootstrap sampling method, and the residual compensation results are output. S67. For each sample, combine the linear prediction result with the residual compensation result to obtain the predicted value of the strawberry quality index, and output the predicted value of the strawberry quality index corresponding to the sample number.
[0024] Example: To verify the feasibility of this invention, it was applied to a post-harvest quality inspection and grading scenario for strawberries. The strawberries in this scenario came from multiple planting batches, and the samples included different varieties, different maturity levels, different fruit diameters, different surface color intensities, and different refrigeration and rewarming conditions. During post-harvest distribution, strawberries are prone to quality differences due to variations in maturity, changes in internal sugar and acid content, tissue softening, and localized damage; however, these differences cannot always be directly identified by visual observation. Existing grading methods primarily rely on manual observation of strawberry color, size, shape, and surface integrity. This can easily lead to samples with similar appearances but significant differences in internal sugar content, pH, and firmness being grouped into the same grade. While physicochemical testing can obtain relatively accurate data on soluble solids content, pH, and firmness, the process requires pressing, piercing, or cutting the strawberries, rendering the tested samples unsellable and unsuitable for large-scale sorting. Using near-infrared spectroscopy alone can result in insufficient representativeness due to factors such as surface curvature, fruit diameter, sampling location, and uneven distribution of internal components. While hyperspectral imaging equipment can simultaneously acquire spatial and spectral information, its high cost, large data volume, and computational complexity make deployment difficult in typical grading scenarios. To address these issues, this embodiment employs a fusion of image information and near-infrared spectral information for non-destructive testing and grading of strawberry internal quality.
[0025] In implementation, a strawberry sample management unit is first established. Each strawberry entering the testing process is individually numbered and registered, and its sample number, variety, post-harvest storage status, cold storage duration parameters, and rewarming duration parameters are recorded in the sample information record table. The sample management unit performs consistency checks on the recorded information. If a sample number is missing, the storage status record is incomplete, or the same number corresponds to multiple samples, the system marks the corresponding sample as a sample awaiting verification and prevents it from entering the subsequent modeling process. Through this process, the image data, spectral data, and subsequent quality indicator data of each strawberry sample can be established based on the number, avoiding prediction errors caused by image-spectral mismatch.
[0026] After sample registration, a single strawberry is placed on a fixed shooting platform. The platform uses a monochrome background and positioning grooves to maintain a stable posture within the shooting area. The mobile terminal camera is set to a fixed shooting distance and a fixed top-down angle, and autofocus is enabled to capture the original color image of the strawberry. The system stores the original color image as a three-channel image matrix and converts the image from the red-green-blue color space to a hue, saturation, and brightness color space. Based on the hue and saturation components, the system establishes a strawberry subject recognition threshold, generates a binary mask image, and then performs connected component analysis on the binary mask image. The connected region with the largest area is selected as the strawberry subject region, and pixels outside the subject region are set to zero. Subsequently, the system calculates the minimum bounding rectangle of the strawberry subject region and crops the image according to the boundary of the bounding rectangle, so that the cropping result retains only the strawberry subject region. The cropped image is resampled to a uniform resolution, and bilinear interpolation is used to calculate the target pixel value during the resampling process. To reduce the impact of ambient light variations on image features across different acquisition batches, the system further calculates the pixel mean and standard deviation for each color channel of the image and performs a linear normalization transformation on the pixel values, ultimately forming standardized image data. Through these image processing techniques, the system can reliably extract color, texture, contour, and surface condition information from strawberry images.
[0027] After image acquisition, strawberries with the same number were transferred to the near-infrared spectroscopy acquisition station. The spectral acquisition station was set up in a constant-temperature, constant-light acquisition area, with the portable near-infrared spectrometer probe maintained at a fixed distance from the strawberry surface. Using the same horizontal cross-section of the strawberry at the equator as the acquisition reference, the system set three equally spaced acquisition positions along the equatorial direction, with an azimuth interval of 120 degrees between adjacent acquisition positions. At each acquisition position, a dark reference signal was acquired first, followed by a white reference signal, and then multiple raw reflectance spectral curves were continuously acquired from the strawberry surface. The system used the dark reference curve to subtract dark current from the raw reflectance spectral curve and used the white reference curve for normalization correction to obtain a corrected reflectance spectral curve. For multiple corrected reflectance spectral curves obtained from the same acquisition position, the system aligned them according to the same wavelength sampling point sequence and used a recursive update method to generate a stable spectrum; when the residual between a certain acquisition curve and the current estimated spectrum exceeds the consistency judgment condition, the system marked that observation as invalid and skipped the update. After obtaining stable spectra at the three acquisition locations, the system averages the data point by point at the corresponding wavelength sampling points to generate the average spectral data for that sample, and then stores the average spectral data in association with the sample number. By acquiring data at three points and averaging it, the system can reduce the impact of uneven local sugar content distribution, local surface condition differences, and probe position deviations on the spectral results of strawberries.
[0028] After obtaining the average spectral data, the system constructs a sample spectral matrix in ascending order of wavelength. If some samples have missing wavelengths, the system uses linear interpolation to fill in the missing wavelengths, ensuring all samples have a consistent intensity value sequence at the same wavelength sampling point. Subsequently, the system performs smoothing and denoising on the spectral vector of each sample. During smoothing and denoising, the system sets the sliding window length and polynomial order, establishes a local polynomial fitting model within each sliding window, and solves for the polynomial coefficients using the least squares method. The fitted value at the center point of the window is used as the smoothed spectral intensity value. The smoothed spectral matrix is input into the partial least squares regression modeling process. The system first centers the spectral matrix and the corresponding quality index vector, then extracts the latent variable direction according to the covariance maximization criterion, and calculates the score value of each sample in the latent variable direction. The system sorts the score sequence, determines the lower and upper quartiles, and calculates the lower and upper limits for anomaly detection based on the interquartile range. If a sample's score is below the lower limit or above the upper limit, the system marks it as an anomalous sample and removes it from the smoothed spectral matrix; the remaining samples are retained to form a valid spectral dataset. This technical feature can reduce the impact of noise curves, acquisition bias, and abnormal samples on model training.
[0029] During the feature extraction stage, the system constructs a spectral input matrix from the effective spectral dataset according to sample numbers, and constructs an image input tensor from the standardized image data according to sample numbers. For the spectral input matrix, the system constructs a cascaded three-level sparse autoencoder network for spectral feature learning. The input layer dimension of the first-level sparse autoencoder network is consistent with the number of columns in the spectral input matrix. The encoding layer is used to compress spectral information, and the decoding layer is used to reconstruct the input spectrum. During training, the system inputs the spectral input matrix into the first-level sparse autoencoder network in batches, updates the network parameters in reverse according to the reconstruction error, and fixes the first-level encoding layer parameters and outputs the first-level encoded features when the reconstruction error reaches the preset convergence condition. The second-level sparse autoencoder network uses the first-level encoded features as input and continues encoding learning and reconstruction training, outputting the second-level encoded features. The third-level sparse autoencoder network uses the second-level encoded features as input and outputs the third-level encoded features. Subsequently, the system calculates the inter-sample variance of the third-level encoded features according to the feature dimensions, deletes the feature dimensions with zero variance, and retains the remaining feature dimensions to form a spectral feature vector.
[0030] For the image input tensor, the system constructs an image feature extraction network based on a lightweight convolutional network structure. This network includes an input convolutional stem layer, multiple moving-inverted convolutional modules, a channel attention submodule, a head convolutional layer, and a global average pooling layer. The input convolutional stem layer performs convolution, batch normalization, and non-linear activation on the normalized image to obtain an initial feature map. The moving-inverted convolutional modules extract deep image features step-by-step through channel expansion, channel-wise convolution, channel compression, and residual connections. The channel attention submodule enhances channel responses related to strawberry color, texture, and ripeness. The head convolutional layer outputs a high-dimensional feature map. The image feature extraction network is fine-tuned and trained on strawberry samples. During training, the network tail is connected to a regression training head, and the loss is calculated using the ground truth quality metric associated with the sample number. After training, the regression training head is removed, retaining only the feature extraction backbone. After the normalized image is input into the feature extraction backbone, global average pooling is used to obtain the image feature vector, which is stored corresponding to the sample number.
[0031] In the feature fusion and quality prediction stage, the system reads the spectral feature vector and image feature vector under the same sample number and performs feature-level concatenation according to dimensional order to generate a fused feature vector. The fused feature vectors of multiple samples form a fused feature matrix. Based on the fused feature matrix, the system constructs a random forest regressor and uses a bootstrap sampling method to extract a training subset from the fused feature matrix to train multiple regression trees. During node splitting, each regression tree randomly extracts a subset of candidate features from all feature dimensions, forming a random forest model after training. The system uses the random forest model to calculate the importance score of each feature dimension and generates an importance sequence in descending order of scores. Subsequently, the system constructs a dynamic threshold search sequence, taking threshold values from high to low and filtering feature dimensions with importance scores not lower than the current threshold to form multiple candidate feature subsets. The system performs cross-validation evaluation on each candidate feature subset, determines the threshold with the smallest prediction error as the optimal threshold, and uses the optimal threshold to select the final feature subset.
[0032] After obtaining the final feature subset, the system trains a partial least squares regression model based on the selected fused feature matrix. This model extracts latent variables through centering and calculates regression coefficients to obtain linear prediction results for each sample. The system further calculates the residuals between the linear prediction results and the actual quality indicators, and uses the latent variable scores extracted by the partial least squares regression model as input, with the residuals as supervision labels to train a random forest residual regression model. After the random forest residual regression model outputs the residual compensation results, the system adds the linear prediction results to the residual compensation results to obtain the final predicted values for strawberry quality indicators. The predicted indicators include soluble solids content, pH, and firmness. The system outputs the corresponding quality grade according to the predicted indicators and preset grading rules, and writes the predicted values, quality grades, sample numbers, and anomaly markers into the detection results database.
[0033] After completing image feature extraction, spectral feature extraction, and feature-level fusion and hybrid regression modeling, to further verify the impact of different information modes on the predictive ability of strawberry quality, a comparative analysis was conducted on three models: single spectral information, single image information, and fused information. All models were built based on the same batch of strawberry samples and adopted a consistent data preprocessing workflow. Spectral data was input into the spectral feature learning network after smoothing, noise reduction, and anomaly removal. Image data was input into the image feature extraction network after background segmentation, scale unification, and illumination normalization. The fusion model then performed feature-level stitching, feature selection, and hybrid regression prediction based on these data.
[0034] The experimental results are shown in the table below: Comparison of strawberry quality prediction performance under fused information and single information modes ; Among them, R 2 The value is used to characterize the model's ability to explain changes in the target variable; the closer the value is to 1, the better the fit. RMSE is used to reflect the degree of deviation between the predicted value and the true value; the smaller the value, the higher the prediction accuracy. RPD is used to evaluate the model's predictive ability and stability; when RPD is greater than 2, it indicates that the model has good practical application value.
[0035] Furthermore, during model evaluation, performance metrics for both the calibration and test sets were statistically analyzed. Here, Rc represents the correlation coefficient of the calibration set, Rp represents the correlation coefficient of the test set, RMSEC represents the root mean square error of the calibration set, RMSEP represents the root mean square error of the test set, RPDC represents the relative analysis error of the calibration set, and RPDP represents the relative analysis error of the test set. Comparison revealed that the fusion model showed relatively small differences in metrics between the calibration and test sets, indicating that the model possesses good generalization ability and stability.
[0036] The data in the table shows that single spectral information has a lower accuracy rate in predicting soluble solids content. 2 The R-value is only 0.5391, indicating that relying solely on spectral data is insufficient to fully characterize the internal quality of strawberries. This is because spectral signals mainly reflect the average chemical composition of local areas, making it difficult to reflect the overall ripeness and spatial distribution differences of the fruit. While single-image information models have a higher R-value for firmness prediction, they are less effective in this area. 2 The value reached 0.8085, but it still has significant shortcomings in predicting soluble solids content and pH, indicating that relying solely on appearance information is insufficient to accurately reflect internal physicochemical indicators.
[0037] In comparison, the fused information model showed significant improvements across all three quality metrics, with the R-value for soluble solids content being the highest. 2The pH value increased to 0.8444, the pH value increased to 0.8746, and the hardness value increased to 0.9263. Simultaneously, the RMSE decreased significantly, and the RPD exceeded 2, especially in hardness prediction where the RPD reached 3.68, indicating that the model has strong predictive ability and stability. These results demonstrate that by fusing image and spectral features at the feature level, and combining feature selection with hybrid regression modeling, the ability of image information to represent maturity and appearance, as well as the responsiveness of spectral information to internal chemical composition, can be effectively utilized, thus compensating for the shortcomings of a single information source.
[0038] As can be seen from the technical implementation process of this invention, the performance improvement comes from the synergistic effect of multiple key technical features, including ensuring the consistency of image features through image standardization processing, improving spectral representativeness through multi-point spectral acquisition and averaging processing, extracting deep spectral features through sparse autoencoder networks, extracting high-dimensional image features through convolutional networks, reducing the impact of redundant features by using random forests for feature importance screening, and achieving linear relationship modeling and nonlinear error compensation through a combination model of partial least squares regression and random forests.
[0039] In summary, this implementation not only verifies the feasibility of the present invention in non-destructive testing of strawberry quality, but also demonstrates through quantitative data that fusing image and spectral features can significantly improve the model's prediction accuracy and stability, effectively solving the problem of insufficient prediction ability of single spectral information or single image information under complex sample conditions.
[0040] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A non-destructive testing method for strawberry quality that integrates image and spectral features, characterized in that, Includes the following steps: S1. Number and register multiple varieties of strawberries and enter their information, record the cold storage and rewarming time parameters, and form a set of samples to be tested; S2. Acquire strawberry RGB images, use the mobile terminal camera component to obtain sample image data, perform background segmentation, scale unification and illumination normalization on the image data, and generate standardized image data. S3. Collect near-infrared spectral data. Under constant temperature and light conditions, set up three equiangularly spaced collection positions along the equatorial direction of strawberry, acquire three spectral curves respectively, and calculate the average spectrum to form the average spectral data corresponding to the sample. The original reflectance spectrum curves obtained from each acquisition are corrected by performing dark current subtraction using a dark reference curve and white plate normalization using a white reference curve to obtain a corrected reflectance spectrum curve. The corrected reflectance spectrum curves from each acquisition are then aligned with the same wavelength sampling point sequence to generate the spectral sequence of the acquisition location. To obtain a stable spectrum, a recursive least squares update is performed on the spectral sequence of the acquisition location: the first corrected reflectance spectrum curve is used as the initial estimated spectrum, the covariance matrix is initialized as a diagonal matrix, each subsequent corrected reflectance spectrum curve is used as a new observation input, the observation residual is calculated, and the forgetting factor is adaptively adjusted according to the residual. In each recursive update, the gain calculation, estimated spectral correction, and covariance matrix update are performed sequentially. The gain calculation uses: ; in, Indicates the first Gain coefficient during recursive update This represents the covariance estimate obtained after the (t-1)th recursive update. Indicates the first The weighted observation noise term corresponding to the next recursive update, and with The current observation residuals are weighted and corrected to estimate the spectrum. At the same time, observations whose residuals exceed the consistency judgment criteria are marked as invalid and skipped in this update. After obtaining the stable spectra at the three acquisition locations, the three stable spectra are averaged point by point at the corresponding wavelength sampling points to generate the average spectral data corresponding to the sample. The average spectral data is then associated with the sample number and written into the spectral dataset. S4. The Savitzky-Golay filtering algorithm is used to smooth and reduce noise in the spectrum. Sample projection features are constructed based on partial least squares regression scores. Abnormal samples are removed by interquartile range threshold discrimination mechanism to obtain an effective spectral dataset. S5. Construct a spectral feature learning network and an image feature extraction network to encode and select features from the effective spectral dataset, output spectral feature vectors, and extract features from standardized image data and output image feature vectors through global average pooling. S6. Perform feature fusion and quality prediction. Concatenate the spectral feature vector and the image feature vector at the feature level to form a fused feature vector. Calculate the feature importance based on the random forest regressor and filter the feature subset through dynamic threshold search. Input the filtered feature subset into the partial least squares regression model to extract latent variables and obtain linear prediction results. Input the linear prediction residuals into the random forest model to obtain residual compensation results. Combine the linear prediction results and residual compensation results to output the predicted value of strawberry quality index.
2. The method for non-destructive testing of strawberry quality by fusing image and spectral features according to claim 1, characterized in that, S1 includes: S11. Select strawberry samples of various varieties that are intact in appearance, without mechanical damage or signs of rot, mark each strawberry sample with a single fruit number, write the number information into the sample information record table, and establish the correspondence between the sample number and the variety name. S12. Place the numbered strawberry samples in a cold storage environment for unified storage. After the cold storage is completed, take out the samples and place them in a room temperature environment for rewarming. Record the start time of cold storage, the end time of cold storage, the start time of rewarming, and the end time of rewarming for each sample. Fill the cold storage duration and the rewarming duration into the sample information record table. S13. Perform consistency verification on the recorded sample information, remove sample numbers that are missing refrigeration or rewarming time, have incomplete records, or have obvious abnormalities, and retain samples with complete time parameters and normal status. S14. The verified samples are grouped and organized according to the numbering order to form a structured sample data list containing sample number, variety category, cold storage duration and rewarming duration. S15. Based on the structured sample data list, determine the sample range to be included in the subsequent image acquisition and spectral acquisition process, and determine the strawberry set corresponding to the above sample number as the sample set to be detected.
3. The method for non-destructive testing of strawberry quality by fusing image and spectral features according to claim 1, characterized in that, S2 includes: S21. Place a single strawberry sample on a fixed shooting platform, set the shooting distance of the mobile terminal camera component to be consistent with the downward angle, turn on the autofocus function to obtain the original RGB image, and store the original RGB image as image data in the form of a three-channel matrix. S22. Perform color space conversion on the original RGB image, converting the RGB color space to the HSV color space. Generate a binary mask image by setting a threshold range based on the hue and saturation components. Perform connected component analysis on the binary mask image, extract the connected region with the largest area as the main strawberry region, and set the background pixels to zero to complete the background segmentation process. S23. Calculate the minimum bounding rectangle for the image with completed background segmentation, and crop the strawberry main image based on the rectangular region to obtain a cropped image containing only the strawberry region. S24. Perform scale unification processing on the cropped image and resample the cropped image to a preset resolution size. The target pixel values are calculated using a bilinear interpolation algorithm to obtain an image of uniform size; S25. Perform illumination normalization on the image of uniform size and calculate the pixel mean for each color channel. with standard deviation According to the normalization formula A linear transformation is performed on the pixel values of each channel, where These are the original pixel values. Normalized image data is generated from the normalized pixel values.
4. The method for non-destructive testing of strawberry quality by fusing image and spectral features according to claim 1, characterized in that, S3 further includes: S31. Fix the strawberry sample posture in the constant temperature and light acquisition area, fix the distance between the portable near-infrared spectrometer probe and the strawberry surface, and mark three acquisition positions in sequence on the same horizontal cross section of the strawberry equator. S32. At each acquisition location, execute the acquisition process: first, acquire the dark reference signal and store it as a dark reference curve, then acquire the white reference signal and store it as a white reference curve, and continuously acquire the original reflectance spectrum curve multiple times at the acquisition location. Each acquisition records the wavelength sampling point sequence and the corresponding intensity sequence.
5. The method for non-destructive testing of strawberry quality by fusing image and spectral features according to claim 1, characterized in that, S4 includes: S41. Read the average spectral data of the samples, sort the average spectrum of each sample in ascending order of wavelength, construct the sample spectral matrix, and perform linear interpolation to complete the data with missing wavelength points. S42. Perform Savitzky-Golay filtering on each sample spectral vector, setting the sliding window length to... The order of the polynomial is Select continuous within the current window Using the spectral intensity values of each wavelength point as fitting samples, a local polynomial model is constructed with the center point of the window as the origin of the independent variable. The polynomial coefficients are solved using the least squares method, and the fitted value of the center point of the window is used as the smoothed value of the wavelength point. The window is moved point by point along the wavelength direction, and the fitting and replacement process is repeated until the smoothing of the entire spectrum is completed, resulting in a smoothed spectral matrix. S43. Input the smoothed spectral matrix into the partial least squares regression modeling process, perform centering processing on the spectral matrix and the corresponding quality index vector respectively, extract the direction of the first latent variable according to the covariance maximization criterion, calculate the score value of each sample in the direction of the latent variable, and form a sample score sequence. S44. Sort the sample score sequence in ascending order, and determine the score value at the 25th percentile as the lower quartile. The score value located at the 75th percentile was determined as the upper quartile. Calculate the interquartile range And calculate the lower limit of anomaly judgment according to the judgment rules respectively. and the upper limit of anomaly judgment ; S45. Compare the score of each sample with the upper and lower limits for anomaly detection, and select samples with scores less than the lower limit. or greater than the upper limit The samples are marked as anomalous and removed from the smoothed spectral matrix, while the remaining samples are retained to form a valid spectral dataset.
6. The method for non-destructive testing of strawberry quality by fusing image and spectral features according to claim 1, characterized in that, S5 includes: S51. Construct a spectral input matrix by aligning the effective spectral dataset according to the sample number, construct an image input tensor by aligning the standardized image data according to the sample number, and establish a pairing relationship between spectral input and image input under the same sample number; S52. Construct a spectral feature learning network with three cascaded sparse autoencoder networks. Set the input layer dimension of the first-level autoencoder network to be consistent with the number of columns of the spectral input matrix. Set the encoding layer and decoding layer and initialize the network parameters. Input the spectral input matrix into the first-level autoencoder network in batches. Perform forward reconstruction calculation and update the network parameters in reverse according to the reconstruction error. After reaching the preset convergence condition, fix the parameters of the first-level encoding layer and output the first-level encoded features. S53. Use the first-level encoding features as input to the second-level autoencoder network, and repeatedly execute the network initialization, batch training, convergence determination and encoding layer parameter fixing process to output the second-level encoding features. Use the second-level encoding features as input to the third-level autoencoder network, and repeatedly execute the network initialization, batch training, convergence determination and encoding layer parameter fixing process to output the third-level encoding features. S54. Perform feature selection on the third-level coding features, calculate the variance between samples according to the feature dimension of the third-level coding features and sort them, delete the feature dimensions with zero variance, retain the remaining feature dimensions to form a spectral feature vector, and store the spectral feature vector with the corresponding sample number. S55. Construct an image feature extraction network based on EfficientNet-B0, building it sequentially from input to output: the input convolutional layer performs convolution, batch normalization, and non-linear activation on the image input tensor to obtain the initial feature map; the hierarchically stacked MBConv module sequence extracts features level by level, wherein each MBConv module sequentially performs 1×1 convolution with channel expansion, 3×3 or 5×5 convolution with channel-wise depth separability, SE channel attention submodule, and 1×1 convolution with channel compression, and performs residual addition when the number of input and output channels of the module is consistent and the stride is 1; the head convolutional layer performs convolution, batch normalization, and non-linear activation on the final feature map to obtain the high-dimensional feature map. S56. Perform fine-tuning training on EfficientNet-B0 using strawberry samples, replace the classification layer at the end of the network with a regression training head, input standardized image data and perform loss calculation by associating the corresponding quality index ground value with the sample number, update the network parameters based on the loss, remove the regression training head after training and retain the feature extraction backbone parameters. S57. Based on the fine-tuned EfficientNet-B0 output image feature vector, the standardized image data is input into the feature extraction backbone to obtain a high-dimensional feature map. Global average pooling is performed on the high-dimensional feature map to generate image feature vectors, and the image feature vectors are stored in correspondence with the sample numbers. S58. Under the same sample number, establish a pairing index for the spectral feature vector and the image feature vector, and output the spectral feature vector and the image feature vector fused at the feature level.
7. The method for non-destructive testing of strawberry quality by fusing image and spectral features according to claim 1, characterized in that, S6 includes: S61. Read the spectral feature vector and the image feature vector, align them according to the sample number, and then perform feature-level concatenation. Concatenate the spectral feature vector and the image feature vector under the same sample number in dimensional order to generate a fused feature vector, and construct a fused feature matrix. S62. Construct a random forest regressor based on the fused feature matrix, set the number of regression trees and the maximum depth of a single regression tree, use the bootstrap sampling method to extract training subsets from the fused feature matrix to train each regression tree, and randomly extract candidate feature subsets from all feature dimensions during the node splitting process of each regression tree to complete the regression tree training and form a random forest model. S63. Calculate the importance score of each feature dimension in the fused feature matrix using the random forest model, sort the importance scores from largest to smallest to generate an importance sequence, and construct a dynamic threshold search sequence. By taking the threshold values from high to low, filter the set of feature dimensions with importance scores not lower than the current threshold to form a subset of candidate features. S64. Perform cross-validation evaluation for each candidate feature subset: Divide the fused feature matrix into training fold and validation fold according to the sample number. Train a partial least squares regression model based on the candidate feature subset on the training fold and calculate the prediction error on the validation fold. Determine the threshold corresponding to the minimum prediction error as the optimal threshold, and use the optimal threshold to filter to obtain the final feature subset and the corresponding filtered fused feature matrix. S65. Based on the fused feature matrix after screening, a partial least squares regression model is trained. After centering, latent variables are extracted and regression coefficients are calculated. The regression coefficients are used to output linear prediction results for each sample, and a linear prediction residual sequence is constructed. The linear prediction residuals are then calculated according to... Calculations show that This represents the true value of the quality index for the corresponding sample. This represents the linear prediction result output by the partial least squares regression model. S66. Using the latent variable scores extracted by the partial least squares regression model as the input for residual learning, and using the linear prediction residual sequence as the supervision label, a random forest residual regression model is constructed. Multiple regression trees are trained using the bootstrap sampling method, and the residual compensation results are output. S67. For each sample, combine the linear prediction result with the residual compensation result to obtain the predicted value of the strawberry quality index, and output the predicted value of the strawberry quality index corresponding to the sample number.
Citation Information
Patent Citations
Nondestructive testing method for internal quality and maturity of strawberries based on MPCD-Mmba model
CN119510322A
Method for detecting content of soluble solids in strawberries based on multi-modal fusion
CN121640455A
