A method and device for detecting aflatoxin B1 content in grains

By combining hyperspectral imaging technology and linear discriminant analysis models, the characteristic wavelength group of corn kernels is obtained for detection, which solves the problem that the detection in the existing technology will destroy the sample and realizes non-destructive detection of aflatoxin B1 content.

CN114778457BActive Publication Date: 2025-09-12INTELLIGENT EQUIPMENT RESEARCH CENTER BEIJING ACADEMY OF AGRICULTURE AND FORESTRY SCIENCES
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210209977.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-04
Publication Date
2025-09-12
Estimated Expiration
2042-03-04

AI Technical Summary

Technical Problem

Existing technologies will destroy samples when detecting aflatoxin B1 in corn kernels, making non-destructive testing impossible.

Method used

Hyperspectral imaging technology is used to obtain the target characteristic wavelength group of the target grain and input it into the content detection model. The linear discriminant analysis (LDA) model is used for detection to output the content level of aflatoxin B1.

Benefits of technology

It has achieved the detection of aflatoxin B1 content without destroying the grains, expanding the scope of application of the detection method.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114778457B_ABST
    Figure CN114778457B_ABST
Patent Text Reader

Abstract

The present invention provides a method and apparatus for detecting aflatoxin B1 content in grains, comprising: obtaining a target characteristic wavelength group of a target grain; inputting the target characteristic wavelength group into a content detection model, and obtaining the aflatoxin B1 content level in the target grain as output by the content detection model; the content detection model is obtained by training the characteristic wavelength groups of individual samples and the content level labels corresponding to the characteristic wavelength groups of the sample samples. The method and apparatus for detecting aflatoxin B1 content in grains provided by the present invention, by identifying and detecting the characteristic wavelength group of the target grain using the content detection model, can detect the aflatoxin B1 content in the target grain without destroying the grain, effectively expanding the scope of application of the detection method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of analysis and detection, and in particular to a method and device for detecting the content of aflatoxin B1 in cereals. Background Art

[0002] Aflatoxin B1 (AFB1) is a highly toxic fungal toxin with potential carcinogenic and teratogenic effects on humans. Corn kernels, due to their nutrient-rich nature, are highly susceptible to fungal infection (such as Aspergillus flavus), which produces a secondary metabolite, AFB1.

[0003] Traditionally, the detection of AFB1 in corn kernels mainly uses biochemical methods such as mass spectrometry, gas chromatography, thin-layer chromatography, and high-performance liquid chromatography.

[0004] All of the above methods are destructive to the samples to be tested. Summary of the Invention

[0005] The present invention provides a method for detecting the content of aflatoxin B1 in cereals, so as to solve the defect of the prior art that the sample to be detected may be destroyed, and realize the detection of the content of aflatoxin B1 in cereals.

[0006] The present invention provides a method for detecting the content of aflatoxin B1 in cereals, comprising:

[0007] Obtaining a target characteristic wavelength group of target grains;

[0008] The target characteristic wavelength group is input into the content detection model to obtain the content level of aflatoxin B1 in the target grain output by the content detection model; the content detection model is obtained by training the sample characteristic wavelength group and the content level label corresponding to the sample characteristic wavelength group.

[0009] According to a method for detecting aflatoxin B1 content in cereals provided by the present invention, obtaining a target characteristic wavelength group of target cereals includes:

[0010] Acquiring a target hyperspectral image of the target grain;

[0011] extracting target spectral data within a preset area from the target hyperspectral image;

[0012] A target characteristic wavelength group is determined in the target spectrum data.

[0013] According to a method for detecting aflatoxin B1 content in cereals provided by the present invention, extracting target spectral data within a preset area in the target hyperspectral image includes:

[0014] Performing interference removal processing on the target hyperspectral image to obtain initial spectral data within a preset area;

[0015] The initial spectral data is smoothed and filtered and first-order derivative is taken to obtain target spectral data.

[0016] According to a method for detecting aflatoxin B1 content in cereals provided by the present invention, determining a target characteristic wavelength group in the target spectral data includes:

[0017] Determining a preliminary characteristic wavelength group with the smallest cross-validated root mean square error value in the target spectral data;

[0018] In the preliminarily selected characteristic wavelength group, according to the grayscale information of the target grain at each wavelength, obtaining the normalized grayscale distribution corresponding to each wavelength;

[0019] Determining the grayscale difference characteristic value at each wavelength according to each normalized grayscale distribution;

