A method and system for detecting soil chemical components based on hyperspectral enhanced data

A hyperspectral method for detecting soil chemical components was constructed by using deep convolutional generative adversarial networks and auxiliary regression generative adversarial networks. This method solves the problems of complex sample pretreatment and long detection cycle, and enables rapid and accurate detection of soil type identification and chemical component content prediction.

CN123065985APending Publication Date: 2026-11-10江西省烟草科学研究所
0 Cites 0 Cited by

Patent Information

Application Number
CN202611269563.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-20
Publication Date
2026-11-10

AI Technical Summary

Technical Problem

Existing methods for detecting soil chemical components using hyperspectral methods suffer from complex sample pretreatment, long detection cycles, high consumption of chemical reagents, and difficulty in meeting the needs of rapid field detection. Furthermore, generative adversarial networks (GANs) struggle to maintain the correspondence between category features and content during both qualitative and quantitative detection, leading to model overfitting or decreased generalization ability.

Method used

Data augmentation was performed using deep convolutional generative adversarial networks and auxiliary regression generative adversarial networks, respectively, to construct qualitative and quantitative raw datasets. Soil type identification and chemical composition content prediction were performed using partial least squares discriminant analysis models and least squares support vector machine models, and rapid detection was achieved by combining with a hyperspectral imaging system.

Benefits of technology

It improves the accuracy, stability, and reliability of soil type identification and prediction of organic matter, total nitrogen, and available potassium content under limited sample conditions, meeting the needs of rapid field testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123065985A_ABST
    Figure CN123065985A_ABST
Patent Text Reader

Abstract

This invention relates to the field of soil testing and agricultural information technology, and discloses a method and system for detecting soil chemical components based on hyperspectral enhanced data. The method includes: acquiring hyperspectral images of soil; extracting raw spectral data through radiometric calibration; training a deep convolutional generative adversarial network (GAN) using the raw spectra of each soil type to generate qualitative spectral data and form a qualitative enhanced dataset; training an auxiliary regression GAN using raw spectra with different chemical component content gradients, inputting random noise and normalized component content into the network to generate quantitative spectral data and form a quantitative enhanced dataset; establishing a partial least squares discriminant analysis model based on the qualitative enhanced data, and establishing least squares support vector machine models for organic matter, total nitrogen, and available potassium based on the quantitative enhanced data; inputting the spectra to be tested into the models to sequentially obtain the soil type and corresponding chemical component content. This method can improve the detection effect of soil chemical components under limited hyperspectral sample conditions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of soil testing and agricultural information testing technology, and in particular to a method and system for detecting soil chemical composition based on hyperspectral enhanced data. Background Technology

[0002] Soil chemical components (such as organic matter, total nitrogen, available phosphorus, and available potassium) are core indicators for evaluating soil fertility and quality. Rapid and accurate detection of these components is crucial for precision agriculture, farmland quality monitoring, and ecological environmental protection. Traditional methods for detecting soil chemical components mainly rely on laboratory chemical analysis, including the Kjeldahl method, potassium dichromate oxidation method, molybdenum-antimony colorimetric method, and flame photometry. While these methods offer high accuracy, they suffer from drawbacks such as complex sample pretreatment, long detection cycles, high consumption of chemical reagents, and difficulty in meeting the needs of rapid field testing. Hyperspectral imaging technology can simultaneously acquire spatial image information and continuous band spectral information of soil samples. Utilizing the spectral absorption and reflection characteristics of soil organic matter, clay minerals, moisture, and nitrogen, phosphorus, and potassium chemical components in specific bands, it enables non-destructive and rapid detection of soil chemical components. However, establishing a hyperspectral soil chemical component detection model requires collecting a large number of labeled samples covering different soil types and varying chemical component content gradients. This involves a significant workload for field sampling, laboratory testing, and spectral acquisition, resulting in a limited number of effective labeled samples that can actually be obtained. When the number of samples is insufficient, the detection model struggles to fully learn the spectral differences between different soil types and the variation of spectral data with chemical component content, easily leading to overfitting or decreased generalization ability. Existing generative adversarial networks can be used to augment hyperspectral data, but soil chemical composition detection includes both qualitative detection (discrimination of soil type or dominant chemical composition category) and quantitative detection (prediction of chemical composition content). Qualitative detection needs to maintain the spectral differences between different soil categories, while quantitative detection needs to ensure that the generated spectral data accurately corresponds to the corresponding chemical composition content. If the same data augmentation method is used to process the two types of data, the generated spectral data may not be able to simultaneously maintain the correspondence between category features and content. At the same time, if the similarity and distribution consistency between the generated spectral data and the original spectral data are not verified, the reliability of the detection results may be affected when the generated data is directly used for model training.

[0003] Therefore, a method and system for detecting soil chemical components based on hyperspectral enhanced data are proposed. Summary of the Invention

[0004] The technical solution of this invention is implemented as follows: A method for detecting soil chemical components based on hyperspectral enhanced data, comprising the following steps: S1. Collect hyperspectral images of soil samples of different soil types and soil samples to be tested, perform radiometric calibration on the hyperspectral images and extract the raw spectral data, construct a qualitative raw dataset according to soil type, and construct a quantitative raw dataset according to the types and content gradients of chemical components. S2. Train a deep convolutional generative adversarial network using the original spectral data corresponding to each soil type. Generate qualitative spectral data corresponding to each soil type using the trained deep convolutional generative adversarial network. Add the qualitative spectral data to the original qualitative dataset to form a qualitatively enhanced dataset. S3. Train the auxiliary regression generative adversarial network using the original spectral data corresponding to each chemical component at different content gradients. Input the random noise and the normalized chemical component content into the trained auxiliary regression generative adversarial network to generate quantitative spectral data corresponding to the input chemical component content. Add the quantitative spectral data to the quantitative original dataset to form the quantitative augmented dataset. S4. A partial least squares discriminant analysis model is established using a qualitative augmentation dataset, and least squares support vector machine models are established for organic matter, total nitrogen and available potassium using a quantitative augmentation dataset, respectively. S5. Acquire hyperspectral images of the soil sample to be tested, perform radiometric calibration on the hyperspectral images of the soil sample to be tested and extract the spectral data to be tested, input the spectral data to be tested into the partial least squares discriminant analysis model to obtain the soil type discrimination result of the soil sample to be tested; when the soil type discrimination result is the soil type to be tested, input the spectral data to be tested into the least squares support vector machine model corresponding to the soil type discrimination result to obtain the chemical composition content detection result of the soil sample to be tested.

