Detection method, system and storage medium for moisture content of Daqu based on spectral reconstruction
Through the detection method based on spectral reconstruction, the existing Daqu moisture detection technology has been solved, and the rapid, accurate and non-destructive testing of Daqu moisture content is achieved, which is suitable for the needs of modern production.
Patent Information
- Application Number
- CN202411719018.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2044-11-28
AI Technical Summary
The existing Daqu moisture detection technology has cumbersome operation, complex sample processing, and long detection cycle, which cannot meet the fast and accurate detection needs of modern production.
Using a detection method based on spectral reconstruction, the hyperspectral data and pseudo-RGB images of the large jing samples were obtained through the hyperspectral imaging system, black and white correction and resampling were performed, and the spectral reconstruction model was established to achieve accurate detection of the large jing moisture content.
It achieves rapid, accurate and non-destructive testing of Daqu moisture content, which is suitable for online testing needs, improves detection efficiency and accuracy, and meets the needs of improving the quality of liquor brewing.
Smart Images

Figure CN119198590B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of Daqu detection, and in particular relates to a detection method, system and storage medium for reconstructing the moisture content of Daqu based on spectrum. Background Art
[0002] In the brewing of solid liquor, the moisture content of Daqu is one of the important indicators to measure its quality. Appropriate moisture content can promote the good growth and metabolism of microorganisms, and then promote the production of various enzymes and flavor substances, thereby improving the taste and quality of liquor.
[0003] The traditional method of testing the moisture content of Daqu mainly adopts the constant weight method. However, this method is extremely cumbersome to operate, the sample processing is complicated, and the testing cycle is long. It cannot meet the needs of modern production for fast and accurate testing. In recent years, emerging detection methods such as image detection technology, spectral detection technology and hyperspectral detection technology have emerged one after another. Although image detection technology can extract the color, texture and other characteristics of the material for detection, its accuracy is poor; spectral detection technology can obtain the spectral information within the specified band of the object to be tested, but it cannot obtain the surface image of the material; although hyperspectral imaging technology combines spectral and imaging technology and can simultaneously obtain the image and spectral information of the target object, the system structure is complex, inconvenient to carry, has strict requirements on external conditions, and takes a long time to obtain data, making it difficult to be widely used in actual production. Summary of the invention
[0004] The purpose of the present invention is to provide a method for reconstructing a large area of the spectrum based on the above-mentioned shortcomings of the prior art.
[0005] The invention discloses a method, system and storage medium for detecting the moisture content of qu, and utilizes spectral reconstruction technology to realize accurate detection of the moisture content of qu during the fermentation process. The method is convenient, fast and non-destructive, and can realize online detection.
[0006] To achieve the above object, the present invention adopts the following technical solution:
[0007] The first object of the present invention is to provide a method for detecting the moisture content of Daqu based on spectral reconstruction, comprising the following specific steps:
[0008] S1. Obtain a Daqu sample, obtain the hyperspectral data of the Daqu sample and the corresponding pseudo RGB image through a hyperspectral imaging system, and eliminate the influence of illumination and camera dark current working instability through black and white correction;
[0009] S2, resampling the hyperspectral data obtained in step S1, and inputting the resampled hyperspectral data and its corresponding pseudo RGB image into a multi-level spectrum converter network to establish a mapping relationship between the two, and establishing a spectrum reconstruction model;
[0010] S3, taking a real RGB image of the Daqu sample, inputting the real RGB image into the spectral reconstruction model, obtaining reconstructed hyperspectral data, and selecting a region of interest from the real RGB image and extracting spectral data;
[0011] S4, preprocessing the extracted spectral data, and measuring the moisture content of the Daqu sample by constant weight method, and making the two data correspond one by one to form a data set together; dividing the data set into a calibration set and a test set, establishing a prediction model of the preprocessed spectral data and moisture content on the calibration set, and evaluating it through the test set, and finally determining the performance of the detection model;
[0012] S5. Input the reconstructed spectral data of the Daqu sample to be tested into the detection model in step S4 to detect the moisture content in the Daqu sample.
[0013] Furthermore, in step S1, the hyperspectral imaging system collects the hyperspectral data of the Daqu sample by linear scanning with a push broom, and performs black-white correction on the collected hyperspectral data. The formula for black-white correction is:
[0014] ,
[0015] In the formula, is the corrected hyperspectral data; is the original hyperspectral image; Dark reference image collected with the lens covered; The captured standard whiteboard image.
[0016] Furthermore, in step S2, the resampled hyperspectral data band range is 400nm~700nm, with an interval of 10nm; the Adam algorithm is selected as the gradient descent optimization algorithm in the multi-level spectral converter network, and β1=0.9, β2=0.999, the initial learning rate is 0.0004, the batchsize is 1, and each epoch is iterated 1000 times until all training samples are trained, where the Adam algorithm is a gradient descent optimization algorithm, β1 and β2 are hyperparameters in the Adam algorithm, batchsize is the total number of training samples, and epoch is a complete cycle.
[0017] Furthermore, in step S3, the region of interest of the real RGB image is selected by morphological processing and calculating the binary image norm.
[0018] Furthermore, the specific method of selecting the region of interest of the real RGB image is to draw multiple regions of interest for each Daqu sample with a radius of 500 pixels from the center of the real RGB image, and average the spectral data of the pixels in each region of interest to obtain the average spectral value. The formula for obtaining the average spectral value is as follows:
[0019] ,
[0020] in, is the average spectral value in a region of interest; is the number of pixels in the region of interest of the Daqu specimen; is the number of bands of hyperspectral data; For the The pixel at Reflectivity in each band.
[0021] Furthermore, in step S4, the constant weight method is used to measure the moisture content of the Daqu sample, and the calculation formula is:
[0022] ,
[0023] in, is the water content in the sample, g / 100g; is the mass of the weighing bottle and Daqu sample, g; is the mass of the weighing bottle and the Daqu sample after drying, g; is the mass of the weighing bottle, g; 100 is the unit conversion factor.
[0024] Furthermore, the preprocessing process is to process the spectral data using a multivariate scattering correction method.
[0025] Furthermore, the partial least squares regression algorithm was used to establish a prediction model of the preprocessed spectral data and moisture content.
[0026] The second object of the present invention is to provide a system for detecting the moisture content of Daqu, wherein the system is based on the above method and at least comprises:
[0027] A data acquisition module is configured to obtain a Daqu sample, and obtain hyperspectral data of the Daqu sample and a corresponding pseudo RGB image through a hyperspectral imaging system;
[0028] The spectral reconstruction module is configured to resample the hyperspectral data acquired by the data acquisition module, and input the resampled hyperspectral data and its corresponding pseudo RGB image into the multi-level spectral converter network to establish a mapping relationship between the two, and establish a spectral reconstruction model;
[0029] The feature extraction module is configured to take a real RGB image of the Daqu sample, input the real RGB image into the spectral reconstruction model, obtain the corresponding hyperspectral data, and select a region of interest from the real RGB image and extract the spectral data;
[0030] The detection model building module is configured to pre-process the extracted spectral data, measure the moisture content of the Daqu sample by the constant weight method, and correspond the two data one by one to form a data set; divide the data set into a calibration set and a test set, establish a prediction model of the pre-processed spectral data and moisture content on the calibration set, and evaluate it through the test set to finally determine the performance of the detection model;
[0031] The detection module is configured to input the spectral data reconstructed from the Daqu sample to be tested into the detection model in step S4 to detect the moisture content in the Daqu sample.
[0032] The third object of the present invention is to provide a computer-readable storage medium, which stores a program, and the program can be executed by one or more processors to implement the above-mentioned method for detecting the moisture content of Daqu.
[0033] The English abbreviations in the present invention are explained as follows:
[0034] RGB: is a digital image format. Its name refers to both the color space (red, green, blue) used by the image format and the image itself, which contains the pixel values of the red, green, and blue channels.
[0035] ROI: region of interest; MST++: multi-stage spectral converter network; HSCNN-D: deep convolutional neural network, the main feature of which is the use of a densely connected structure, which allows the network to learn and extract features more effectively when processing hyperspectral data; HRNet: hierarchical regression network; MSC: multivariate scatter correction; SNV: standard normal transformation; SG: convolution smoothing; RMSE: root mean square error; MRAE: mean relative absolute error; PSNR: peak signal-to-noise ratio; PLSR: partial least squares regression model; SVR: support vector regression model; ELM: extreme learning machine model; PFA-ELM: pathfinder algorithm optimized extreme learning machine model.
[0036] Compared with the prior art, the technical solution provided by the present invention has the following beneficial effects:
[0037] (1) The present invention provides a method for detecting the moisture content of Daqu based on spectral reconstruction, by inputting a real RGB image of a Daqu sample taken by an industrial camera into a spectral reconstruction model, extracting its spectral data from the hyperspectral data output by the spectral reconstruction model, and then inputting the spectral data into a moisture content prediction model to obtain a predicted value of the moisture content. In practical applications, the moisture content of Daqu can be quickly obtained by using an industrial camera instead of a hyperspectral camera and putting the taken Daqu photo into the prediction model. The industrial camera is easy to carry and can meet the needs of various production conditions. It solves the problem of using a hyperspectral camera in the background technology, which has a complex structure, is not easy to carry, and has strict requirements on external conditions. The use of an industrial camera is more convenient to operate, improves the detection efficiency and accuracy, and improves the quality of liquor brewing. It shows non-destructive, efficient and accurate detection performance and meets the needs of the production site.
[0038] (2) The detection method provided by the present invention overcomes the shortcomings of the existing Daqu moisture content detection technology, and realizes rapid, accurate and non-destructive detection of the moisture content of brewing Daqu. It provides a rapid non-destructive detection technology for brewing companies to detect the moisture content in brewing Daqu on-site, and provides a new technical approach for solid-state intelligent brewing. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 A flow chart of a method for detecting the moisture content of Daqu provided by the present invention;
[0040] Figure 2 The schematic diagram of the structure of the MST++ network is formed by cascading Ns single-stage spectral converters;
[0041] Figure 3 The schematic diagram of the U-shaped SST module structure consists of an encoder, a bottleneck, and a decoder.
[0042] Figure 4 Schematic diagram of the structure of the components of the attention block;
[0043] Figure 5 It is a structural diagram of the feedforward network;
[0044] Figure 6 Schematic diagram of the structure of the spectral multi-head attention block;
[0045] Figure 7 This is the result of hyperspectral data reconstruction of Daqu sample using HSCNN-D method;
[0046] Figure 8 This is the result of hyperspectral data reconstruction of Daqu sample using HRNet method;
[0047] Fig. 9 This is the result of hyperspectral data reconstruction of Daqu sample using MST++ method;
[0048] Fig.10 MRAE heat maps of hyperspectral data reconstructed by MST++ method in different bands;
[0049] Fig.11 MRAE heatmaps of hyperspectral data reconstructed by HRNet method in different bands;
[0050] Fig.12 MRAE heat maps of hyperspectral data reconstructed by HSCNN-D method in different bands;
[0051] Fig.13 To extract images in different bands;
[0052] Fig.14 A schematic diagram of the structure of a system for detecting the moisture content of Daqu provided by the present invention. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical scheme and advantages of the present invention clearer, the specific implementation of the present invention is further described in detail below in conjunction with specific embodiments and drawings. If no specific technology or conditions are specified in the embodiments, the technology or conditions described in the literature in the art or the product instructions are used.
[0054] Unless otherwise specified, the raw materials, equipment and methods used in the present invention are commonly used in the art.
[0055] like Figure 1 As shown, it is a flow chart of the method for detecting the moisture content of Daqu of the present invention, which comprises the following steps:
[0056] (1) Obtain the Daqu sample, obtain the hyperspectral data of the Daqu sample and the corresponding pseudo-RGB image through the hyperspectral imaging system, and eliminate the influence of illumination and camera dark current instability through black and white correction;
[0057] (2) Resample the hyperspectral data of the training samples, and input the resampled hyperspectral data and its corresponding pseudo RGB image into the MST++ network to establish a mapping relationship between the two and establish a spectral reconstruction model;
[0058] (3) The hyperspectral data of the test sample and the corresponding pseudo RGB image are input into the spectral reconstruction model, and the hyperspectral data is reconstructed by the spectral reconstruction model. The spectral reconstruction model is then evaluated by the evaluation index of the hyperspectral data.
[0059] (4) Inputting the pseudo RGB image of the verification sample into the spectral reconstruction model to obtain the corresponding hyperspectral data, and comparing the hyperspectral data with the hyperspectral data obtained by the verification sample in the hyperspectral imaging system;
[0060] (5) Taking a real RGB image of the Daqu sample, inputting the real RGB image into the spectral reconstruction model to obtain the corresponding hyperspectral data, and extracting spectral data from the hyperspectral data by selecting the region of interest from the real RGB image;
[0061] (6) Measure the moisture content of the Daqu sample and correspond it to the spectral data one by one to form a data set. Divide the data set into a calibration set and a test set. Preprocess the data set and establish a prediction model of the spectral data and moisture content after preprocessing in the calibration set. Use the test set to screen out the optimal preprocessing method and the optimal prediction model to determine the detection model.
[0062] (7) The reconstructed spectral data of the Daqu sample to be tested is input into the detection model to detect the moisture content in the Daqu sample.
[0063] Example 1
[0064] The present invention provides a method for detecting the moisture content of Daqu, which specifically comprises the following steps:
[0065] 1. Data Collection
[0066] 1.1 Daqu sample preparation
[0067] The selected Daqu samples came from a brewery in Luzhou, Sichuan. The fermentation cycle of this batch of Daqu samples was 19 days. During the Daqu fermentation stage, a piece of Daqu was taken from three locations in two fermentation rooms at 9:00 am at Anqu, the first day, the second day, the third day, the first turn of the qu, the second turn of the qu, the room, the middle of the slow fall, and the room. The obtained Daqu was broken, crushed, and mixed evenly, and placed in a culture dish with a diameter of 100 mm. Five samples were prepared for each Daqu, and 30 Daqu samples were prepared for each fermentation period. A total of 270 (2×3×9×5) Daqu samples were prepared, which were divided into training samples, test samples, and verification samples in a ratio of 3:1:1.
[0068] 1.2 Hyperspectral Data and Pseudo-RGB Image Acquisition
[0069] The hyperspectral imaging system selected in the present invention consists of a hyperspectral camera (SpecimFX10E, Finland), two sets of 150W halogen light sources (OSRAM, Germany), a high-precision electronically controlled mobile platform with a stroke of 400mm (Specim, Finland), a computer equipped with hyperspectral acquisition software (DELL, USA) and an auxiliary bracket. The spatial resolution and spectral resolution of the FX10E hyperspectral camera are 630*1024piexl and 5nm respectively. The camera can not only obtain 448 continuous wavelengths of hyperspectral data in the visible light-shortwave near infrared (400-1000nm) range, but also capture RGB images of spatial pixels corresponding to the hyperspectral data. Before data acquisition, turn on the halogen light source, connect the camera and the electronically controlled mobile platform, and set the acquisition-related parameters after the system is preheated for 15 minutes, including acquisition frequency (50HZ), exposure time 8.8ms, and electronically controlled platform movement speed 10.84mm / s. After the parameters are set, each Daqu sample is placed in the specified area, and the platform is moved at a constant speed through the software control system, so that the hyperspectral camera scans the sample line by line, and finally the hyperspectral data and RGB image of the Daqu sample are obtained.
[0070] 1.3 Black and white calibration
[0071] In order to eliminate the influence of illumination and camera dark current instability, the collected hyperspectral data needs to be corrected. When collecting each Daqu sample, first cover the camera lens and collect a full black calibration image with a reflectivity of about 0; then place a white board to obtain a full white calibration image with a reflectivity of about 1. The formula for black and white correction is:
[0072] , (1)
[0073] In the formula, is the corrected hyperspectral data; is the original hyperspectral image; Dark reference image collected with the lens covered; The captured standard whiteboard image.
[0074] 1.4 Real RGB Image Acquisition
[0075] An industrial camera was used to capture the RGB image (real RGB image) of the Daqu sample. The RGB image acquisition system consists of an industrial camera (Daheng), a ring light source, a rack, a power supply, and an industrial computer. Before shooting, the light source was turned on and the light intensity was adjusted to 1.1. The camera and computer were connected, and the camera-related shooting parameters were set as follows: exposure time 50000 ms, gain 1.00 dB, automatic white balance continuous, and white balance coefficient 1.0. During shooting, each Daqu sample was placed in the designated shooting area, and the camera was controlled by the acquisition software to complete the acquisition of RGB image data and saved in PNG format. A total of 54 images were collected. In order to facilitate the subsequent reconstruction of hyperspectral data, the real RGB image was cropped to 1680×1680 pixels.
[0076] 1.5 Determination of moisture content of Daqu
[0077] The constant weight method is used to detect the moisture content in Daqu. After the weighing bottle is dried and constant weight is set, 2g~10g of Daqu sample (accurate to 0.0001g) is weighed and placed in the weighing bottle. The thickness of the Daqu sample shall not exceed 5mm. If the sample is relatively loose, the thickness shall not exceed 10mm. After precise measurement and capping, it is placed in a 101℃~105℃ drying oven, with the bottle cap obliquely supported on the edge of the bottle. After drying for 2h~4h, cover it and take it out, place it in the dryer to cool for half an hour, and then weigh it again. Repeat the experimental operation until the difference between the two masses does not exceed 2mg, which is constant weight.
[0078] The calculation formula is:
[0079] ,
[0080] in, is the water content in the sample, g / 100g; is the mass of the weighing bottle and Daqu sample, g; is the mass of the weighing bottle and the Daqu sample after drying, g; is the mass of the weighing bottle, g; 100 is the unit conversion factor.
[0081] 2. Spectral reconstruction
[0082] 2.1 Determine the reconstruction algorithm
[0083] After completing the data set collection of the Daqu sample, the collected pseudo RGB images and the corresponding hyperspectral data need to be input into the spectral reconstruction network for spectral reconstruction model training. The spectral image data of the Daqu sample are reconstructed using three methods: MST++ multi-level spectral converter network, HRNet hierarchical regression network, and HSCNN-D network to determine the reconstruction algorithm.
[0084] The multi-stage spectral-wise transformer network (MST++) uses spectral-wise multi-head self-attention (S-MSA) based on the sparseness of hyperspectral images in space and self-similarity in spectrum to form the basic unit, namely spectral-wise attention block (SAB). The MST++ network is formed by cascading Ns single-stage spectral transformers (SST), such as Figure 2 shown. Figure 3As shown in the figure, a U-shaped SST module consisting of an encoder, a bottleneck, and a decoder is shown. In the SST module, the embedding and mapping block is a 3×3 convolutional layer. The feature map in the encoder undergoes a downsampling operation (a cross-row 4×4 convolutional layer), N1 spectral attention blocks (SAB), a downsampling operation, and N2 SABs in sequence; the bottleneck consists of N3 SABs; the decoder adopts a symmetrical structure, and the upsampling operation is a deconv2×2 layer. In order to avoid information loss during the downsampling process, a jumper connection is used between the encoder and the decoder. The single-stage spectral transformer (SST) adopts an encoder-bottleneck-decoder architecture to achieve efficient spectral data processing and conversion. Its workflow is as follows: First, the input data (X0) is preprocessed through an Embedding layer to convert the original data into a form that the model can understand. Next, the embedded data enters the encoder part, where they go through a series of self-attention blocks (SABs), each SAB module is repeatedly applied N1 and N2 times to capture the complex relationships and patterns within the data. After each round of SAB, the data also goes through a downsampling operation (DownSample) layer to reduce its dimension and generate higher-level feature representations, recorded as (X1) and (X2). These downsampled features finally reach the bottleneck layer, which contains SAB modules that are applied N3 times again to further refine the information. From the bottleneck layer, the data enters the decoding stage. The decoder also consists of multiple rounds of SAB, but before each round of SAB, the data is upsampled through an upsampling operation (UpSample) layer and gradually restored to a resolution close to the original, resulting in (X'1) and (X'2). This process helps to restore image details and prepare the final output. Finally, the data (X'0) processed by the decoder is converted into the desired output form, such as a specific type of spectrogram or analysis result, through a mapping layer. Throughout the process, the self-attention mechanism is crucial for understanding and modeling long-distance dependencies in the data, while the combination of up and down sampling enhances the model's ability to learn features of different scales, thereby achieving accurate spectral data conversion and reconstruction. Figure 4The components of SAB are shown. The attention block SAB (Spectral Attention Block) consists of two layers of layer normalization (Layer Norm), a layer of spectral multi-head attention block (S-MSA, Spectral - Multi-Head Self-Attention Block) and a layer of feed-forward network (FFN, Feed-Forward Network). Its structure is as follows: first layer normalization, then spectral multi-head attention block, then layer normalization, and finally feed-forward network. This structure is used to capture the relationship between spectral features. The multi-head self-attention mechanism can focus on spectral features at different positions, the residual connection helps gradient propagation, and layer normalization can stabilize the training process. Figure 5 The structure of the feed-forward network FFN (Feed-Forward Network) is shown. It consists of two layers of 1×1 convolution (Conv 1×1), two layers of GELU activation function and a layer of 3×3 depth-wise separable convolution (DW Conv 3×3). The specific structure is: first a layer of 1×1 convolution, followed by a GELU activation function, then a 3×3 depth-wise separable convolution, then a GELU activation function, and finally a 1×1 convolution. The feed-forward network is used to further process spectral features. The fully connected layer transforms the dimension of the features through the activation function. The residual connection can maintain the gradient flow and enhance the model's expressiveness. The layer normalization can stabilize the training process. Figure 6 The detailed information of the spectral multi-head attention block S-MSA is shown. It consists of an input matrix X_in (size is H×W×C), a positional encoding PE (size is H×W×C), multiple 1×1 convolutions (W_V, W_K, W_Q, used to generate V, K, Q matrices respectively), a transpose operation, a matrix multiplication, a spectral self-attention operation, a weighted operation (A) and an output matrix X_out (size is H×W×C). The specific structure is: the input X_in is first added to PE, and then passes through W_V, W_K, and W_Q to generate V, K, and Q matrices respectively. After transposition and the first matrix multiplication, V and K are subjected to the spectral self-attention operation to obtain the weighted matrix A, and A is then multiplied with Q by the second matrix to obtain the final output X_out. The spectral multi-head attention block is used to capture the relationship between different spectral channels. The residual connection helps gradient propagation. Layer normalization can stabilize the training process. The feedforward network is used to further process features. The MST++ network adopts a multi-stage learning method to gradually improve the reconstruction accuracy, and the network can capture long-range dependencies and self-similarity between spectra.
[0085] 2.2 Establishment of mapping relationship for Daqu spectrum reconstruction
[0086] In order to remove unnecessary data and facilitate training, the pseudo RGB image and hyperspectral data correspond to pixel areas and are cropped into RGB images of 512×512×3 pixels and hyperspectral data of 512×512×448 pixels, respectively. The cropped hyperspectral data are resampled into 31-band hyperspectral data (pixels: 512×512×31) with an interval of 10 nm in the range of 400nm~700nm.
[0087] The model training uses the Pytorch deep learning framework. The computer CPU used in the experiment is Intel Core i5-7000, the memory is 16GB, and the GPU is GTX2080Ti. Three models are trained using paired Daqu pseudo-RGB images and hyperspectral data. Adam with β1=0.9, β2=0.999 is selected as the gradient descent optimization algorithm. The initial learning rate is set to 0.0004, the batch size is 1, and the number of iterations is 1000 until all samples are trained. A total of 200 epochs are trained. During the training process, the RGB image is linearly scaled to the range of [0, 1]. Due to the large size of hyperspectral images and RGB images, the patch size of the model is set to 128, the step size is 8, and the data set is cropped to 128×128 pixel RGB and HSI sample pairs for input to the model. The training data is enhanced by random rotation and flipping. In the test phase, the RGB image is also linearly scaled to [0, 1] and input into the model for calculation of various indicators. The training accuracy and loss change curves of HSCNN-D, HRNet, and MST++ models are shown in Figure 2. Figure 7-Figure 9 As shown in the figure, the red line is the test mean absolute relative error (Test MRAE), the blue line is the test root mean square error (Test RMSE), and the green line is the test peak signal-to-noise ratio (Test PSNR). All three models iterate 206 epochs. In the first 100 epochs, the training loss (Train Loss), test mean absolute relative error (Test MRAE) and test root mean square error (TestRMSE) drop rapidly, and the test peak signal-to-noise ratio (Test PSNR) rises rapidly; after 150 epochs, each indicator tends to be flat.
[0088] In order to evaluate the difference between the reconstructed spectrum and the original spectrum, the spectrum reconstruction model was evaluated using evaluation indicators including root mean square error (Root Mean Square Error, RMSE), mean relative absolute error (Mean Relative Absolute Error, MRAE), mean square error (Mean Squared Error, MSE) and peak signal-to-noise ratio (Peak Signal-to-Noise Ratio, PSNR). The calculation method of these evaluation parameters is shown in the following formula:
[0089] , (2)
[0090] , (3)
[0091] , (4)
[0092] , (5)
[0093] In the formula, , Represent the height and width of the spatial resolution of hyperspectral data, represents the actual spectral data, represents the reconstructed spectral data, Respectively represent the coordinate values of the height and width of the spatial resolution of the hyperspectral data, Represents the maximum possible value of the reconstructed spectral data. Since the reflectance of the hyperspectral data is between 0 and 1, The default is 1.
[0094] The evaluation results are shown in Table 1. The MST++ method has the best model effect. Its test set MRAE, RMSE and are 0.0218 and 0.0087 respectively, which are lower than the HSCNN-D model by 0.0835 and 0.0224, and lower than the HRNet model by 0.0109 and 0.0045; and the RSNR of the MST++ test set is 41.6555, which is 9.7838 higher than that of HSCNN-D and 3.4744 higher than that of HSCNN-D. This shows that in the process of training hyperspectral image reconstruction using pseudo RGB images of Daqu samples, the hyperspectral data reconstructed by the MST++ method has better quality than the hyperspectral data reconstructed by the HRNet method and the HSCNN-D method, and the quality difference between the reconstructed hyperspectral data and the original hyperspectral data is small, and the difference between each pixel is smaller than the original hyperspectral image pixel.
[0095] Table 1. Performance of different reconstruction methods
[0096]
[0097] 2.3 Evaluation of Daqu spectral reconstruction mapping relationship
[0098] The pseudo RGB images of the Daqu prediction samples are used to reconstruct the hyperspectral data, and the spectral curves of each sample at different pixel points and three reconstructed spectral curves are plotted, as well as three MRAE heat maps in different bands to evaluate the reconstruction quality.
[0099] Nine data with different fermentation times were selected from the hyperspectral data and the three reconstructed hyperspectral data. The pixels at the same position were randomly selected from the hyperspectral data of each fermentation time and the three reconstructed hyperspectral data. The spectral curves of 31 bands with an interval of 10nm in the range of 400nm~700nm were plotted to understand the difference in reflectance between the hyperspectral data and the reconstructed hyperspectral data. The spectral curves of Daqu samples at different fermentation times showed certain similarities with the three reconstructed spectral curves, and their changing trends were basically the same, indicating that the spectral reconstruction network can reconstruct hyperspectral data with a certain accuracy from the RGB images of Daqu samples. Among the three spectral reconstruction methods, the spectral data reconstructed by the MST++ method had the smallest difference with the original spectral data, followed by the HRNet method, and the spectral data reconstructed by the HSCNN-D method had the largest difference with the original spectral data, indicating that compared with HRNet and HSCNN+ methods, the hyperspectral quality reconstructed by the MST++ method is higher. This is because the HRNet method and the HSCNN-D method only focus on the relationship between spectra when reconstructing hyperspectral data, while the MST++ method has advantages in capturing long-range dependencies and self-similarity between spectra, making the reconstructed hyperspectral quality higher. In addition, in the 400nm~500nm band, the original spectrum deviates greatly from the three reconstructed spectra, which may be due to the influence of noise, resulting in a large deviation in the prediction results.
[0100] In order to further explore the quality of hyperspectral reconstruction by different methods, three hyperspectral data with different fermentation times and the corresponding three reconstructed hyperspectral data were randomly selected, and three MRAE heat maps in different bands were drawn, as shown in Figure 2. Figure 10~Figure 12 As shown in the figure, the MRAE heat map drawn by the hyperspectral data reconstructed by the MST++ method, the MRAE heat map drawn by the hyperspectral data reconstructed by the HRNet method, and the MRAE heat map drawn by the hyperspectral data reconstructed by the HSCNN-D method. In each figure, the redder the area, the greater the error between the reconstructed hyperspectrum and the hyperspectral data, and the worse the quality of the reconstructed hyperspectrum; the closer the color to the blue area, the smaller the error with the hyperspectral data, and the higher the quality of the reconstructed hyperspectrum.
[0101] The errors between the three reconstructed hyperspectral data and the hyperspectral data are all less than 0.5. In the same band, the blue area accounts for the largest proportion in the MRAE thermal map drawn by the hyperspectral data reconstructed by the MST++ method, and the blue area is darker. The MRAE thermal map drawn by the hyperspectral data reconstructed by the HRNet method is blue as a whole, but the color of the blue area is not as deep as the thermal effect map drawn by the MST++ method. A certain range of light blue and red areas appear in the thermal map within the 400nm band, indicating that the hyperspectral data reconstructed within this band is quite different from the original hyperspectral data. This is because when shooting hyperspectral data, the hyperspectral camera is affected by light and dark current, which will cause many noise points in the hyperspectral data at both ends of the spectral band, thereby affecting the reconstruction accuracy of the model, resulting in some areas in the MRAE thermal map showing light blue and red.
[0102] 3. Determination of region of interest and spectral extraction
[0103] The selection of the region of interest (ROI) is crucial to the accuracy and effectiveness of the prediction model. In the present invention, the ROI is selected by morphological processing and calculation of the binary image norm. With the center of the image of Daqu as the center and a radius of 500 pixels, 7 ROIs are drawn for each sample to separate the sample from the background. The spectral data of the pixels in each ROI are averaged to obtain 378 sets of spectral data for further processing and analysis. Since the amount of hyperspectral data is very large, it is necessary to process the spectral data under the sample ROI to meet the format requirements of the model input data. The data format after processing in the present invention is one-dimensional waveform spectral data. The spectral data of all pixels in the ROI area of the sample are averaged to obtain the one-dimensional waveform spectral data of the sample. The specific calculation is shown in formula (6):
[0104] , (6)
[0105] in, is the average spectral value in a region of interest; is the number of pixels in the region of interest of the Daqu specimen; is the number of bands of hyperspectral data; For the The pixel at Reflectivity in each band.
[0106] 4. Daqu hyperspectral data reconstruction
[0107] The real RGB images were used instead of the pseudo RGB images to be input into the reconstruction network. According to the established spectral reconstruction mapping relationship of HSCNN-D, HRNet and MST++, three types of hyperspectral data were reconstructed. According to the detection effect of the final model on the moisture content, it was evaluated whether the replacement met the requirements. There were 54 hyperspectral data for each reconstruction, including Daqu samples from 9 fermentation periods.
[0108] The Daqu hyperspectral data of three periods reconstructed by different methods were randomly selected, and images of different bands were extracted from them for display. The display results are shown in the figure. Fig.13 As shown in the figure. The hyperspectral data reconstructed by the HSCNN-D method is poor, and images in different bands are blurred. The image reconstructed by the HRNet method is slightly lower than that of MST++, but the image reconstructed by HRNet is not as good as that of MST++ in the 400nm band, and the image reconstructed by MST++ retains more details and is closer to the original RGB image taken by the industrial camera, so the reconstruction effect is worse than that of HRNet.
[0109] 5. Build a detection model
[0110] After the detection model is established, the determination coefficient (Rc 2 ) and root mean square error (RMSE c ), the coefficient of determination of the test set (Rp 2 ) and root mean square error (RMSE P ) are used to evaluate the detection performance of the model. Specifically, Rc 2 and Rp 2 The closer it is to 1, the better the fit of the model on the training set and the test set; RMSE c and RMSE P The smaller it is, the lower the detection error of the model. The specific calculation method of the above evaluation parameters is shown in the following formula:
[0111] , (7)
[0112] , (8)
[0113] , (9)
[0114] , (10)
[0115] In the formula, represents the number of samples in the training set, represents the number of samples in the test set, is the test value, is the average moisture content in the training set, is the average moisture content in the test set.
[0116] 5.1 Preprocessing of reconstructed spectral data
[0117] For the reconstruction of spectral data, three methods, HSCNN-D, HRNet, and MST++, were used to reconstruct the spectral data, and PLSR models were established based on different preprocessing methods to evaluate the effect. The results are shown in Table 2, where None means no preprocessing. Specifically, the spectral data reconstructed by the HSCNN-D method has the best effect when the PLSR model is established by using the MSC method for preprocessing, and its Rp 2 is 0.9884, RMSE p is 1.1574 g / 100 g; however, the PLSR model established using the SG pretreatment method is not very effective, Rp 2 is 0.9742, RMSE p For the spectral data reconstructed by the HRNet method, the model established by the MSC preprocessing method has the best effect, Rp 2 Reached 0.9845, RMSE p The Rp was 1.3091 g / 100 g, which was slightly better than the model established by the SNV pretreatment method (Rp 2 is 0.9845, RMSE p In the spectral data reconstructed by MST++ method, the optimal model is the PLSR model established after preprocessing by MSC method, Rp 2 is 0.9864, RMSE p The PLSR model established under the SG method pretreatment has a poor effect, Rp 2 is 0.9765, RMSE p In summary, in the subsequent modeling of moisture content, the spectral data reconstructed by MST++ will be preprocessed using the MSC and None methods.
[0118] Table 2. Spectral data reconstructed by different reconstruction algorithms and PLSR models established based on different preprocessing methods
[0119]
[0120] 5.2 Detection of water content in Daqu based on reconstructed spectral data
[0121] The PLSR, SVM, ELM and PFA-ELM models were established for the three types of reconstructed spectral data to explore the prediction effects of the three types of reconstructed spectral data in each model. The effects of spectral data reconstructed by different methods in each model are shown in Table 3.
[0122] The modeling results of moisture content detection of Daqu spectral data using three reconstructed spectral data are shown in Table 3. For the modeling results of HSCNN-D reconstructed spectral data, the SVR model has the best effect, and its Rp 2 and RMSE p The results of spectral data reconstruction by HRNet show that the SVR model has the best effect, and its coefficient of determination Rp of the test set is 0.9941 and 0.7695 g / 100 g respectively, which is better than the results of other models. 2 And root mean square error RMSE p The results of the MST++ reconstruction of spectral data show that the SVR model has the best effect, while the PLSR, ELM and PFA-ELM models have lower effects. The determination coefficient Rp of the SVR model is 2 And root mean square error RMSE P They are 0.9984 and 0.4093 g / 100 g respectively. This shows that the model established by the SVR method has a good detection effect. Among the SVR models established by spectral data reconstructed by different methods, the spectral data reconstructed by the MST++ method has the best modeling effect, indicating that the spectral data reconstructed by the MST++ method has a good regression effect.
[0123] Table 3. Results of the moisture content prediction model established using reconstructed spectral data
[0124]
[0125] Comparative Example 1
[0126] Moisture content detection based on Daqu raw hyperspectral data.
[0127] 1. Daqu hyperspectral data division
[0128] The sample was separated from the background with the center of the Daqu image as the center and a radius of 100 pixels. The spectral data of the pixels in each sample ROI were averaged to obtain 378 sets of spectral data. The sample set partitioning (SPXY) algorithm based on the joint xy distance was used. The algorithm partitioned the sample set based on the spectral characteristics of the sample and the spatial distribution of the response variable. The algorithm was used to divide all spectral data into a correction set and a prediction set at a ratio of 4:1. The partitioning results are shown in Table 4.
[0129] Table 4. Statistics of moisture content determination results of spectral data within Daqu ROI
[0130]
[0131] 2. Preprocessing of Daqu original hyperspectral data
[0132] For the hyperspectral data collected by the hyperspectral system, the PLSR model was established by using the spectral data without preprocessing and using the SNV, SG and MSC methods for preprocessing. The modeling results are shown in Table 5, where None means no preprocessing. The study shows that under the MSC preprocessing method, the model achieved the best detection effect, and its Rc 2 , Rp 2 They are as high as 0.9952 and 0.9891 respectively, RMSE c 、RMSE p The results of the models established by other pretreatment methods are better than those by other pretreatment methods. Therefore, the MSC method is suitable for pretreatment of Daqu hyperspectral data.
[0133] Table 5. Results of establishing PLSR models based on different preprocessing methods for spectral data
[0134]
[0135] 3. Detection of moisture content in Daqu original hyperspectral data
[0136] The PLSR, SVM, ELM and PFA-ELM models were established using the original hyperspectral data of Daqu to detect the moisture content of Daqu. The spectrum used was full wavelength. The model performance was comprehensively evaluated by examining the determination coefficient and root mean square error of the calibration set and the test set to determine the optimal model. The modeling effect is shown in Table 6.
[0137] As shown in Table 6, the PLSR, SVR, ELM and PFA-ELM models established using full wavelength can better explain the corresponding relationship between spectral information and the moisture content of Daqu, which are recorded as Full+PLSR, Full+SVR, Full+ELM and Full+PFA-ELM. 2 and RMSE p The Rp of the Full+SVR model prediction set is 0.9891 and 1.0529 g / 100 g respectively. 2 and RMSE p The Rp of the prediction set of the Full+ELM model is 0.9980 and 0.4520 g / 100 g respectively. 2 and RMSE p In the PFA-ELM model results, the Rp of the Full+PFA-ELM prediction set is 2 and RMSEp They are 0.9595 and 2.0849 g / 100 g respectively.
[0138] Table 6. Results of the moisture content detection model established based on the hyperspectral data of Daqu samples
[0139]
[0140] Comparing the results of the optimal modeling of the spectrum reconstructed in Example 1 with the original hyperspectral data in Comparative Example 1, its Rp 2 and RMSE p The difference is 0.0004 and 0.0427 g / 100 g (water content), respectively, which indicates that the use of RGB images for spectral reconstruction can detect the moisture content of Daqu. The above research shows that the Daqu RGB image detection method based on spectral reconstruction technology can be applied to the online detection of Daqu quality during the production process, which provides convenience for wine companies to produce liquor.
[0141] Example 2
[0142] This embodiment is based on the design basis of embodiment 1 and discloses a system for detecting the moisture content of Daqu. Fig.14 As shown, the system is based on the above-mentioned method for detecting the moisture content of Daqu, and at least includes:
[0143] A data acquisition module is configured to obtain a Daqu sample, and obtain hyperspectral data of the Daqu sample and a corresponding pseudo RGB image through a hyperspectral imaging system;
[0144] The spectral reconstruction module is configured to resample the hyperspectral data acquired by the data acquisition module, and input the resampled hyperspectral data and its corresponding pseudo RGB image into the multi-level spectral converter network to establish a mapping relationship between the two, and establish a spectral reconstruction model;
[0145] The feature extraction module is configured to pre-process the extracted spectral data, measure the moisture content of the Daqu sample by the constant weight method, and correspond the two data one by one to form a data set; divide the data set into a calibration set and a test set, establish a prediction model of the pre-processed spectral data and moisture content on the calibration set, and evaluate it through the test set to finally determine the performance of the detection model;
[0146] The detection model building module is configured to measure the moisture content of the Daqu sample, and correspond one-to-one with the spectral data extracted by the feature extraction module to form a data set, divide the data set into a calibration set and a test set, pre-process the data set, and then establish a prediction model of the spectral data and moisture content after pre-processing in the calibration set, and determine the detection model after evaluation through the test set;
[0147] The detection module is configured to input the hyperspectral image data of the Daqu sample to be tested into the detection model to detect the moisture content in the Daqu sample.
[0148] Example 3
[0149] Based on the design basis of Examples 1 and 2, this embodiment discloses a computer-readable storage medium, which stores a program. The program can be executed by one or more processors to implement the above-mentioned method for detecting the moisture content of Daqu.
[0150] In the absence of conflict, the above embodiments and features in the embodiments may be combined with each other.
[0151] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for detecting the moisture content of Daqu based on spectral reconstruction, characterized in that: The specific steps include: S1. Obtain a Daqu sample, obtain the hyperspectral data of the Daqu sample and the corresponding pseudo RGB image through a hyperspectral imaging system, and eliminate the influence of illumination and camera dark current working instability through black and white correction; S2, resampling the hyperspectral data obtained in step S1, and inputting the resampled hyperspectral data and its corresponding pseudo RGB image into a multi-level spectrum converter network to establish a mapping relationship between the two, and establishing a spectrum reconstruction model; The resampled hyperspectral data band range is 400nm~700nm, with an interval of 10nm; the Adam algorithm is selected as the gradient descent optimization algorithm in the multi-level spectral converter network, and β1=0.9, β2=0.999, the initial learning rate is 0.0004, the batchsize is 1, and each epoch is iterated 1000 times until all training samples are trained. Among them, the Adam algorithm is a gradient descent optimization algorithm, β1 and β2 are hyperparameters in the Adam algorithm, batchsize is the total number of training samples, and epoch is a complete cycle; S3, taking a real RGB image of the Daqu sample, inputting the real RGB image into the spectral reconstruction model, obtaining reconstructed hyperspectral data, and selecting a region of interest from the real RGB image and extracting spectral data; Select the region of interest of the real RGB image by morphological processing and calculating the binary image norm; S4, preprocessing the extracted spectral data, and measuring the moisture content of the Daqu sample by constant weight method, and making the two data correspond one by one to form a data set together; dividing the data set into a calibration set and a test set, establishing a prediction model of the preprocessed spectral data and moisture content on the calibration set, and evaluating it through the test set, and finally determining the performance of the detection model; The constant weight method was used to measure the moisture content of the Daqu sample, and the calculation formula was: , in, is the water content in the sample, g / 100g; is the mass of the weighing bottle and Daqu sample, g; is the mass of the weighing bottle and the Daqu sample after drying, g; is the mass of the weighing bottle, g; 100 is the unit conversion factor; The SVR support vector regression model was used to establish a prediction model of the preprocessed spectral data and moisture content; S5. Input the reconstructed spectral data of the Daqu sample to be tested into the detection model in step S4 to detect the moisture content in the Daqu sample.
2. The detection method according to claim 1, characterized in that In step S1, the hyperspectral imaging system collects the hyperspectral data of the Daqu sample by push-broom linear scanning, and performs black-white correction on the collected hyperspectral data. The formula for black-white correction is: , In the formula, is the corrected hyperspectral data; is the original hyperspectral image; Dark reference image collected with the lens covered; The captured standard whiteboard image.
3. The detection method according to claim 1, characterized in that The specific method of selecting the region of interest of the real RGB image is to draw multiple regions of interest for each Daqu sample with a radius of 500 pixels from the center of the real RGB image, and average the spectral data of the pixels in each region of interest to obtain the average spectral value. The formula for obtaining the average spectral value is as follows: , in, is the average spectral value in a region of interest; is the number of pixels in the region of interest of the Daqu specimen; is the number of bands of the hyperspectral data; For the The pixel at Reflectivity in each band.
4. The detection method according to claim 3, characterized in that The preprocessing process is to process the spectral data using a multivariate scattering correction method.
5. A system for detecting the moisture content of Daqu, characterized in that: The system is based on the method according to any one of claims 1 to 4, and at least includes: A data acquisition module is configured to obtain a hyperspectral image of the Daqu sample and obtain a corresponding corrected pseudo RGB image through black and white correction; The spectral reconstruction module is configured to resample the hyperspectral data acquired by the data acquisition module, and input the resampled hyperspectral data and its corresponding pseudo RGB image into the multi-level spectral converter network to establish a mapping relationship between the two, and establish a spectral reconstruction model; A feature extraction module is configured to capture a real RGB image of a Daqu sample, input the real RGB image into the spectral reconstruction model, obtain reconstructed hyperspectral data, and extract spectral data by selecting a region of interest from the real RGB image; The detection model building module is configured to pre-process the extracted spectral data, measure the moisture content of the Daqu sample by the constant weight method, and correspond the two data one by one to form a data set; divide the data set into a calibration set and a test set, establish a prediction model of the pre-processed spectral data and moisture content on the calibration set, and evaluate it through the test set to finally determine the performance of the detection model; use the SVR support vector regression model to establish a prediction model of the pre-processed spectral data and moisture content; The detection module is configured to input the spectral data reconstructed from the Daqu sample to be tested into the detection model in step S4 to detect the moisture content in the Daqu sample.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program, and the program can be executed by one or more processors to implement the method for detecting the moisture content of Daqu according to any one of claims 1-4.
Citation Information
Patent Citations
Sorghum variety identification method based on spectral image reconstruction
CN116337781A