[0020] A target characteristic wavelength group is determined in the target spectrum data according to the grayscale difference characteristic value at each wavelength.

[0021] According to a method for detecting aflatoxin B1 content in cereals provided by the present invention, before inputting the target characteristic wavelength group into the content detection model, the method further includes:

[0022] Obtain sample hyperspectral images and aflatoxin B1 content level labels for multiple sample grains;

[0023] Extracting sample spectral data within a preset area in each sample hyperspectral image;

[0024] determining a sample characteristic wavelength group in each sample spectral data;

[0025] Using the combination of the sample feature group of each corn sample and the content grade label as a training sample to obtain multiple training samples;

[0026] The content detection model is trained using the training samples.

[0027] According to a method for detecting aflatoxin B1 content in cereals provided by the present invention, the method of training a content detection model using the training samples includes:

[0028] For any training sample, the training sample is input into the content detection model, and the predicted content level corresponding to the training sample is output;

[0029] Calculating a loss value based on the predicted content level corresponding to the training sample and the content level label in the training sample using a preset loss function;

[0030] When the loss value is less than a preset threshold, the content detection model training is completed.

[0031] The present invention also provides a device for detecting the content of aflatoxin B1 in cereals, comprising:

[0032] an acquisition module, for acquiring a target characteristic wavelength group of a target grain;

[0033] The detection module is used to input the target characteristic wavelength group into the content detection model to obtain the content level of aflatoxin B1 in the target grain output by the content detection model; the content detection model is obtained by training the sample characteristic wavelength group and the content level label corresponding to the sample characteristic wavelength group.

[0034] The present invention also provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the method for detecting aflatoxin B1 content in cereals as described above is implemented.

[0035] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for detecting the aflatoxin B1 content in cereals as described in any one of the above.

[0036] The present invention also provides a computer program product, comprising a computer program, which, when executed by a processor, implements any of the above methods for detecting the content of aflatoxin B1 in cereals.

[0037] The method and device for detecting the aflatoxin B1 content in grains provided by the present invention identify and detect the characteristic wavelength group of the grain to be tested through a content detection model, and can detect the aflatoxin B1 content in the grain to be tested without destroying the grain, thereby effectively expanding the scope of application of the detection method. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0039] Figure 1 This is a schematic flow chart of the method for detecting aflatoxin B1 content in cereals provided by the present invention;

[0040] Figure 2Schematic diagram of the relationship between the number of sampling wavelengths and the number of sampling times in the CARS algorithm provided by the present invention;

[0041] Figure 3 Schematic diagram of the relationship between the RMSECV value and the number of sampling times in the CARS algorithm provided by the present invention;

[0042] Figure 4 Schematic diagram of characteristic wavelengths selected by the CARS algorithm provided by the present invention;

[0043] Figure 5 1 is a flow chart of the characteristic wavelength selection method provided by the present invention;

[0044] Figure 6 is a schematic diagram of the eigenvalues ​​calculated by GDI provided by the present invention;

[0045] Figure 7 Schematic diagram of the characteristic wavelength selected by the GDI provided by the present invention;

[0046] Figure 8 This is a schematic structural diagram of a device for detecting aflatoxin B1 content in cereals provided by the present invention;

[0047] Figure 9 It is a schematic diagram of the physical structure of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0048] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0049] The following combination Figures 1 to 9 The present invention provides a method and device for detecting aflatoxin B1 content in cereals.

[0050] Figure 1 Schematic diagram of the process of detecting aflatoxin B1 content in cereals provided by the present invention. Figure 1 As shown, including but not limited to the following steps:

[0051] First, in step S1 , a target characteristic wavelength group of a target grain is acquired.

[0052] Among them, the target grains can be crops such as corn kernels, brown rice, and oats. In the subsequent embodiments of the present invention, the aflatoxin content detection of corn kernels is used as an example for illustration, which is not regarded as limiting the scope of protection of the present invention.

[0053] The target characteristic wavelength group may be selected from a hyperspectral image of the target grain.

[0054] Specifically, a hyperspectral image of the target grain is obtained, and denoising is performed on the hyperspectral image. In the hyperspectral image, a plurality of characteristic wavelengths with large information differences among groups of samples are selected as the target characteristic wavelength group.

[0055] Furthermore, in step S2, the target characteristic wavelength group is input into the content detection model to obtain the content level of aflatoxin B1 in the target grain output by the content detection model; the content detection model is obtained by training the sample characteristic wavelength groups and the content level labels corresponding to the sample characteristic wavelength groups.