[0005] Furthermore, in step S1, the chemical component content in each soil type sample used to construct the qualitative raw dataset covers the typical content range of that soil type; in each chemical component sample used to construct the quantitative raw dataset, the content gradient is set to an equally spaced gradient within the conventional detection range of that chemical component, and the difference between two adjacent content gradients is set according to the detection accuracy requirements.

[0006] Further, in step S1, the soil sample preparation process includes: collecting field soil samples, air-drying them naturally, grinding and sieving them, weighing the soil samples according to the set content gradient and mixing them with the standard matrix, homogenizing the mixed soil samples, and pressing the homogenized soil samples into sheet samples or putting them into standard sample cups.

[0007] Furthermore, in steps S1 and S5, the acquisition band of the hyperspectral image is 400–1000 nm or 900–1700 nm, the spectral resolution is no greater than 5 nm, the camera exposure time is adjusted according to the light source intensity, and the moving speed of the displacement platform carrying the sample is set according to the sampling resolution requirements; a standard white board reference image and a dark reference image are acquired respectively, and the acquired hyperspectral image is radiometrically calibrated based on the white board reference image and the dark reference image.

[0008] Furthermore, the deep convolutional generative adversarial network in step S2 includes a first generator and a first discriminator; the first generator processes random noise through a fully connected mapping and a one-dimensional transposed convolution to generate qualitative spectral data with the same band dimension as the original spectral data; the first discriminator processes the original spectral data or qualitative spectral data through a one-dimensional convolution and outputs the true / false discrimination result; the first generator and the first discriminator are updated with parameters by alternating training.

[0009] Furthermore, the auxiliary regression generative adversarial network in step S3 includes a second generator and a second discriminator. The second generator takes random noise and normalized chemical component content as joint inputs, and outputs quantitative spectral data corresponding to the chemical component content after fully connected mapping. The second discriminator includes an adversarial output layer and a content regression output layer. The adversarial output layer outputs the true / false discrimination result of the original spectral data or the quantitative spectral data, and the content regression output layer outputs the corresponding chemical component content regression result. The training loss of the auxiliary regression generative adversarial network includes Wasserstein adversarial loss, mean squared error regression loss, and gradient penalty loss.

[0010] Furthermore, after forming the qualitative and quantitative augmentation datasets, the generated qualitative and quantitative spectral data are compared with the corresponding original spectral data in terms of spectral morphology and statistical distribution using average spectral curves and box plots, respectively. The structural similarity index, maximum mean difference, and Manhattan distance are calculated to verify the structural similarity and distribution consistency between the generated spectral data and the corresponding original spectral data.

[0011] Furthermore, in step S4, a continuous projection algorithm or a competitive adaptive reweighted sampling algorithm is used to extract feature wavelengths from the qualitative enhancement dataset, and a partial least squares discriminant analysis model is established without performing spectral preprocessing on the qualitative enhancement dataset; the least squares support vector machine model corresponding to different soil types selects a radial basis kernel function or a linear kernel function according to the characteristics of the spectral data of that soil type.

[0012] The present invention also provides a soil chemical composition detection system based on hyperspectral enhanced data, including a hyperspectral imaging system, a memory, and a processor connected to the hyperspectral imaging system and the memory. The hyperspectral imaging system is used to acquire hyperspectral images of different soil types and soil samples to be tested, and transmit the acquired hyperspectral images to the processor; The processor performs radiometric calibration on the hyperspectral images of samples from different soil types and extracts the raw spectral data. It then forms a qualitative raw dataset according to soil type and a quantitative raw dataset according to the types and content gradients of chemical components. The processor runs a deep convolutional generative adversarial network to generate qualitative spectral data corresponding to each soil type based on the original spectral data, and merges the qualitative spectral data with the original qualitative dataset to form a qualitatively enhanced dataset; it runs an auxiliary regression generative adversarial network to generate quantitative spectral data corresponding to the chemical component content with random noise and normalized chemical component content as joint input, and merges the quantitative spectral data with the original quantitative dataset to form a quantitatively enhanced dataset. The processor uses a qualitative augmentation dataset to build a partial least squares discriminant analysis model, and uses a quantitative augmentation dataset to build least squares support vector machine models corresponding to organic matter, total nitrogen, and available potassium, respectively; the memory is used to store deep convolutional generative adversarial network, auxiliary regression generative adversarial network, partial least squares discriminant analysis model, and least squares support vector machine models corresponding to organic matter, total nitrogen, and available potassium, respectively. The processor performs radiometric calibration on the hyperspectral image of the soil sample to be tested and extracts the spectral data to be tested. The spectral data to be tested is then input into the partial least squares discriminant analysis model to obtain the soil type discrimination result. When the soil type discrimination result is the soil type to be tested, the spectral data to be tested is input into the least squares support vector machine model corresponding to the soil type discrimination result to obtain the chemical composition content detection result.

