Preharvest citrus sugar degree nondestructive testing method and system based on hyperspectral image
By using an improved CNN-FA-RB model and hyperspectral imaging technology, the environmental interference and model adaptability issues of citrus sugar content detection in orchard environments have been resolved. This has enabled high-precision, rapid, and non-destructive pre-harvest detection of citrus sugar content, suitable for real-time online detection and embedded devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGXI ZHUANG AUTONOMOUS REGION ACAD OF AGRI SCI
- Filing Date
- 2026-01-21
- Publication Date
- 2026-04-28
AI Technical Summary
Existing indoor hyperspectral imaging methods, when used for non-destructive testing of citrus sugar content in orchard environments, are severely affected by environmental interference, have inaccurate feature extraction, and lack model adaptability, making pre-harvest testing impossible.
An improved CNN-FA-RB model is adopted, combined with hyperspectral imaging technology. Spectral data is processed by threshold segmentation and Savitzky-Golay smoothing algorithm to construct feature bands. Feature enhancement and residual modules are used to improve the model's detection capability in complex environments.
It enables non-destructive testing of citrus sugar content in orchard environments, with high accuracy and speed, suitable for real-time online testing, and highly adaptable to embedded device deployment.
Smart Images

Figure CN121937992A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of agricultural information technology, specifically relating to a non-destructive method and system for pre-harvest citrus sugar content detection based on hyperspectral images. Background Technology
[0002] Currently, citrus sugar content testing mainly relies on the refractometer method and hyperspectral imaging methods under indoor conditions. Among them, the refractometer method is a destructive testing method, which requires peeling and pressing the citrus fruit before performing multiple titration measurements using a digital sugar refractometer. Although this method has high accuracy, it is time-consuming, labor-intensive, and inefficient, making it unsuitable for large-scale testing in production environments.
[0003] In recent years, detection methods based on hyperspectral imaging have been increasingly applied to the internal quality analysis of fruits, and numerous non-destructive technologies for detecting citrus sugar content using hyperspectral imaging in indoor environments have emerged. This technology first requires the use of specialized sugar content detection equipment or the construction of an experimental platform, with strict requirements regarding uniformity of illumination, consistency of shooting angles, and control of environmental noise. The general technical path involves a multi-step process: post-harvest hyperspectral image acquisition of citrus fruits, spectral data preprocessing, machine learning model training, and model sugar content prediction. Through experimentation, the optimal model and parameters suitable for the current variety are determined among several classic machine learning models, ultimately achieving stable sugar content detection results.
[0004] When applying hyperspectral imaging methods in an indoor environment to non-destructive testing of citrus sugar content in the pre-harvest stage of orchards, the following problems exist: 1. Severe environmental interference: Uneven lighting, instrument noise, water vapor and humidity in the orchard cause spectral baseline drift and increased high-frequency noise, affecting the accuracy of modeling.
[0005] 2. Inaccurate feature extraction: Traditional methods such as region selection are easily affected by shadow interference and lose effective information when extracting regions of interest (ROI); full-band modeling contains a large number of redundant bands, which is computationally intensive and prone to overfitting. In orchards, it is especially susceptible to interference from bands such as water, chlorophyll or carotenoids.
[0006] 3. Insufficient model adaptability: Existing machine learning models (such as PLSR, RFR, SVR) have limited ability to model nonlinear relationships in hyperspectral data under complex environments; classic deep learning models (such as CNN, AlexNet, ResNet) are susceptible to noise interference in complex environments, and have slow training speed and large number of parameters, which is not conducive to deployment in actual orchards.
[0007] Existing hyperspectral imaging methods for indoor environments cannot be used in the pre-harvest stage, and no non-destructive testing methods for pre-harvest citrus sugar content based on hyperspectral images have been reported in orchard environments. Summary of the Invention
[0008] To address the problems of severe environmental interference, inaccurate feature extraction, and insufficient model adaptability in existing indoor hyperspectral imaging methods used in the pre-harvest stage, this invention provides a non-destructive detection method and system for citrus sugar content based on hyperspectral images. This method uses hyperspectral imaging technology to acquire citrus images, applies specific region of interest extraction and spectral data preprocessing methods to reduce outdoor noise interference, and constructs a CNN-FA-RB sugar content detection model to ensure the accuracy and robustness of the model, enabling non-destructive detection of citrus sugar content before harvest.
[0009] To achieve the above objectives, the present invention provides the following solution: A non-destructive method for pre-harvest sugar content detection of citrus fruits based on hyperspectral images, the method comprising: Collect hyperspectral image data and sugar content data of pre-harvest citrus samples; A sugar content detection model is constructed based on the improved CNN-FA-RB model; A training dataset was constructed based on hyperspectral image data and sugar content data, and the sugar content detection model was trained using the training dataset. Based on a trained sugar content detection model, non-destructive detection and spatial distribution visualization of sugar content in citrus fruits before harvest are achieved.
[0010] Preferred methods for collecting hyperspectral image data and sugar content data of preharvest citrus samples include: A hyperspectral imaging system was used to acquire hyperspectral images of citrus samples from citrus trees, and each hyperspectral image was assigned an ID number to obtain hyperspectral image data. After acquiring hyperspectral images, citrus samples were collected, and the sugar content of the citrus samples was detected using a handheld sugar refractometer. The sugar content data was recorded according to the ID number of the hyperspectral image.
[0011] The preferred, improved CNN-FA-RB model includes: an input layer with a feature enhancement module and a residual module; The input layer and feature enhancement module use second-order polynomial feature enhancement technology to expand the input feature bands into combined features; The residual module contains two sub-residual blocks, and each sub-residual block contains two convolutional layers. All two-dimensional convolutional layers, pooling layers, and batch normalization layers in the residual module are replaced with one-dimensional convolutional layers, pooling layers, and batch normalization layers.
[0012] Preferably, the method of constructing a training dataset based on hyperspectral image data and sugar content data, and using the training dataset to train the sugar content detection model includes: Hyperspectral image data and sugar content data were used to create a training dataset, with hyperspectral image data serving as training samples and sugar content data serving as labels. The threshold segmentation method is used to automatically extract the region of interest from the hyperspectral image data. The Savitzky-Golay smoothing algorithm is used to preprocess the spectral data within the region of interest. The competitive adaptive reweighted sampling method is used to extract the feature bands from the preprocessed full-band spectrum. The training dataset after extracting feature bands is divided into training set, validation set and test set according to the proportions. The training set is fed into the sugar content detection model for training. The parameters of the sugar content detection model are adjusted using the validation set and the test set. When the MSE loss value of the sugar content detection model converges and stabilizes, the network weights of the sugar content detection model are saved to obtain the trained sugar content detection model.
[0013] The present invention also provides a non-destructive testing system for pre-harvest citrus sugar content based on hyperspectral images. The system is used to implement the aforementioned method and includes: an acquisition module, a model building module, a training module, a detection module, and a visualization module. The acquisition module is used to acquire hyperspectral images of citrus and sugar content data of citrus samples before harvest; The model building module is used to build a sugar content detection model based on the improved CNN-FA-RB model; The training module is used to construct a training dataset based on hyperspectral image data and sugar content data, and to train the sugar content detection model using the training dataset; The detection module is used to perform non-destructive detection of citrus sugar content before harvest, based on a trained sugar content detection model. The visualization module is used to visualize the spatial distribution of citrus sugar content before harvest, based on a trained sugar content detection model.
[0014] Preferably, the acquisition module includes: an image acquisition unit and a sugar content acquisition unit; The image acquisition unit is used to acquire hyperspectral images of citrus samples on citrus trees using a hyperspectral imaging system, and to assign an ID number to each hyperspectral image to obtain hyperspectral image data. The sugar content acquisition unit is used to collect citrus samples after acquiring hyperspectral images, use a handheld sugar content refractometer to detect the sugar content of the citrus samples, and record the sugar content data according to the ID number of the hyperspectral image.
[0015] The preferred, improved CNN-FA-RB model includes: an input layer with a feature enhancement module and a residual module; The input layer and feature enhancement module use second-order polynomial feature enhancement technology to expand the input feature bands into combined features; The residual module contains two sub-residual blocks, and each sub-residual block contains two convolutional layers. All two-dimensional convolutional layers, pooling layers, and batch normalization layers in the residual module are replaced with one-dimensional convolutional layers, pooling layers, and batch normalization layers.
[0016] Preferably, the training module includes: a dataset construction unit, an extraction unit, a partitioning unit, and a training adjustment unit; The dataset construction unit is used to create a training dataset from hyperspectral image data and sugar content data, where hyperspectral image data is used as training samples and sugar content data is used as labels. The extraction unit is used to automatically extract the region of interest from hyperspectral image data using a threshold segmentation method, perform spectral preprocessing on the spectral data within the region of interest using the Savitzky-Golay smoothing algorithm, and extract feature bands from the preprocessed full-band spectrum using a competitive adaptive reweighted sampling method. The partitioning unit is used to divide the training dataset after extracting feature bands into training set, validation set and test set according to a certain ratio. The training and adjustment unit is used to feed the training set into the sugar content detection model for training, adjust the parameters of the sugar content detection model with the validation set and test set, and save the network weights of the sugar content detection model after the MSE loss value of the sugar content detection model training has converged and stabilized, thus obtaining the trained sugar content detection model.
[0017] Compared with the prior art, the beneficial effects of the present invention are as follows: ① Strong environmental adaptability: The threshold segmentation method is used to automatically remove shadow areas, SG smoothing is used to suppress high-frequency noise from the outside world and the instrument, and CARS algorithm is used to select characteristic bands that are strongly correlated with sugar content, which improves the data quality under complex lighting, angle, water vapor and other interferences before sampling.
[0018] ② High accuracy and fast speed in sugar content detection: The constructed CNN-FA-RB model enhances the model's ability to extract deep spectral features and predict sugar content in complex environments by adding feature enhancement operations at the front end, designing a residual module suitable for spectral data in the middle, and adding global pooling operations at the end, based on the classic CNN model. Experiments show that the model achieves a coefficient of determination R² of 0.816, a root mean square error RMSE of 0.751, a mean absolute error MAE of 0.576, and a mean absolute percentage error MAPE of 5.616% on the test set, significantly outperforming traditional machine learning and classic deep learning models in prediction accuracy; at the same time, the model has only 13 layers and only 0.12M parameters, resulting in fast training speed and easy deployment on embedded devices or mobile platforms.
[0019] ③ Achieve end-to-end non-destructive testing: The entire process from hyperspectral image preprocessing to model sugar content detection is automated without damaging the fruit. It is suitable for real-time, online testing in the field before citrus harvest, providing a feasible technical solution for intelligent harvesting and precision orchard management. Attached Figure Description
[0020] To more clearly illustrate the technical solution of the present invention, the drawings used in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a schematic diagram of the training data acquisition process according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the CNN-FA-RB model structure according to an embodiment of the present invention; Figure 3 This is a schematic diagram of the CNN-FA-RB model training process according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the sugar content detection process in an embodiment of the present invention; Figure 5 This is a schematic diagram illustrating the spatial distribution visualization process of citrus sugar content according to an embodiment of the present invention; Figure 6 This is a schematic diagram comparing the CNN-FA-RB model with the conventional CNN model and the ResNet18 model structure in an embodiment of the present invention. Detailed Implementation
[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0023] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0024] Example 1 This invention provides a non-destructive method for pre-harvest sugar content detection of citrus fruits based on hyperspectral images, comprising: Collect hyperspectral image data and sugar content data of pre-harvest citrus samples; A sugar content detection model is constructed based on the improved CNN-FA-RB model; A training dataset was constructed based on hyperspectral image data and sugar content data, and the sugar content detection model was trained using the training dataset. Based on a trained sugar content detection model, non-destructive detection and spatial distribution visualization of sugar content in citrus fruits before harvest are achieved.
[0025] The specific implementation process of this invention is as follows: To collect data for model training, hyperspectral image data and corresponding sugar content data of citrus samples from the color-changing stage to maturity were collected in an orchard environment. The sample size was 500, and the citrus variety was Wogan. The training data collection process is as follows: Figure 1 As shown, it specifically includes: 1. Hyperspectral image data acquisition (1) A portable hyperspectral imaging system was set up in the orchard environment under natural light conditions. The hyperspectral imaging system has 256 channels in the spectral band of 390 nm to 1025 nm (with an average channel spacing of 2.5 nm). (2) The hyperspectral imaging system is about 1.5 m away from the citrus tree. The hyperspectral images of citrus fruits are randomly selected from the four directions of the citrus tree (east, south, west, and north). The random selection ensures the diversity of data, which is conducive to the model being able to make accurate detection under different conditions. (3) After shooting, remove blurry, duplicate, and other invalid images to obtain 500 hyperspectral images of citrus fruits. Assign a unique ID number to each image: ID number = 3-digit orchard code + 2-digit area code + 4-digit fruit tree code + 10-digit year, month, day, hour, minute timestamp + 3-digit shooting sequence number (1) (4) Use hyperspectral image editing software to remove the background and a small amount of branches and leaves from the image to obtain hyperspectral image data.
[0026] 2. Sugar content data collection (1) Immediately collect citrus samples after acquiring hyperspectral images; (2) The sugar content of the citrus samples was detected using a handheld sugar refractometer and recorded according to the ID number of the hyperspectral image to obtain sugar content data; (3) A total of 500 samples of citrus sugar content were obtained.
[0027] Furthermore, a threshold segmentation method is used to automatically extract the region of interest (ROI) from the hyperspectral image of citrus fruit, specifically including: 1. Calculate the grayscale image of citrus using the weighted average method based on the RGB bands of the hyperspectral image; 2. Enhance image contrast using an adaptive histogram equalization method with limited contrast; 3. The Otsu thresholding method is used to automatically determine the threshold for each image to remove dark lighting areas (fruit edges or shadow occlusion), and retain the fruit surface areas with uniform lighting as ROI.
[0028] Furthermore, the spectral data within the ROI region undergoes preprocessing, specifically including: 1. Calculate the average reflectance of all pixels within the ROI region in each band, and obtain the original spectral curves in band order; 2. The Savitzky-Golay smoothing algorithm was used to preprocess the original spectral curve to suppress high-frequency noise; 3. A competitive adaptive reweighted sampling method was used to screen and extract feature bands that are highly correlated with sugar content from the preprocessed full-band spectrum (256 bands), resulting in 25 feature bands. This was done to avoid irrelevant bands affecting sugar content detection and to improve the computational efficiency of subsequent models.
[0029] Furthermore, a sugar content detection model is constructed based on the improved CNN-FA-RB model.
[0030] This invention constructs a sugar content detection model based on a convolutional neural network (CNN with Feature Augmentation and Residual Block, CNN-FA-RB) model, used for non-destructive sugar content detection of citrus fruits before harvest. Figure 2 As shown, the CNN-FA-RB model structure includes: 1. Input Layer and Feature Enhancement Module Model structure: Input layer: Input feature number (number of one-dimensional spectral bands): 25 Operation: Second-order polynomial feature enhancement (expanding to 300 features) Output feature count: 25 + 300 = 325 Output dimensions: (1, 325) The sugar content detection model receives 25 feature bands as input. In field testing in orchards, the hyperspectral signal on the surface of citrus fruits is often interfered with by factors such as ambient light, peel curvature, and moisture content, resulting in complex nonlinear characteristics in the spectral response. This invention uses second-order polynomial feature enhancement technology (see formula (2)) to expand the original 25 bands to 325 combined features, explicitly introducing cross terms and square terms between bands, effectively simulating the physicochemical interaction effects hidden in the spectrum. This operation enhances the sensitivity of the sugar content detection model to complex sugar content features, improves the ability to represent spectral signals under varying orchard environments, and provides rich input information for subsequent deep feature extraction and integrated prediction.
[0031] (2) in, The original input spectrum, The spectrum is after feature enhancement.
[0032] 2. Initial convolutional block Model structure: Initial Conv1: Convolutional layer: Conv1d (channel count 1→32) Batch Normalization: BatchNorm1d Activation function: ReLU Pooling layer: MaxPool1d (spectral number 325→162) Output dimensions: (32, 162) The initial convolutional block serves as the starting point for feature extraction, capturing the correlation between local bands from the enhanced spectrum. The convolutional layer performs multi-channel convolution operations along the channel dimension using a 32-dimensional convolutional kernel, extracting local spectral morphological features related to sugar content, such as absorption valleys, reflection peaks, and spectral differentials. The batch normalization layer combats data distribution shifts caused by instrument fluctuations, sample differences, or data transformations during orchard data collection, improving the stability of model training. The pooling layer performs max pooling along the spectral dimension using a pooling kernel with a stride of 2, reducing data dimensionality and computational burden while preserving key spectral features, making the model more suitable for embedded or mobile deployments and adapting to real-time field monitoring needs.
[0033] 3. Residual Module Model structure: Residual Block 1: Convolutional layer: Conv1d (channel count changes from 32 to 64) Batch Normalization: BatchNorm1d Activation function: ReLU Convolutional layer: Conv1d (channel count 64 → 64) Batch Normalization: BatchNorm1d (From input) Skip connection: Shortcut (channel number 32→64) Operation: Jump, Connect, Add Activation function: ReLU Pooling layer: MaxPool1d (spectral number 162→81) Output dimensions: (64, 81) Residual Block 2: Convolutional layer: Conv1d (channel count 64 → 128) Batch Normalization: BatchNorm1d Activation function: ReLU Convolutional layer: Conv1d (channel count 128 → 128) Batch Normalization: BatchNorm1d (From input) Skip connection: Shortcut (channel number 64 → 128) Operation: Jump, Connect, Add Activation function: ReLU Pooling layer: MaxPool1d (spectral number 81→40) Output dimensions: (128, 40) As neural networks become deeper, simply stacking convolutional layers can easily lead to gradient vanishing or network degradation, affecting the accuracy of sugar content prediction. Existing technologies use residual network models to address this issue. However, conventional residual network models only support two-dimensional image data processing and do not support one-dimensional spectral data processing; moreover, they are generally large in scale (such as 18 or 34 layers), making them unsuitable for the needs of lightweight and rapid detection.
[0034] To address this, the present invention makes two improvements, reconstructing the existing residual network model into a residual module: ① The residual network model is simplified to form a residual module containing two sub-residual blocks, each containing two convolutional layers, to reduce model complexity, improve computational efficiency, and ensure sufficient feature extraction capability. ② All two-dimensional convolutional layers, pooling layers, and batch normalization layers in the residual module are replaced with one-dimensional convolutional layers, pooling layers, and batch normalization layers, making the entire residual module suitable for processing one-dimensional spectral data.
[0035] In the residual module, skip connections directly pass the input to the convolutional ends, ensuring that low-level spectral information is not lost with deeper networks and avoiding the attenuation of key spectral features due to network deepening. The convolutional layers increase the number of feature channels from 32 to 128, focusing on extracting more subtle and complex sugar content-related features in the hyperspectral matrix (such as the superposition effect of sugars and organic acids in the near-infrared band). The addition of skip connections allows the model to simultaneously learn shallow spectral profiles and deep abstract features. The final pooling layer compresses the number of spectra to 40, highlighting spectral patterns closely related to sugar content, providing highly condensed and discriminative feature maps for subsequent overall spectral representation. The residual module includes two structurally identical sub-residual blocks, promoting further mining of deep features and improving the model's robustness in complex pre-sampling environments. Meanwhile, this design also echoes the feature enhancement technology of the input layer, achieving the following effects: it constructs a two-stage feature learning mode of "enhanced input – deep refinement". The former expands the expression range and physicochemical correlation of the input features, while the latter realizes higher-order deep feature extraction and screening on this basis, improving the model's ability to model the spectrum-sugar content relationship in complex orchard environments; at the same time, the feature enhancement module explicitly introduces nonlinear transformations in the input stage, partially replacing the burden of the backbone network implicitly learning these relationships, reducing the requirements for the complexity of the backbone network in terms of layer depth, number of neurons, etc., which is conducive to simplifying the network structure, constructing a lightweight and high real-time computing model, and enhancing its practicality in orchard edge computing.
[0036] 4. Global Average Pooling Module Model structure: Global Average Pooling Layer: Operation: AdaptiveAvgPool1d (spectral number 40 → 1) Output dimensions: (128, 1) A global adaptive average pooling operation is employed to compress the 40-dimensional features of each channel into a single mean, which is equivalent to extracting the overall intensity of the spectral response of each channel. This operation not only significantly reduces the number of parameters and avoids excessive computational complexity of fully connected layers, but also endows the model with the ability to perceive the overall spectral morphology, making sugar content prediction more dependent on the overall spectral distribution pattern rather than local noise. This enhances the model's generalization ability under interference conditions and improves the stability of pre-harvest sugar content detection.
[0037] 5. Fully Connected Module Model structure: Fully Connected Layer 1 (FC Layer 1): Linear layer: Linear (channel count 128 → 128) Activation function: ReLU Operation: Dropout Output dimensions: (128, 1) Fully Connected Layer 2 (FC Layer 2): Linear layer: (channel count changes from 128 to 64) Activation function: ReLU Operation: Dropout Output dimensions: (64, 1) A fully connected layer (linear layer) is used to integrate the 128-dimensional global features obtained by global average pooling at a high level. Then, the channel dimension is reduced from 128 to 64 to compress and integrate the abstract features, preparing the most essential relevant features for the final sugar content prediction output. The Dropout operation randomly discards some neurons during training to simulate possible anomalies or accidental noise in orchard data (such as surface damage to individual fruits or dust interference), further improving the model's fault tolerance and robustness in real orchard environments, making the model applicable to citrus sugar content prediction in different orchards and at different growth stages.
[0038] 6. Output layer Model structure: Output layer: Linear layer: Linear (channel count 64 → 1) Output dimension: (1) (i.e., the detected sugar content value) As the decision-making end of the model, the output layer outputs a final sugar content prediction value by converting the 64-dimensional high-level feature maps extracted and refined from all the preceding modules. The entire model achieves end-to-end, non-destructive detection from initial spectral data to sugar content values. This provides a feasible solution for pre-harvest operations in orchards, enabling real-time spectral imaging and sugar content feedback, which can directly serve harvesting decisions, orchard monitoring, and precision agriculture management.
[0039] Compared to conventional convolutional neural networks (CNNs) or residual networks (ResNet18), the CNN-FA-RB model in this invention improves the structure as follows, for example... Figure 6 As shown: ① Front-end feature enhancement improves the quality and richness of input information: Conventional CNN / ResNet18 directly accepts raw spectral data as input, and the model relies on its own convolutional layers to learn effective features reflecting sugar content from limited complex signals. The CNN-FA-RB model introduces a second-order polynomial feature enhancement module in the input layer. In orchard environments, factors such as changes in light intensity, fruit surface curvature, and water content cause the spectral response to be non-linearly correlated. This module mathematically expands the 25 spectral bands of the input, explicitly constructing cross-terms and square terms between bands to simulate physicochemical interactions related to sugar content (such as the synergistic expression effect of CH / OH bonds). This improvement enriches the connotation of the input information, enabling the model to have stronger feature representation capabilities and robustness when facing spectral data with low signal-to-noise ratios collected in variable environments.
[0040] ② The residual module designed for spectral data in the middle section enables deep extraction and filtering of important features: Conventional CNNs, by simply stacking convolutional layers, are prone to gradient vanishing, making it difficult to build a network deep enough to extract complex features, thus limiting the model's ability to capture deep abstract spectral patterns (such as the superimposed absorption features of sugar and multiple components). ResNet18 can solve the gradient vanishing and degradation problems in deep network training through skip connections, but too many layers can easily lead to overfitting, and the number of parameters and computation time are greatly increased. The CNN-FA-RB model simplifies the residual network model according to the actual task of "non-destructive detection of hyperspectral sugar content before harvest in orchards". It contains two residual blocks with skip connections, which progressively expand the number of channels (32→64→128) through convolution, while systematically compressing the spectral dimension in conjunction with max pooling. In an orchard environment, this structure can preserve and enhance the core spectral features related to sugar content (such as the reflection mode of fruit component content) in the deep network, while gradually filtering out irrelevant spectral fluctuations caused by random environmental noise (such as water vapor changes, dust, etc.), thereby extracting stable high-level features that are insensitive to environmental disturbances and sensitive to changes in sugar content.
[0041] ③ The compact global pooling and regularization design at the end effectively enhances robustness in complex environments: Conventional CNNs often directly flatten out convolutional layers before connecting large fully connected layers for prediction, which introduces a large number of parameters and is prone to overfitting when the amount of data is limited, affecting the detection accuracy on new samples. Although the standard ResNet18 uses global average pooling to compress the number of parameters, it does not use Dropout to prevent overfitting. The CNN-FA-RB model adopts a combination of global average pooling and Dropout, which significantly reduces the number of parameters and the risk of overfitting, and improves generalization ability. Using a global average pooling layer instead of the traditional flattening operation compresses the features of each channel into a global statistical value, forcing the model to judge from the overall response level of each channel rather than relying on certain specific local locations, thus avoiding the influence of random noise interference. Adding a Dropout layer when integrating features in the fully connected layer, by randomly dropping neurons, simulates missing values and anomalies that may occur in an orchard environment, enhancing the model's tolerance and robustness. In addition, the lightweight end-point structure makes the model easier to deploy on mobile or embedded devices, meeting the needs of real-time pre-harvest monitoring in orchards.
[0042] Furthermore, a training dataset was constructed based on hyperspectral image data and sugar content data. This training dataset was then used to train the sugar content detection model, such as... Figure 3 As shown, it specifically includes: (1) The collected hyperspectral image data and sugar content data are used to create a dataset, with the hyperspectral image data as training samples and the sugar content data as labels; (2) The threshold segmentation method is used to automatically extract the region of interest from the hyperspectral image data. The Savitzky-Golay smoothing algorithm is used to preprocess the spectral data in the region of interest. The competitive adaptive reweighted sampling method is used to extract the feature bands from the preprocessed full-band spectrum. (3) Divide the training dataset after extracting feature bands into training set, validation set and test set in a ratio of 8:1:1; (4) The training set is fed into the sugar content detection model (CNN-FA-RB model) for training to learn the mapping relationship between the feature band and the sugar content value. The sugar content detection model is adjusted with the validation set and the test set to find the optimal parameters. When the MSE (mean square error) loss value of the sugar content detection model training (see formula (3)) converges and stabilizes, the network weight of the sugar content detection model is saved to obtain the trained sugar content detection model.
[0043] MSE = (3) in, n For the number of citrus samples, y i Citrus samplesi The measured sugar content It is a citrus sample i The sugar content test value.
[0044] Furthermore, based on the trained sugar content detection model, non-destructive detection of citrus sugar content before harvest can be achieved, such as... Figure 4 As shown, it specifically includes: 1. In an orchard environment with natural light, use a portable hyperspectral imaging system or camera at a distance of about 1.5 m from the citrus tree to photograph the central part of the citrus fruit whose sugar content is to be tested, and obtain its hyperspectral image; 2. Thresholding segmentation, Savitzky-Golay smoothing algorithm, and competitive adaptive weighted sampling method were applied sequentially to the hyperspectral image to obtain 25 wavelength feature bands; 3. Load the saved network weights into the trained sugar content detection model; 4. Input the extracted 25 feature bands into the trained sugar content detection model to obtain the detected sugar content value.
[0045] Furthermore, based on a trained sugar content detection model, the spatial distribution of sugar content in citrus fruits can be visualized before harvest to observe the specific distribution of sugar content throughout the entire fruit (e.g., sun-facing / shaded side, calyx / equatorial / stem region), providing visualization and fine-grained data support for real-time monitoring and scientific research. Figure 5 As shown, it specifically includes: 1. In an orchard environment with natural light, use a portable hyperspectral imaging system or camera at a distance of about 1.5 m from the citrus tree to photograph the central part of the citrus fruit whose sugar content is to be tested, and obtain its hyperspectral image; 2. Use thresholding to segment the hyperspectral image to distinguish the foreground (i.e., the region of interest of the citrus fruit) from the background; 3. Load the saved network weights into the trained sugar content detection model; 4. For each pixel position in the foreground, read the one-dimensional hyperspectral sequence of that position in the hyperspectral image, perform spectral preprocessing using the Savitzky-Golay smoothing algorithm, extract feature bands based on the obtained 25 wavelengths, and input them into the trained sugar content detection model to obtain the sugar content value at that position. 5. Generate a sugar content matrix based on the length and width of the image, where the values of pixels at the foreground position are set to the obtained sugar content values and the values of pixels at the background position are set to -1; 6. Draw a spatial distribution map of citrus sugar content based on the sugar content matrix. The pixel colors in the spatial distribution map are converted according to the rules shown in Table 1: Table 1 Pixel Color Conversion Rules In summary, compared to traditional indoor citrus sugar content testing, which requires the use of specialized sugar content testing equipment or the construction of experimental platforms and is mainly used for post-harvest quality testing and grading of citrus, this invention uses an improved deep learning model to achieve non-destructive testing of citrus sugar content in an outdoor orchard environment before harvest. It can be applied to the judgment and analysis of citrus maturity before harvest.
[0046] Example 2 Based on the same inventive concept, the present invention also provides a pre-harvest citrus sugar content non-destructive testing system based on hyperspectral images, used to implement the method described in the foregoing embodiments. The system includes: an acquisition module, a model building module, a training module, a detection module, and a visualization module. The acquisition module is used to acquire hyperspectral image data and sugar content data of pre-harvest citrus samples; The model building module is used to build a sugar content detection model based on the improved CNN-FA-RB model; The training module is used to construct a training dataset based on hyperspectral image data and sugar content data, and to train the sugar content detection model using the training dataset; The detection module is used to perform non-destructive detection of citrus sugar content before harvest, based on a trained sugar content detection model. The visualization module is used to visualize the spatial distribution of citrus sugar content before harvest, based on a trained sugar content detection model.
[0047] Furthermore, in this embodiment, the acquisition module includes: an image acquisition unit and a sugar content acquisition unit; The image acquisition unit is used to acquire hyperspectral images of citrus samples on citrus trees using a hyperspectral imaging system, and to assign an ID number to each hyperspectral image to obtain hyperspectral image data. The sugar content acquisition unit is used to collect citrus samples after acquiring hyperspectral images, use a handheld sugar content refractometer to detect the sugar content of the citrus samples, and record the sugar content data according to the ID number of the hyperspectral image.
[0048] Furthermore, in this embodiment, the improved CNN-FA-RB model includes: an input layer with a feature enhancement module and a residual module; The input layer and feature enhancement module use second-order polynomial feature enhancement technology to expand the input feature bands into combined features; The residual module contains two sub-residual blocks, and each sub-residual block contains two convolutional layers. All two-dimensional convolutional layers, pooling layers, and batch normalization layers in the residual module are replaced with one-dimensional convolutional layers, pooling layers, and batch normalization layers.
[0049] Furthermore, in this embodiment, the training module includes: a dataset construction unit, an extraction unit, a partitioning unit, and a training adjustment unit; The dataset construction unit is used to create a training dataset from hyperspectral image data and sugar content data, where hyperspectral image data is used as training samples and sugar content data is used as labels. The extraction unit is used to automatically extract the region of interest from hyperspectral image data using a threshold segmentation method, perform spectral preprocessing on the spectral data within the region of interest using the Savitzky-Golay smoothing algorithm, and extract feature bands from the preprocessed full-band spectrum using a competitive adaptive reweighted sampling method. The partitioning unit is used to divide the training dataset after extracting feature bands into training set, validation set and test set according to a certain ratio. The training and adjustment unit is used to feed the training set into the sugar content detection model for training, adjust the parameters of the sugar content detection model with the validation set and test set, and save the network weights of the sugar content detection model after the MSE loss value of the sugar content detection model training has converged and stabilized, thus obtaining the trained sugar content detection model.
[0050] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made to the technical solutions of the present invention by those skilled in the art without departing from the spirit of the present invention should fall within the protection scope defined by the claims of the present invention.
Claims
1. A non-destructive method for pre-harvest sugar content detection of citrus fruits based on hyperspectral images, characterized in that, The method includes: Collect hyperspectral image data and sugar content data of pre-harvest citrus samples; A sugar content detection model is constructed based on the improved CNN-FA-RB model; A training dataset was constructed based on hyperspectral image data and sugar content data, and the sugar content detection model was trained using the training dataset. Based on a trained sugar content detection model, non-destructive detection and spatial distribution visualization of sugar content in citrus fruits before harvest are achieved.
2. The method according to claim 1, characterized in that, Methods for collecting hyperspectral image data and sugar content data of preharvest citrus samples include: A hyperspectral imaging system was used to acquire hyperspectral images of citrus samples from citrus trees, and each hyperspectral image was assigned an ID number to obtain hyperspectral image data. After acquiring hyperspectral images, citrus samples were collected, and the sugar content of the citrus samples was detected using a handheld sugar refractometer. The sugar content data was recorded according to the ID number of the hyperspectral image.
3. The method according to claim 2, characterized in that, The improved CNN-FA-RB model includes: an input layer with a feature enhancement module and a residual module; The input layer and feature enhancement module use second-order polynomial feature enhancement technology to expand the input feature bands into combined features; The residual module contains two sub-residual blocks, and each sub-residual block contains two convolutional layers. All two-dimensional convolutional layers, pooling layers, and batch normalization layers in the residual module are replaced with one-dimensional convolutional layers, pooling layers, and batch normalization layers.
4. The method according to claim 3, characterized in that, Methods for training a sugar content detection model using a training dataset constructed from hyperspectral image data and sugar content data include: Hyperspectral image data and sugar content data were used to create a training dataset, with hyperspectral image data serving as training samples and sugar content data serving as labels. The threshold segmentation method is used to automatically extract the region of interest from the hyperspectral image data. The Savitzky-Golay smoothing algorithm is used to preprocess the spectral data within the region of interest. The competitive adaptive reweighted sampling method is used to extract the feature bands from the preprocessed full-band spectrum. The training dataset after extracting feature bands is divided into training set, validation set and test set according to the proportions. The training set is fed into the sugar content detection model for training. The parameters of the sugar content detection model are adjusted using the validation set and the test set. When the MSE loss value of the sugar content detection model converges and stabilizes, the network weights of the sugar content detection model are saved to obtain the trained sugar content detection model.
5. A pre-harvest non-destructive testing system for citrus sugar content based on hyperspectral imaging, the system being used to implement the method described in any one of claims 1-4, characterized in that, The system includes: an acquisition module, a model building module, a training module, a detection module, and a visualization module; The acquisition module is used to acquire hyperspectral image data and sugar content data of pre-harvest citrus samples; The model building module is used to build a sugar content detection model based on the improved CNN-FA-RB model; The training module is used to construct a training dataset based on hyperspectral image data and sugar content data, and to train the sugar content detection model using the training dataset; The detection module is used to perform non-destructive detection of citrus sugar content before harvest, based on a trained sugar content detection model. The visualization module is used to visualize the spatial distribution of citrus sugar content before harvest, based on a trained sugar content detection model.
6. The system according to claim 5, characterized in that, The acquisition module includes: an image acquisition unit and a sugar content acquisition unit; The image acquisition unit is used to acquire hyperspectral images of citrus samples on citrus trees using a hyperspectral imaging system, and to assign an ID number to each hyperspectral image to obtain hyperspectral image data. The sugar content acquisition unit is used to collect citrus samples after acquiring hyperspectral images, use a handheld sugar content refractometer to detect the sugar content of the citrus samples, and record the sugar content data according to the ID number of the hyperspectral image.
7. The system according to claim 6, characterized in that, The improved CNN-FA-RB model includes: an input layer with a feature enhancement module and a residual module; The input layer and feature enhancement module use second-order polynomial feature enhancement technology to expand the input feature bands into combined features; The residual module contains two sub-residual blocks, and each sub-residual block contains two convolutional layers. All two-dimensional convolutional layers, pooling layers, and batch normalization layers in the residual module are replaced with one-dimensional convolutional layers, pooling layers, and batch normalization layers.
8. The system according to claim 7, characterized in that, The training module includes: dataset construction unit, extraction unit, partitioning unit, and training tuning unit; The dataset construction unit is used to create a training dataset from hyperspectral image data and sugar content data, where hyperspectral image data is used as training samples and sugar content data is used as labels. The extraction unit is used to automatically extract the region of interest from hyperspectral image data using a threshold segmentation method, perform spectral preprocessing on the spectral data within the region of interest using the Savitzky-Golay smoothing algorithm, and extract feature bands from the preprocessed full-band spectrum using a competitive adaptive reweighted sampling method. The partitioning unit is used to divide the training dataset after extracting feature bands into training set, validation set and test set according to a certain ratio. The training and adjustment unit is used to feed the training set into the sugar content detection model for training, adjust the parameters of the sugar content detection model with the validation set and test set, and save the network weights of the sugar content detection model after the MSE loss value of the sugar content detection model training has converged and stabilized, thus obtaining the trained sugar content detection model.
Citation Information
Cited By
A method and system for predicting sugar content of fruits based on multispectral images
CN122347802A