[0056] According to the test of multiple neural network models, the Linear Discriminant Analysis (LDA) model has the highest accuracy and the best detection effect, so the content detection model can be constructed based on the LDA model.

[0057] The levels of aflatoxin B1 may include: 0 ppb (parts per million), 10 ppb, 20 ppb, 50 ppb and 100 ppb.

[0058] Specifically, the target characteristic wavelength group is input into the content detection model, and the content detection model detects the content of aflatoxin B1 according to the target characteristic wavelength and outputs the content level of aflatoxin B1 in the target grain.

[0059] The method for detecting the aflatoxin B1 content in cereals provided by the present invention identifies and detects the characteristic wavelength group of the cereals to be tested through a content detection model, and can detect the aflatoxin B1 content in the cereals to be tested without destroying the cereals, thereby effectively expanding the scope of application of the detection method.

[0060] Optionally, obtaining a target characteristic wavelength group of a target grain includes:

[0061] Acquiring a target hyperspectral image of the target grain;

[0062] extracting target spectral data within a preset area from the target hyperspectral image;

[0063] A target characteristic wavelength group is determined in the target spectrum data.

[0064] Specifically, corn seeds with intact appearance and roughly the same grain size were selected as samples, with each seed weighing approximately 0.5 grams (g). An appropriate amount of 2 micrograms / milliliter (μg / mL) AFB1 toxin and methanol solution was prepared. By changing the mixing ratio of the toxin and methanol, four diluents with concentrations of 0.2μg / mL, 0.4μg / mL, 1.0μg / mL, and 2.0μg / mL were prepared. According to the weight of a single corn kernel, 25 microliters (μL) of the diluent were inoculated onto the embryo surface of each corn kernel using a precision pipette to obtain samples with four different AFB1 concentrations of 10ppb, 20ppb, 50ppb, and 100ppb. In addition, a group of samples without AFB1 were prepared as a control group. Each sample in the control group was treated with 25μL of methanol alone to eliminate the effects of the diluent treatment as much as possible.

[0065] Furthermore, a spectrometer is used to collect a spectrum in the wavelength range of 400 nanometers (nm) to 1000 nm, which contains a total of 778 bands with a spectral interval of 0.775 nm. A 14-bit visible-short wavenear infrared (Vis-SWNIR) electron-multiplying charge-coupled device (EMCCD) camera is used for hyperspectral imaging of the sample in the visible-near infrared range. The spectrometer model can be ImSpector V10E, Spectral Imaging Ltd, Oulu or Finland; the camera model can be Andor Luca EMCCD DL-604M, Andor Technology plc or N.Ireland.

[0066] A spectrometer was used to collect spectra in the wavelength range of 1000 nm to 2500 nm, containing a total of 256 bands with a spectral interval of 6.32 nm. A 14-bit long wave near infrared (LWNIR) charge-coupled device (CCD) camera (Xeva-2.5-320, Xenics Ltd, Belgium) was used for hyperspectral imaging of the samples in the LWNIR range, as well as other related equipment such as light sources and platforms.

[0067] Since the acquired Vis-SWNIR hyperspectral image consists of 1000 congruent sub-images spanning 325nm to 1100nm, and the LWNIR hyperspectral image consists of 256 congruent sub-images spanning 930nm to 2548nm, to balance the band spacing of the two spectrometers so that the wavelength intervals after spectral fusion are basically consistent, one wavelength is extracted every eight wavelengths in the Vis-SWNIR region, that is, 125 wavelengths are extracted from the original 1000 wavelengths for analysis.

[0068] Optionally, extracting target spectral data within a preset area from the target hyperspectral image includes:

[0069] Performing interference removal processing on the target hyperspectral image to obtain initial spectral data within a preset area;

[0070] The initial spectral data is smoothed and filtered and first-order derivative is taken to obtain target spectral data.

[0071] The area where the spectrum is located after removing the areas with severe interference at both ends of the spectrum can be called a preset area.

[0072] Specifically, after collecting the seed hyperspectral information, a hyperspectral image of the entire seed surface area is extracted, and the spectrum of each seed's entire surface area is compressed into a single spectrum in each band to reduce the amount of data calculations. Because this spectral information often also contains instrument noise, as well as baseline drift caused by physiological differences such as temperature and size of the sample itself, sample surface scattering, and optical path changes, spectral preprocessing becomes critical and necessary.