[0013] Furthermore, the hyperspectral imaging system includes an imaging spectrometer, a displacement platform for carrying soil samples, a drive mechanism for moving the displacement platform, and an illumination unit located around the sample collection area. The imaging spectrometer has a spectral range of 400–1000 nm or 900–1700 nm and a spectral resolution of no more than 5 nm.

[0014] The embodiments of the present invention have the following advantages due to the adoption of the above technical solutions: This invention addresses the different requirements of qualitative and quantitative detection for hyperspectral augmentation data. First, it constructs qualitative and quantitative raw datasets based on soil type and chemical component content gradients, respectively. Then, it employs different generative adversarial networks (GANs) for data augmentation tailored to the two tasks. Specifically, a deep convolutional GAN ​​learns the characteristic distribution of the original spectra for each soil type to generate qualitative data with corresponding category spectral features, thus expanding the sample size while maintaining spectral differences between different soil types. An auxiliary regression GAN uses normalized chemical component content as conditional information, inputting it along with random noise, constraining the generation process by the target content, thereby establishing a correspondence between generated spectra and chemical component content. Based on the augmented data, partial least squares discriminant analysis (PLD) and least squares support vector machine (LSVM) models are established, ensuring that qualitative discrimination and quantitative prediction use data and modeling methods adapted to their respective task characteristics. This scheme implements targeted data augmentation based on two different needs: category preservation and content correspondence. This reduces the weakening of category features or the shift in content correspondence caused by a uniform augmentation method, improving the accuracy, stability, and reliability of soil type discrimination and prediction of organic matter, total nitrogen, and available potassium content under limited sample conditions. Attached Figure Description

[0015] Figure 1 This is a box plot of the DCGAN training data for this invention. Figure 2 This is a comparison diagram of the DCGAN generated spectrum and the original spectrum of the present invention; Figure 3 This is a comparison diagram of the ARGAN-generated spectrum and the original spectrum of this invention; Figure 4 This is a schematic flowchart of the soil chemical composition detection method based on hyperspectral enhanced data according to the present invention. Detailed Implementation

[0016] In the following description, only certain exemplary embodiments are briefly described. As those skilled in the art will recognize, the described embodiments can be modified in various ways without departing from the spirit or scope of the invention. Therefore, the drawings and description are considered to be exemplary in nature and not restrictive.

[0017] Refer to the instruction manual appendix Figure 1 The diagram shows a box plot of DCGAN training data provided by an embodiment of the present invention.

[0018] Figure 1This section evaluates the effectiveness of data augmentation. The four graphs show the effects of four different chemical component concentrations. The horizontal axis compares the data augmentation model with the original data (real) after 500, 1000, and 1500 runs. The closer the square is to the original data (real), the better the augmentation effect at that number of runs. The vertical axis represents the spectral reflectance value.

[0019] Refer to the instruction manual appendix Figure 2 The image shows a comparison between the generated spectrum and the original spectrum of a DCGAN provided in an embodiment of the present invention.

[0020] Figure 2 The horizontal axis represents the range of spectral wavelengths, and the vertical axis represents the spectral reflectance value. The red line represents the spectrum after data enhancement, and the blue-green line represents the original spectrum. The four graphs show four different cases with varying concentrations of chemical components. The closer the red and blue lines are, the better the enhancement effect.

[0021] Refer to the instruction manual appendix Figure 3 The image shows a comparison between the generated spectrum and the original spectrum of an ARGAN provided by an embodiment of the present invention.

[0022] Figure 3 : This is the enhanced spectrum of multiple data points (at different concentrations), compared with Figure 2 The meaning is the same.

[0023] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0024] This invention provides a method for detecting soil chemical components based on hyperspectral enhanced data. First, hyperspectral images of different soil types (such as red soil, black soil, and alluvial soil) are acquired, and the raw spectral data are extracted after radiometric calibration. Considering the characteristics of data for soil type identification and chemical component content prediction, deep convolutional generative adversarial networks (GANs) and auxiliary regression GANs are used for data enhancement, forming qualitative and quantitative enhanced datasets. Subsequently, partial least squares discriminant analysis (PLD) and least squares support vector machine (LSVM) models are established to identify the soil type of the soil sample to be tested, and after determining the soil type, the contents of its organic matter, total nitrogen, available potassium, and other chemical components are predicted.

[0025] Example 1 In this embodiment, three typical soil types—red soil, black soil, and alluvial soil—were collected as experimental subjects, with organic matter, total nitrogen, and available potassium as the target chemical components.

[0026] Based on the testing task, the samples are divided into qualitative analysis samples and quantitative analysis samples.

[0027] The qualitative analysis samples included red soil samples, black soil samples, and alluvial soil samples, with 40 samples for each soil type. The samples were collected from typical distribution areas of the soil type, and the chemical composition content covered the conventional content range of the soil type.

[0028] Quantitative analysis samples were prepared with concentration gradients for three chemical components: organic matter, total nitrogen, and available potassium. For example, the concentration gradient for organic matter was set at 0.5%–5.0%, with a difference of 0.5% between adjacent gradients, and each gradient corresponded to 10 samples. The concentration gradient for total nitrogen was set at 0.05%–0.50%, with a difference of 0.05% between adjacent gradients. The concentration gradient for available potassium was set at 50–150 mg / kg, with a difference of 10 mg / kg between adjacent gradients.

[0029] During sample preparation, after collecting field soil samples, they were air-dried indoors, and after removing plant residues and stones, they were ground and sieved through a 2mm sieve. For quantitative analysis samples, the content of the target chemical components in the soil samples was adjusted according to the set content gradient using the standard addition method or dilution method. The treated soil samples were placed in 50mL centrifuge tubes and homogenized using a vortex mixer at 2500rpm for 2 minutes to ensure that the soil samples were fully homogenized.

[0030] After mixing, weigh 200 mg of soil sample and press it under 10 t pressure for 1 min to form a sheet sample with a diameter of 13 mm and a thickness of 0.8–1.1 mm; or directly put the soil sample into a standard sample cup and compact it to a uniform height so that the various samples have relatively consistent physical morphology and reduce the impact of sample surface state differences on subsequent hyperspectral data acquisition.

[0031] Example 2 In this embodiment, a hyperspectral imaging system was used to acquire hyperspectral images of the soil samples prepared in Example 1.

[0032] The hyperspectral imaging system includes a computer, an imaging spectrometer, a displacement platform for carrying the sample, a drive mechanism for moving the displacement platform, and an illumination unit located around the sample acquisition area.

[0033] In this embodiment, the imaging spectrometer can be a GaiaField-V10 or a near-infrared hyperspectral imager with a spectral range of 400–1000 nm or 900–1700 nm and a spectral resolution of 2.5–5 nm; the displacement platform is a precision displacement platform and the drive mechanism is a stepper motor; the illumination unit includes a halogen lamp or an LED light source.

[0034] When acquiring hyperspectral images, the camera exposure time is set to 5–15 ms based on the light source intensity, the displacement platform movement speed is set to 10–15 mm / s, and the sample acquisition process is carried out in a closed space to reduce the impact of ambient light changes on hyperspectral image acquisition.

[0035] Before acquisition, turn on the hyperspectral imaging system and warm it up for 30 minutes. Adjust the system imaging parameters and focal length using the image acquisition software until the preview image can clearly display the sample.

[0036] Hyperspectral images are acquired according to the following procedure: S101. Place soil samples at intervals on the displacement platform; S102. After previewing the image acquisition software and confirming the sample position and imaging status, start image acquisition. The drive mechanism moves the displacement platform so that the imaging spectrometer can complete the hyperspectral image acquisition of the corresponding sample area. S103. Save the acquired hyperspectral image to the computer. The hyperspectral image contains the spatial image information of the sample and the spectral information corresponding to different bands.

[0037] Because the CCD or InGaAs detectors in imaging spectrometers have dark currents during operation and are prone to noise in low-intensity bands, radiometric calibration is performed on the acquired hyperspectral images before extracting the raw spectral data.

[0038] During radiometric calibration, while keeping the lens focal length and camera acquisition parameters unchanged, the lens is aimed at a standard white reference board to acquire a white reference image; then, while maintaining the current focus, the lens is closed and a dark reference image is acquired; the hyperspectral image of the soil sample is radiometrically calibrated using the white reference image and the dark reference image, and the original spectral data is extracted from the calibrated hyperspectral image.

[0039] The soil samples to be tested were processed using the same hyperspectral acquisition conditions and radiometric calibration methods to obtain the spectral data to be tested.

[0040] Example 3 Spectral data is extracted from the hyperspectral images that have undergone radiometric calibration. In this embodiment, each set of spectral data includes hundreds of band dimensions (the specific number of bands depends on the spectral resolution of the imaging spectrometer).

[0041] According to soil type, the original spectral data of red soil samples, black soil samples and alluvial soil samples were assigned corresponding category labels, thereby constructing a qualitative original dataset.

[0042] Based on the types and content gradients of chemical components, the original spectral data of organic matter, total nitrogen, and available potassium samples at different content gradients were assigned corresponding content labels, thereby constructing quantitative raw datasets for the three chemical components respectively.

[0043] Comparison of the average spectral curves of different soil samples shows that the spectral curves of different soil types have certain commonalities in the overall trend, but there are differences in specific bands (such as the water absorption bands near 1400nm and 1900nm, and the visible light band related to organic matter), indicating that there are spectral differences between different soil types for type identification.

[0044] Principal component analysis was further used to analyze the original spectral data. After standardization, the original data underwent linear orthogonal transformation. Principal components with a cumulative variance contribution rate of not less than 85% were selected according to the eigenvalues. As the number of principal components increased, the root mean square error of the modeling set and the prediction set decreased overall. When the number of principal components was 9, the root mean square error of the prediction set reached the lowest value. After further increasing the number of principal components, the root mean square error of the prediction set increased slightly and gradually stabilized. Therefore, the number of principal components obtained in this embodiment was 9.

[0045] Among the main scattered point distributions, red soil, black soil and alluvial soil samples showed a certain clustering trend, but there were still cases of crossover of scattered points between different categories of samples. Therefore, partial least squares discriminant analysis model was further used to distinguish soil types.

[0046] For spectral preprocessing, this embodiment uses SG smoothing, multivariate scattering correction (MSC), and standard normal variable transformation (SNV) for comparative analysis. In the subsequent qualitative model comparison, the original spectrum, the spectrum after SG smoothing and MSC combined processing, and the spectrum after wavelet transform and SG smoothing combined processing are modeled and compared.

[0047] Example 4 This embodiment uses a deep convolutional generative adversarial network to augment the qualitative original dataset. The deep convolutional generative adversarial network includes a first generator and a first discriminator.

[0048] The first generator takes 100-dimensional random noise as input. It first maps the 100-dimensional random noise into a feature tensor through a fully connected layer, and then performs upsampling processing through two one-dimensional transposed convolutional layers to finally generate qualitative spectral data with the same band dimension as the original spectral data.

[0049] The first generator restricts the output to the range of 0 to 1 using the Sigmoid activation function to correspond to the normalized range of spectral reflectance values; during training, batch normalization and ReLU activation are used to improve training stability.

[0050] The first discriminator takes the original spectral data or the qualitative spectral data generated by the first generator as input, and extracts spectral features by passing them through two one-dimensional convolutional layers. Then, the convolutional processing results are flattened and input into a fully connected layer, and the true / false discrimination result is output through the Sigmoid activation function. Dropout is set during training to reduce overfitting.