[0073] First, the regions with severe interference at both ends of the spectrum were removed. Then, a preprocessing method combining Savitzky–Golay (SG) smoothing filtering and first-order derivative (FD) was used. The preprocessed target spectral data consisted of 240 bands ranging from 500 nm to 2000 nm.

[0074] Hyperspectral images are data cubes containing rich spectral and image information. While they can capture grayscale images of objects across a wide range of wavelengths, the sheer volume of data presents challenges for data modeling and can easily lead to the Hughes phenomenon. Therefore, dimensionality reduction of hyperspectral images is essential. Selecting a few wavelengths that capture the target information is an effective method for reducing computational complexity and improving model performance. Hyperspectral imaging has emerged as a new approach for crop and food safety testing, and has been applied to the detection of AFB1 in corn kernels.

[0075] Previous studies on characteristic wavelength selection have primarily used spectral information to select characteristic wavelengths, while ignoring image information. This invention fuses spectral and image information to screen characteristic wavelengths and, based on the selected characteristic wavelengths, establishes a content detection model for AFB1 concentration in corn kernels.

[0076] Optionally, determining a target characteristic wavelength group in the target spectrum data includes:

[0077] Determining a preliminary characteristic wavelength group with the smallest cross-validated root mean square error value in the target spectral data;

[0078] In the preliminarily selected characteristic wavelength group, according to the grayscale information of the target grain at each wavelength, obtaining the normalized grayscale distribution corresponding to each wavelength;

[0079] Determining the grayscale difference characteristic value at each wavelength according to each normalized grayscale distribution;

[0080] A target characteristic wavelength group is determined in the target spectrum data according to the grayscale difference characteristic value at each wavelength.

[0081] Competitive adaptive reweighted sampling (CARS) is an excellent variable selection algorithm. Numerous studies have shown that it is highly effective in selecting hyperspectral feature wavelengths. This paper uses this algorithm to perform an initial selection of hyperspectral key wavelengths. Before the sampling run, the number of Monte Carlo sample runs and the number of cross-validation runs were set to 50 and 10, respectively.

[0082] Figure 2 Schematic diagram of the relationship between the number of sampling wavelengths and the number of sampling times in the CARS algorithm provided by the present invention, such as Figure 2 As shown in the figure, the horizontal axis is the number of sampling runs, and the vertical axis is the number of sampled variables. Figure 3 This is a schematic diagram of the relationship between the RMSECV value and the number of sampling times in the CARS algorithm provided by the present invention, as shown in FIG. Figure 3 As shown in the figure, the horizontal axis is the number of sampling runs and the vertical axis is the RMSECV value.

[0083] Figure 2 and Figure 3 It respectively shows the number of selected bands and the change pattern of the root mean square error of cross validation (RMSECV) value with the increase of sampling times. The asterisk line in the figure indicates the state when the RMSECV value reaches the lowest point.

[0084] Figure 4 Schematic diagram of the characteristic wavelength selected by the CARS algorithm provided by the present invention, such as Figure 4 As shown, the horizontal axis is wavelength (Wavelength), the unit is nm, and the vertical axis is reflectance (reflectance), wherein the line is the target spectrum data (spectrum of a sample), and the square is the selected characteristic wavelength (selected bands). Figure 4 All 25 characteristic wavelengths selected by the CARS algorithm are shown, constituting the preliminary set of characteristic wavelengths.

[0085] Because the computational process of characteristic wavelength selection is time-consuming, the CARS algorithm is used to roughly select characteristic wavelengths before using this algorithm to minimize the data dimension of the hyperspectral image. Based on the rough wavelength selection using the CARS algorithm, the gray-value difference of images (GDI) information proposed in this chapter is used to fine-tune the characteristic wavelengths.

[0086] For each wavelength after rough selection, in the region of interest (ROI) of the sample in the image at each wavelength, assume that D(i, j, k) is the grayscale value of a pixel point (i, j) at the kth wavelength, where k = 1, 2, ..., K, K is the total number of wavelengths; i = 1, 2, ..., I, I is the number of horizontal pixels of the camera; j = 1, 2, ..., J, J is the number of vertical pixels of the camera.

[0087] Extract the grayscale information of samples at different wavelengths. Taking the image at wavelength k as an example, for each pixel of the image, its grayscale value can be regarded as a random variable in the range of 0 to 255, and calculate the probability distribution density P of each different grayscale level in each group of sample images. d , the calculation method is as follows:

[0088]

[0089] Among them, h d is the total number of pixels with grayscale value d in the image; r is the total number of pixels in the image, r = I × J.