[0051] The first generator and the first discriminator are trained alternately to update their parameters. When training the first discriminator, the original spectral data and the qualitative spectral data generated by the first generator are input into the first discriminator respectively, so that the first discriminator learns the distribution differences between the two types of data. When training the first generator, the parameters of the first discriminator are fixed, and the generated qualitative spectral data are gradually made to approach the distribution of the original spectral data of the corresponding soil type by updating the parameters of the first generator.

[0052] The deep convolutional generative adversarial network uses binary cross-entropy as the loss function and the Adam optimizer for parameter updates. The learning rate is set to 0.0002 and the first momentum parameter beta1 is set to 0.5.

[0053] The training was conducted using the original spectral data corresponding to red soil, black soil, and alluvial soil samples, and the training rounds were determined by comparing the generated spectral data with the original spectral data under different training rounds.

[0054] The training rounds for red soil are 1000; the training rounds for black soil are 1500; and the training rounds for alluvial soil are 1500.

[0055] By comparing the median, interquartile range, mean, and overall distribution of the generated spectral data with the original spectral data at different training rounds, it can be seen that the number of training rounds required for different soil types to achieve a relatively stable data distribution varies. Accordingly, this embodiment uses 1000 rounds, 1500 rounds, and 1500 rounds as the training rounds for the deep convolutional generative adversarial networks corresponding to red soil, black soil, and alluvial soil, respectively.

[0056] The first generator trained above is used to generate qualitative spectral data for red soil, black soil and alluvial soil respectively, and assign corresponding category labels. The qualitative spectral data is then added to the original qualitative dataset to form a qualitatively enhanced dataset.

[0057] Example 5 This embodiment employs an auxiliary regression generative adversarial network (GAN) to enhance the quantitative original dataset. The auxiliary regression GAN is a generative adversarial network that adds content regression constraints to the WGAN-GP structure, and includes a second generator and a second discriminator.

[0058] The second generator takes 32-dimensional random noise and 1-dimensional normalized chemical composition content as joint inputs, concatenates them, and maps them to 64-dimensional features through a fully connected layer. It then performs non-linear processing using a LeakyReLU activation function with a negative slope of 0.2 and sets a Dropout layer with a dropout ratio of 0.3. Subsequently, the 64-dimensional features are further mapped to 128-dimensional features, and LeakyReLU activation and Dropout processing are performed again. Finally, the output layer generates quantitative spectral data with the same band dimensions as the original spectral data.

[0059] The output layer of the second generator uses the Tanh activation function to limit the output to the range of -1 to 1, corresponding to the normalized spectral reflectance. By using the normalized chemical component content and random noise as input, the generated quantitative spectral data corresponds to the input chemical component content.

[0060] The second discriminator takes the original spectral data or the quantitative spectral data generated by the second generator as input, and performs feature extraction through a fully connected layer with spectral normalization. The extracted feature dimension is reduced from 128 dimensions to 64 dimensions, and is processed by a LeakyReLU activation function with a negative slope of 0.2.

[0061] The second discriminator includes an adversarial output layer and a content regression output layer. The adversarial output layer outputs an unconstrained adversarial judgment value, which is used to calculate the Wasserstein adversarial loss. The content regression output layer outputs the corresponding chemical component content regression results, which are used to establish the relationship between the input spectral data and the chemical component content.

[0062] The auxiliary regression generative adversarial network uses an alternating training method, where the second generator is trained five times for each training iteration of the second discriminator.

[0063] When training the second discriminator, the original spectral data with content labels and the quantitative spectral data generated by the second generator are respectively input into the second discriminator. Wasserstein adversarial loss and mean square error regression loss are calculated for the original spectral data, and Wasserstein adversarial loss is calculated for the quantitative spectral data. At the same time, a gradient penalty is set to constrain the Lipschitz continuity of the second discriminator, and the gradient penalty weight is 10.

[0064] When training the second generator, the network parameters of the second discriminator are fixed. While reducing the ability of the second discriminator to distinguish between the generated spectral data and the original spectral data, the difference between the chemical component content regression result output by the second discriminator and the input chemical component content is reduced. The content regression loss weight is 2.0.

[0065] The second generator and the second discriminator both use the Adam optimizer for parameter updates, with a learning rate of 0.00005, a first momentum parameter of 0.5, and a second momentum parameter of 0.999. During training, an early stopping mechanism is used, and data augmentation is performed using noise addition, spectral shifting, and amplitude scaling.

[0066] The corresponding auxiliary regression generative adversarial networks were trained using the original spectral data of organic matter, total nitrogen, and available potassium at different content gradients. After training, random noise and normalized chemical component content were input into the second generator to generate quantitative spectral data corresponding to the content.

[0067] The generated quantitative spectral data are labeled with the corresponding chemical components and their contents, and then added to the corresponding quantitative original dataset to form quantitative enhanced datasets for organic matter, total nitrogen, and available potassium.

[0068] Test Example 1 To verify the consistency between the spectral data generated by the deep convolutional generative adversarial network and the auxiliary regression generative adversarial network and the corresponding original spectral data, this test case uses the average spectral curve, box plot, structural similarity index, maximum mean difference, and Manhattan distance for comparison.

[0069] The box plot determines the first quartile Q1, median Q2, and third quartile Q3 based on the spectral data sorted from smallest to largest. Q1 and Q3 form a box, and the difference between Q3 and Q1 is used as the interquartile range (IQR). 1.5 times the IQR is used as the outlier detection range. At the same time, the data mean is marked. This allows for a comparison of the central tendency and dispersion of the generated spectral data and the original spectral data.

[0070] For qualitative spectral data generated by deep convolutional generative adversarial networks, the average spectral curves for each soil type are calculated. For quantitative spectral data generated by auxiliary regression generative adversarial networks, the average spectral curves for each chemical component under different content gradients are calculated and compared with the corresponding original spectral data.

[0071] The average spectral curves of the qualitative spectral data generated by the deep convolutional generative adversarial network (DBGAN) and the corresponding original spectral data were calculated and compared. The average spectral curves show that the generated qualitative spectral data and the corresponding original spectral data have similar overall trends within the acquisition band range. The curve changes at the main band positions are basically corresponding, with only slight differences in some bands. This indicates that the data generated by the DBGAN can maintain the main spectral characteristics of the corresponding soil type.

[0072] Further quantitative evaluation was conducted using the Structural Similarity Index (SSIM), Maximum Mean Difference (MMD), and Manhattan Distance (MD). SSIM, ranging from 0 to 1, was used to evaluate the structural similarity between the two sets of data; MMD was used to evaluate the distributional differences between the two sets of data in the feature space; and MD was used to evaluate the overall deviation between the corresponding band dimensions of the two sets of data.

[0073] In the evaluation results of the qualitative spectral data generated by the deep convolutional generative adversarial network and the corresponding original spectral data, the SSIM of the three types of soil samples were all higher than 0.99, MMD was lower than 0.25, and MD was lower than 0.65, indicating that the generated data and the original data have a high degree of structural similarity and distribution consistency.

[0074] Further comparisons were made between the quantitative spectral data generated by the auxiliary regression generative adversarial network (GAN). It can be seen that under different content gradients, the generated quantitative spectral data maintains the corresponding trend of the original spectral data. The changes in the main reflection peaks, curve inflection points, and characteristic band regions are basically consistent, indicating that the auxiliary regression GAN can preserve the spectral characteristics of different chemical components and reflect spectral changes under different content gradients when generating spectral data. To further verify the structural similarity and data distribution consistency between the quantitative spectral data and the original spectral data, SSIM, MMD, and MD were calculated. The SSIM values ​​for organic matter, total nitrogen, and available potassium were all higher than 0.998, the MMD values ​​were lower than 0.08, and the MD values ​​were lower than 0.52, indicating that the quality of the generated data meets the requirements for subsequent modeling.

[0075] The aforementioned average spectral curves, box plots, and quantitative evaluation indicators are used together to determine the spectral structure similarity and data distribution consistency between the generated spectral data and the corresponding original spectral data. The generated spectral data verified above is then used to establish the subsequent detection model.

[0076] Test Example 2 This test case uses red soil, black soil, and alluvial soil samples for qualitative analysis.

[0077] The spectral data corresponding to the qualitative analysis samples were divided into a modeling set, a validation set, and a prediction set in a 6:2:2 ratio. The continuous projection algorithm was used to extract feature wavelengths from the qualitative enhancement dataset, and the partial least squares discriminant analysis method was used to establish a soil type discrimination model.

[0078] To compare the impact of data augmentation and different spectral processing methods on the model results, we used both the original qualitative dataset and the qualitatively augmented dataset for modeling, and set up three data processing methods for comparison: Raw indicates that no spectral preprocessing is performed; SG+MSC indicates that a combination of SG smoothing and multivariate scattering correction was used for processing; Wavelet+SG indicates that the processing is combined with wavelet transform and SG smoothing.

[0079] The correlation coefficient Rp and the determination coefficient Rp of the prediction set are used as the basis for the prediction set. 2 The root mean square error (RMSEP) of the prediction was used as the evaluation index.

[0080] The test results show that, under the same data processing method, the Rp and Rp² of the model built with the qualitative augmentation dataset are higher than those of the model built with the original qualitative dataset, and the corresponding RMSEP is lower.

[0081] Among them, without spectral preprocessing, the partial least squares discriminant analysis model established using the qualitatively enhanced dataset has an Rp greater than 0.95, an Rp² greater than 0.92, and an RMSEP less than 0.33. Among the three data processing methods used in this test case, the model evaluation index corresponding to this set of results is better. Therefore, the partial least squares discriminant analysis model was established using the qualitatively enhanced dataset without spectral preprocessing.

[0082] When testing, the spectral data of the soil sample to be tested are input into the established partial least squares discriminant analysis model to obtain the soil type discrimination result of red soil, black soil or alluvial soil.

[0083] Test Example 3 This test example quantitatively analyzed organic matter, total nitrogen, and available potassium, with the content of each chemical component covering the conventional detection range.

[0084] The data corresponding to each chemical component were divided into a modeling set, a validation set, and a prediction set in a ratio of 6:2:2. Least square support vector machine models were established using radial basis function and linear kernel function, respectively. The prediction set correlation coefficient Rp, prediction set determination coefficient Rp², and prediction root mean square error RMSEP were used to evaluate the model.

[0085] We used both the original quantitative dataset and the quantitative augmented dataset formed after enhancement by the auxiliary regression generative adversarial network for modeling.

[0086] The test results show that, in the quantitative detection of the three chemical components, the overall model evaluation index was improved after modeling with the quantitative augmentation dataset.

[0087] For organic matter, the least squares support vector machine model established using the quantitative augmentation dataset and radial basis kernel function has an Rp greater than 0.95, an Rp² greater than 0.91, and an RMSEP less than 0.06%.

[0088] For total nitrogen, the least squares support vector machine model established using a quantitative augmentation dataset and a linear kernel function has an Rp greater than 0.96, an Rp² greater than 0.92, and an RMSEP less than 0.005%.

[0089] For readily available potassium, the model established using quantitative augmentation datasets and radial basis kernel functions has an Rp greater than 0.98, an Rp² greater than 0.97, and an RMSEP less than 3.5 mg / kg.

[0090] In actual testing, the soil type of the soil sample to be tested is first determined by the partial least squares discriminant analysis model. When the soil type is red soil, the spectral data to be tested is input into the least squares support vector machine model corresponding to the red soil for organic matter, total nitrogen, and available potassium. When the soil type is black soil or alluvial soil, the chemical composition detection model under the corresponding soil type is called to obtain the content detection results of each chemical component.