[0090] Calculate the grayscale values ​​of each group of samples at each wavelength from 0 to 255. dThe values ​​are used to form a normalized grayscale distribution. At the same wavelength, if the difference in normalized grayscale distribution between different groups is greater, it means that the information difference between the samples in each group at that wavelength is greater, which is conducive to the establishment of a classification model. Conversely, if the difference in normalized grayscale distribution between different groups at that wavelength is smaller, it means that the information difference is smaller, which is not conducive to the establishment of a classification model. The normalized grayscale distribution can be the ratio of each grayscale value.

[0091] Figure 5 Schematic diagram of the characteristic wavelength selection method provided by the present invention, as shown in FIG. Figure 5 As shown, for any wavelengths in the first to fifth groups (Group1, Group2, Group3, Group4 and Group5) after the initial selection, in the normalized grayscale distribution diagram of Group1 to Group5, the horizontal axis is the gray value (Gray value), the vertical axis is the proportion (Proportion), and the sum of the vertical axes is equal to 1; define the eigenvalue E o To express the difference in normalized grayscale distribution between different groups at each wavelength, the calculation method is as follows:

[0092]

[0093] Where d represents the grayscale value; m and n represent two groups with different AFB1 concentrations, respectively.

[0094] Calculate the grayscale difference characteristic value E at each wavelength o , if E at a certain wavelength o A smaller value indicates that the grayscale images of the groups are quite different at this wavelength, and the data at this wavelength is conducive to the establishment of the classification model.

[0095] In order to facilitate observation and calculation, take the eigenvalue E o The reciprocal of is taken as the new eigenvalue, and E is used x The calculation method is as follows:

[0096]

[0097] Since the eigenvalue E x The size reflects the difference in grayscale images between groups. In order to select the wavelengths with the largest feature differences between groups, the largest X eigenvalues ​​E are selected. x The corresponding wavelength is the characteristic wavelength selected by this algorithm, and X is the number of selected characteristic wavelengths.

[0098] For the 25 characteristic wavelengths selected by the CARS algorithm, the characteristic value E at each wavelength is calculated according to the GDI algorithm. n , select the largest eigenvalues ​​E n The corresponding wavelength is used as the characteristic wavelength selected by GDI.

[0099] Figure 6 It is a schematic diagram of the characteristic value calculated by GDI provided by the present invention, such as Figure 6 As shown in the figure, the horizontal axis is the serial number of characteristic wavelength, and the vertical axis is the eigenvalue. Figure 7 Schematic diagram of the characteristic wavelength selected by the GDI provided by the present invention, such as Figure 7 As shown, the horizontal axis is wavelength (Wavelength), the unit is nm, and the vertical axis is reflectance (reflectance), wherein the line is the target spectrum data (spectrum of a sample), and the square is the selected characteristic wavelength (selected bands).

[0100] After the characteristic wavelengths were roughly selected using CARS, the calculated GDI characteristic values ​​at each wavelength and the final selected 10 characteristic wavelengths were as follows: Figure 6 and Figure 7 As shown in the figure, the larger the GDI characteristic value at a certain wavelength, the higher the probability that the wavelength is a characteristic wavelength. Therefore, the 10 wavelengths corresponding to the 10 largest GDI characteristic values ​​are selected as the target characteristic wavelength group. The order of the selected characteristic wavelengths is 1373.0nm, 1366.7nm, 1872.5nm, 1796.1nm, 1840.6nm, 1815.2nm, 1824.5nm, 1834.3nm, 1827.9nm and 1216.6nm.

[0101] Optionally, before inputting the target characteristic wavelength group into the content detection model, the method further includes:

[0102] Obtain sample hyperspectral images and aflatoxin B1 content level labels for multiple sample grains;

[0103] Extracting sample spectral data within a preset area in each sample hyperspectral image;

[0104] determining a sample characteristic wavelength group in each sample spectral data;

[0105] Using the combination of the sample feature group of each corn sample and the content grade label as a training sample to obtain multiple training samples;

[0106] The content detection model is trained using the training samples.

[0107] Optionally, the training of the content detection model using the training samples includes:

[0108] For any training sample, the training sample is input into the content detection model, and the predicted content level corresponding to the training sample is output;

[0109] Calculating a loss value based on the predicted content level corresponding to the training sample and the content level label in the training sample using a preset loss function;

[0110] When the loss value is less than a preset threshold, the content detection model training is completed.