[0091] When the soil type discrimination result output by the partial least squares discriminant analysis model is consistent with the soil type in the training set, the system completes the soil chemical composition detection in the order of first performing soil type discrimination and then calling the corresponding quantitative detection model based on the soil type discrimination result, so that qualitative spectral data enhancement, quantitative spectral data enhancement, soil type discrimination and chemical composition content detection form a complete data processing flow.

[0092] Example 6 This embodiment provides a soil chemical composition detection system based on hyperspectral enhanced data, including a hyperspectral imaging system, a memory, and a processor connected to the hyperspectral imaging system and the memory.

[0093] The hyperspectral imaging system includes an imaging spectrometer, a displacement platform for carrying Panax notoginseng powder samples, a drive mechanism for moving the displacement platform, and an illumination unit located around the sample acquisition area.

[0094] The hyperspectral imaging system includes an imaging spectrometer, a displacement platform for carrying soil samples, a drive mechanism for moving the displacement platform, and an illumination unit located around the sample acquisition area.

[0095] In this embodiment, the imaging spectrometer can be a GaiaField-V10 or a near-infrared hyperspectral imager with a spectral range of 400–1000 nm or 900–1700 nm and a spectral resolution of 2.5–5 nm; the displacement platform is a precision displacement platform; the drive mechanism is a stepper motor; and the illumination unit includes a halogen lamp or an LED light source.

[0096] The memory contains programs for performing image radiometric calibration and spectral data extraction, a deep convolutional generative adversarial network, an auxiliary regression generative adversarial network, a partial least squares discriminant analysis model, and least squares support vector machine models corresponding to organic matter, total nitrogen, and available potassium, respectively.

[0097] During the detection model establishment phase, the hyperspectral imaging system acquires hyperspectral images of soil samples of different types and transmits the hyperspectral images to the processor.

[0098] The processor performs radiometric calibration on the hyperspectral image based on the standard white reference image and dark reference image, extracts the original spectral data from the calibrated hyperspectral image, and forms a qualitative raw dataset according to soil type and a quantitative raw dataset according to the type and content gradient of chemical components.

[0099] The processor runs a deep convolutional generative adversarial network to generate qualitative spectral data corresponding to each soil type based on the original spectral data. The generated qualitative spectral data is then merged with the original qualitative dataset to form a qualitatively enhanced dataset. A partial least squares discriminant analysis model is then established using the qualitatively enhanced dataset.

[0100] The processor runs an auxiliary regression generative adversarial network, taking random noise and normalized chemical component content as joint inputs to generate quantitative spectral data corresponding to the input chemical component content. The generated quantitative spectral data is then merged with the corresponding quantitative original dataset to form a quantitative augmentation dataset. Least squares support vector machine models for organic matter, total nitrogen, and available potassium are established using the corresponding quantitative augmentation datasets.

[0101] During the soil sample testing phase, the soil sample is placed on a displacement platform, and the hyperspectral imaging system acquires the hyperspectral image of the soil sample under the same acquisition conditions as in the model establishment phase. The processor performs radiometric calibration on the hyperspectral image of the soil sample and extracts the spectral data to be tested.

[0102] The processor inputs the spectral data to be tested into the partial least squares discriminant analysis model to obtain the soil type discrimination result of the soil sample to be tested.

[0103] When the soil type identification result is consistent with the training set type, the processor calls the least squares support vector machine model corresponding to the soil type for organic matter, total nitrogen, and available potassium, inputs the spectral data to be tested into the corresponding model, and obtains the chemical composition content detection results of the soil sample to be tested.

[0104] Therefore, the system completes the detection of soil chemical components by first identifying the soil type and then calling the corresponding quantitative detection model based on the soil type identification results, thus forming a complete data processing flow of qualitative spectral data enhancement, quantitative spectral data enhancement, soil type identification, and chemical component content detection.

[0105] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various variations or substitutions within the technical scope disclosed in the present invention, and these should all be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A method for detecting soil chemical components based on hyperspectral enhanced data, characterized in that, Includes the following steps: S1. Collect hyperspectral images of soil samples of different soil types and soil samples to be tested, perform radiometric calibration on the hyperspectral images and extract raw spectral data, construct a qualitative raw dataset according to soil type, and construct a quantitative raw dataset according to chemical composition type and content gradient. S2. Train a deep convolutional generative adversarial network using the original spectral data corresponding to each soil type. Generate qualitative spectral data corresponding to each soil type using the trained deep convolutional generative adversarial network. Add the qualitative spectral data to the qualitative original dataset to form a qualitative enhanced dataset. S3. Train the auxiliary regression generative adversarial network using the original spectral data corresponding to each chemical component at different content gradients. Input the random noise and the normalized chemical component content into the trained auxiliary regression generative adversarial network to generate quantitative spectral data corresponding to the input chemical component content. Add the quantitative spectral data to the quantitative original dataset to form a quantitative enhanced dataset. S4. A partial least squares discriminant analysis model is established using the qualitative augmentation dataset, and least squares support vector machine models corresponding to organic matter, total nitrogen and available potassium are established using the quantitative augmentation dataset respectively. S5. Acquire hyperspectral images of the soil sample to be tested, perform radiometric calibration on the hyperspectral images of the soil sample to be tested and extract the spectral data to be tested, input the spectral data to be tested into a partial least squares discriminant analysis model to obtain the soil type discrimination result of the soil sample to be tested; when the soil type discrimination result is the soil type to be tested, input the spectral data to be tested into the least squares support vector machine model corresponding to the soil type discrimination result to obtain the chemical composition content detection result of the soil sample to be tested.