[0111] The preset threshold can be flexibly selected according to the requirements for the detection accuracy of the content detection model. The smaller the preset threshold, the higher the detection accuracy of the content detection model.

[0112] All samples included five sample groups with different AFB1 concentrations, totaling 350 samples, namely four groups of samples with different AFB1 content and one group of control samples without AFB1, each group containing 70 samples.

[0113] The Kennard-Stone algorithm was used to divide all samples into calibration and prediction sets. Within each set, 40 samples were selected as calibration samples, and the remaining 30 samples were selected as prediction samples. Based on the rough selection of characteristic wavelengths using CARS, the GDI algorithm was used to further filter the characteristic wavelengths. This double selection of characteristic wavelengths using CARS-GDI, combined with the LDA classification model, achieved ideal detection results.

[0114] Table 1 is the confusion matrix of the AFB1 content prediction results. When 10 characteristic wavelengths are selected, the accuracy rates of the calibration set and prediction set tests reach 97.00% and 94.67%, respectively. The specific test results are shown in Table 1.

[0115] Table 1 Confusion matrix of AFB1 content prediction results

[0116]

[0117] The results in Table 1 demonstrate that the proposed method achieves satisfactory results for both calibration and prediction sets. In the prediction set, all uncontaminated and 10 ppb samples were correctly identified. Four samples in the 20 ppb group were mistakenly identified as 50 ppb, and one sample in the 50 ppb group was mistakenly identified as 20 ppb. For the 100 ppb group, three samples were predicted as 50 ppb. These erroneous results are primarily due to the very similar spectral characteristics of samples in adjacent concentration groups. Furthermore, differences in seed sample shape, which slightly affect spectral reflectance, also contribute to misidentification.

[0118] The proposed method achieved an average accuracy of 94.67% for detecting AFB1 concentration in the prediction set using ten characteristic wavelengths, achieving ideal experimental results. This method provides a new approach for detecting AFB1 concentration in corn seeds and selecting characteristic wavelengths for hyperspectral imaging.

[0119] The method for establishing an aflatoxin B1 concentration discrimination model provided by the present invention uses combined visible short-wave near-infrared and long-wave near-infrared hyperspectral image information. First, competitive adaptive weighted sampling is used to perform a preliminary selection of characteristic wavelengths. Second, characteristic wavelength optimization is performed using the image's grayscale information. Finally, based on the secondary screening characteristic wavelength data, a linear discriminant analysis algorithm is combined to construct a discriminant model for AFB1 concentration in corn kernels. This method integrates spectral and image information to select characteristic wavelengths, taking into account aflatoxin information in both spectral and image information. While ensuring detection accuracy, it reduces the number of wavelengths and improves the speed of aflatoxin B1 concentration discrimination.

[0120] Existing detection technologies require specialized instruments, making them unsuitable for online testing and limiting their feasibility for routine use. In an alternative embodiment, the present invention first prepares five corn kernel samples with varying AFB1 concentrations (0 ppb, 10 ppb, 20 ppb, 50 ppb, and 100 ppb). Vis-SWNIR and LWNIR hyperspectral images are acquired for all samples. Spectral data from a predefined region of the seeds is extracted and preprocessed to obtain target spectral data in the wavelength range of 500 to 2000 nm.

[0121] The preprocessed target spectral data was used to perform preliminary characteristic wavelength selection using CARS, and 25 wavelengths were selected from 240 bands as the preliminary characteristic wavelength group. The grayscale information of the image was then used to perform secondary screening of the characteristic wavelengths in the preliminary characteristic wavelength group, and 10 characteristic wavelengths were further selected from the 25 wavelengths as the target characteristic wavelength group.

[0122] Using the data at 10 wavelengths after secondary screening and combined with the LDA model, a discriminant model for the AFB1 concentration of corn kernels was established. After testing, the test accuracy of the prediction set samples reached 94.67%. It can be seen that the characteristic wavelength selection algorithm of the CARS-GDI combination proposed in the present invention combined with the LDA classification model has achieved good results in distinguishing the AFB1 concentration of corn seeds, realizing the online detection of aflatoxin B1 content in grains, and is feasible for routine use.

[0123] The following describes the device for detecting the content of aflatoxin B1 in cereals provided by the present invention. The device for detecting the content of aflatoxin B1 in cereals described below and the method for detecting the content of aflatoxin B1 in cereals described above can be used for reference in correspondence with each other.

[0124] Figure 8 Schematic diagram of the structure of the device for detecting the content of aflatoxin B1 in cereals provided by the present invention. Figure 8 Shown, including:

[0125] An acquisition module 801 is used to acquire a target characteristic wavelength group of a target grain;

[0126] Detection module 802 is used to input the target characteristic wavelength group into the content detection model to obtain the content level of aflatoxin B1 in the target grain output by the content detection model; the content detection model is obtained by training the sample characteristic wavelength group and the content level label corresponding to the sample characteristic wavelength group.

[0127] First, the acquisition module 801 acquires a target characteristic wavelength group of a target grain.

[0128] Among them, the target grains can be crops such as corn kernels, brown rice, and oats. In the subsequent embodiments of the present invention, the aflatoxin content detection of corn kernels is used as an example for illustration, which is not regarded as limiting the scope of protection of the present invention.

[0129] The target characteristic wavelength group may be selected from a hyperspectral image of the target grain.

[0130] Specifically, a hyperspectral image of the target grain is obtained, and denoising is performed on the hyperspectral image. In the hyperspectral image, a plurality of characteristic wavelengths with large information differences among groups of samples are selected as the target characteristic wavelength group.

[0131] Furthermore, the detection module 802 inputs the target characteristic wavelength group into the content detection model to obtain the content level of aflatoxin B1 in the target grain output by the content detection model; the content detection model is obtained by training the sample characteristic wavelength group and the content level label corresponding to the sample characteristic wavelength group.

[0132] According to the test of multiple neural network models, the LDA model has the highest accuracy and the best detection effect, so the content detection model can be constructed based on the LDA model.

[0133] The levels of aflatoxin B1 may include: 10 ppb, 10 ppb, 20 ppb, 50 ppb and 100 ppb.

[0134] Specifically, the target characteristic wavelength group is input into the content detection model, and the content detection model detects the content of aflatoxin B1 according to the target characteristic wavelength and outputs the content level of aflatoxin B1 in the target grain.

[0135] The device for detecting the content of aflatoxin B1 in grains provided by the present invention identifies and detects the characteristic wavelength group of the grains to be tested through a content detection model, and can detect the content of aflatoxin B1 in the grains to be tested without destroying the grains, thereby effectively expanding the scope of application of the detection method.

[0136] Figure 9 This is a schematic diagram of the physical structure of the electronic device provided by the present invention, such as Figure 9 As shown, the electronic device may include: a processor 910, a communication interface 920, a memory 930, and a communication bus 940, wherein the processor 910, the communication interface 920, and the memory 930 communicate with each other via the communication bus 940. The processor 910 may call the logic instructions in the memory 930 to execute a method for detecting the content of aflatoxin B1 in grains, the method comprising: obtaining a target characteristic wavelength group for a target grain; inputting the target characteristic wavelength group into a content detection model, and obtaining the content level of aflatoxin B1 in the target grain output by the content detection model; the content detection model is obtained by training the characteristic wavelength groups of individual samples and the content level labels corresponding to the characteristic wavelength groups of the sample samples.

[0137] In addition, the logic instructions in the above-mentioned memory 930 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0138] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the aflatoxin B1 content detection method in grains provided by the above methods, the method including: obtaining a target characteristic wavelength group of the target grain; inputting the target characteristic wavelength group into a content detection model, and obtaining the content level of aflatoxin B1 in the target grain output by the content detection model; the content detection model is obtained by training individual sample characteristic wavelength groups and content level labels corresponding to the sample characteristic wavelength groups.

[0139] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the aflatoxin B1 content detection method in grains provided by the above-mentioned methods, the method comprising: obtaining a target characteristic wavelength group of target grains; inputting the target characteristic wavelength group into a content detection model, and obtaining the content level of aflatoxin B1 in the target grains output by the content detection model; the content detection model is obtained by training individual sample characteristic wavelength groups and content level labels corresponding to the sample characteristic wavelength groups.

[0140] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0141] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.

[0142] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A method for detecting aflatoxin B1 content in cereals, characterized in that: include: Obtaining a target characteristic wavelength group of target grains; Inputting the target characteristic wavelength group into a content detection model to obtain the content level of aflatoxin B1 in the target grain output by the content detection model; the content detection model is obtained by training each sample characteristic wavelength group and the content level label corresponding to the sample characteristic wavelength group; The step of obtaining a target characteristic wavelength group of a target grain comprises: Acquiring a target hyperspectral image of the target grain; extracting target spectral data within a preset area from the target hyperspectral image; determining a target characteristic wavelength group in the target spectrum data; Determining a target characteristic wavelength group in the target spectrum data includes: Based on the CARS algorithm, a preliminary characteristic wavelength group with the smallest cross-validated root mean square error value is determined in the target spectral data; In the preliminarily selected characteristic wavelength group, according to the grayscale information of the target grain at each wavelength, obtaining the normalized grayscale distribution corresponding to each wavelength; Determining a grayscale difference characteristic value at each wavelength according to each normalized grayscale distribution, wherein the grayscale difference characteristic value is used to characterize the normalized grayscale distribution difference of different aflatoxin B1 concentration groups at each wavelength; Determining a target characteristic wavelength group in the target spectrum data according to the grayscale difference characteristic value at each wavelength; determining the target characteristic wavelength group in the target spectrum data according to the grayscale difference characteristic value at each wavelength includes: At the same wavelength, if the difference in normalized grayscale distribution between different groups is greater, it means that the information difference between the samples in each group at this wavelength is greater, which is conducive to the establishment of the classification model; on the contrary, if the difference in normalized grayscale distribution between different groups at this wavelength is smaller, it means that the information difference is smaller, which is not conducive to the establishment of the classification model.

2. The method for detecting aflatoxin B1 content in cereals according to claim 1, characterized in that: Extracting target spectral data within a preset area from the target hyperspectral image includes: Performing interference removal processing on the target hyperspectral image to obtain initial spectral data within a preset area; The initial spectral data is smoothed and filtered and first-order derivative is taken to obtain target spectral data.

3. The method for detecting aflatoxin B1 content in cereals according to claim 1 or 2, characterized in that: Before inputting the target characteristic wavelength group into the content detection model, the method further includes: Obtain sample hyperspectral images and aflatoxin B1 content level labels for multiple sample grains; Extracting sample spectral data within a preset area in each sample hyperspectral image; determining a sample characteristic wavelength group in each sample spectral data; Using a combination of the sample characteristic wavelength group and the content level label of each sample grain as a training sample, obtaining a plurality of training samples; The content detection model is trained using the training samples.

4. The method for detecting aflatoxin B1 content in cereals according to claim 3, characterized in that: The method of training the content detection model using the training samples includes: For any training sample, the training sample is input into the content detection model, and the predicted content level corresponding to the training sample is output; Calculating a loss value based on the predicted content level corresponding to the training sample and the content level label in the training sample using a preset loss function; When the loss value is less than a preset threshold, the content detection model training is completed.

5. A device for detecting aflatoxin B1 content in cereals, characterized in that: include: an acquisition module, for acquiring a target characteristic wavelength group of a target grain; a detection module, configured to input the target characteristic wavelength group into a content detection model and obtain the content level of aflatoxin B1 in the target grain output by the content detection model; the content detection model is obtained by training each sample characteristic wavelength group and the content level labels corresponding to the sample characteristic wavelength group; The acquisition module is specifically used to: Acquiring a target hyperspectral image of the target grain; extracting target spectral data within a preset area from the target hyperspectral image; determining a target characteristic wavelength group in the target spectrum data; The acquisition module is specifically used to: Based on the CARS algorithm, a preliminary characteristic wavelength group with the smallest cross-validated root mean square error value is determined in the target spectral data; In the preliminarily selected characteristic wavelength group, according to the grayscale information of the target grain at each wavelength, obtaining the normalized grayscale distribution corresponding to each wavelength; Determining, based on each normalized grayscale distribution, a grayscale difference characteristic value at each wavelength, wherein the grayscale difference characteristic value is used to characterize the normalized grayscale distribution difference of different aflatoxin B1 concentration groups at each wavelength; and determining, based on the grayscale difference characteristic value at each wavelength, a target characteristic wavelength group in the target spectral data; Determining a target characteristic wavelength group in the target spectrum data according to the grayscale difference characteristic value at each wavelength includes: At the same wavelength, if the difference in normalized grayscale distribution between different groups is greater, it means that the information difference between the samples in each group at this wavelength is greater, which is conducive to the establishment of the classification model; on the contrary, if the difference in normalized grayscale distribution between different groups at this wavelength is smaller, it means that the information difference is smaller, which is not conducive to the establishment of the classification model.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method for detecting the content of aflatoxin B1 in cereals as claimed in any one of claims 1 to 4 is implemented.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for detecting the content of aflatoxin B1 in cereals as claimed in any one of claims 1 to 4 is implemented.

8. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method for detecting the content of aflatoxin B1 in cereals as claimed in any one of claims 1 to 4 is implemented.