2. The method for detecting soil chemical components based on hyperspectral enhanced data according to claim 1, characterized in that, In step S1, the chemical composition content of each soil type sample used to construct the qualitative raw dataset covers the typical content range of that soil type; in each chemical composition sample used to construct the quantitative raw dataset, the content gradient is set to an equally spaced gradient within the conventional detection range of that chemical composition, and the difference between two adjacent content gradients is set according to the detection accuracy requirements.

3. The method for detecting soil chemical components based on hyperspectral enhanced data according to claim 1, characterized in that, In step S1, the soil sample preparation process includes: collecting field soil samples, air-drying them naturally, grinding and sieving them, weighing the soil samples according to the set content gradient and mixing them with the standard matrix, homogenizing the mixed soil samples, and pressing the homogenized soil samples into sheet samples or putting them into standard sample cups.

4. The method for detecting soil chemical components based on hyperspectral enhanced data according to claim 1, characterized in that, In steps S1 and S5, the acquisition band of the hyperspectral image is 400–1000 nm or 900–1700 nm, the spectral resolution is no greater than 5 nm, the camera exposure time is adjusted according to the light source intensity, and the moving speed of the displacement platform carrying the sample is set according to the sampling resolution requirements. A standard white reference image and a dark reference image are acquired separately, and the acquired hyperspectral image is radiometrically calibrated based on the white reference image and the dark reference image.

5. The method for detecting soil chemical components based on hyperspectral enhanced data according to claim 1, characterized in that, The deep convolutional generative adversarial network in step S2 includes a first generator and a first discriminator; the first generator processes random noise through a fully connected mapping and a one-dimensional transposed convolution to generate qualitative spectral data with the same band dimension as the original spectral data; the first discriminator processes the original spectral data or qualitative spectral data through a one-dimensional convolution and outputs the true / false discrimination result; The first generator and the first discriminator are updated with parameters through alternating training.

6. The method for detecting soil chemical components based on hyperspectral enhanced data according to claim 1, characterized in that, The auxiliary regression generative adversarial network in step S3 includes a second generator and a second discriminator. The second generator takes random noise and normalized chemical component content as joint inputs, and outputs quantitative spectral data corresponding to the chemical component content after fully connected mapping. The second discriminator includes an adversarial output layer and a content regression output layer. The adversarial output layer outputs the true / false discrimination result of the original spectral data or quantitative spectral data, and the content regression output layer outputs the corresponding chemical component content regression result. The training loss of the auxiliary regression generative adversarial network includes Wasserstein adversarial loss, mean squared error regression loss, and gradient penalty loss.

7. The method for detecting soil chemical components based on hyperspectral enhanced data according to claim 1, characterized in that, After generating qualitative and quantitative augmentation datasets, the generated qualitative and quantitative spectral data are compared with the corresponding original spectral data in terms of spectral morphology and statistical distribution using average spectral curves and box plots, respectively. The structural similarity index, maximum mean difference, and Manhattan distance are calculated to verify the structural similarity and distribution consistency between the generated spectral data and the corresponding original spectral data.

8. The method for detecting soil chemical components based on hyperspectral enhanced data according to claim 1, characterized in that, In step S4, a continuous projection algorithm or a competitive adaptive reweighted sampling algorithm is used to extract feature wavelengths from the qualitative enhancement dataset, and a partial least squares discriminant analysis model is established without performing spectral preprocessing on the qualitative enhancement dataset. The least squares support vector machine model corresponding to different soil types selects a radial basis kernel function or a linear kernel function according to the characteristics of the spectral data of that soil type.

9. A soil chemical composition detection system based on hyperspectral enhanced data, comprising a hyperspectral imaging system, a memory, and a processor connected to the hyperspectral imaging system and the memory; The hyperspectral imaging system is used to acquire hyperspectral images of different soil types and soil samples to be tested, and to transmit the acquired hyperspectral images to the processor. The processor performs radiometric calibration on the hyperspectral images of samples from different soil types and extracts the raw spectral data. It then forms a qualitative raw dataset according to soil type and a quantitative raw dataset according to the types and content gradients of chemical components. The processor runs a deep convolutional generative adversarial network to generate qualitative spectral data corresponding to each soil type based on the original spectral data, and merges the qualitative spectral data with the original qualitative dataset to form a qualitatively enhanced dataset; it also runs an auxiliary regression generative adversarial network to generate quantitative spectral data corresponding to the chemical component content using random noise and normalized chemical component content as joint inputs, and merges the quantitative spectral data with the original quantitative dataset to form a quantitatively enhanced dataset. The processor uses the qualitative augmentation dataset to establish a partial least squares discriminant analysis model, and uses the quantitative augmentation dataset to establish least squares support vector machine models corresponding to organic matter, total nitrogen, and available potassium, respectively; the memory is used to store the deep convolutional generative adversarial network, the auxiliary regression generative adversarial network, the partial least squares discriminant analysis model, and the least squares support vector machine models corresponding to organic matter, total nitrogen, and available potassium, respectively. The processor performs radiometric calibration on the hyperspectral image of the soil sample to be tested and extracts the spectral data to be tested. The spectral data to be tested is then input into a partial least squares discriminant analysis model to obtain a soil type discrimination result. When the soil type discrimination result is the soil type to be tested, the spectral data to be tested is input into a least squares support vector machine model corresponding to the soil type discrimination result to obtain a chemical component content detection result.

10. The soil chemical composition detection system based on hyperspectral enhanced data according to claim 9, wherein the hyperspectral imaging system includes an imaging spectrometer, a displacement platform for carrying soil samples, a drive mechanism for driving the displacement platform to move, and an illumination unit disposed around the sample collection area, wherein the spectral range of the imaging spectrometer is 400–1000 nm or 900–1700 nm, and the spectral resolution is not greater than 5 nm.