A method for rapid detection of multi-class defects of corn kernels by using hyperspectral imaging
Patent Information
- Application Number
- CN202611100921.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2026-05-18
- Filing Date
- 2026-07-23
- Publication Date
- 2026-10-09
AI Technical Summary
人工检测效率低、主观性强,难以满足大批量、快速检测需求;理化检测方法虽然精度较高,但存在检测周期长、样品破坏性强、成本高等问题
(1)本发明利用高光谱成像技术,实现了对玉米籽粒早期霉变、严重霉变、热损及泥点等多种缺陷的无损、快速检测,从而实现对种子品质检测,有效弥补传统种子活力测定方法的不足。
Smart Images

Figure CN122882455A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of non-destructive testing technology for food security, food safety and agricultural product pollution information, and mainly relates to a rapid detection method for multiple defects in corn kernels using hyperspectral imaging. Background Technology
[0002] Corn is an important food crop and feed ingredient in my country, and its quality and safety are directly related to grain storage, processing, and food safety. During the harvesting, transportation, drying, and storage of corn, the kernels are highly susceptible to environmental factors, resulting in various quality defects such as mold, heat damage, and mud contamination. The national standard GB1353-2018 for corn inspection clearly stipulates the testing categories, methods, and quality requirements for corn kernels during the procurement process. Mold, heat damage, and impurities are listed separately as key testing items, demonstrating the serious harm they pose.
[0003] Moldy corn is usually caused by fungal infection, which not only leads to the loss of nutrients but may also produce harmful substances such as aflatoxin, posing a serious threat to human and animal health. Early-stage moldy corn, in particular, often lacks obvious mold characteristics and is easily missed during seed screening, directly affecting the purity of the seed and germination rate, increasing subsequent storage and planting risks. Heat-damaged corn is often caused by excessively high temperatures during drying or storage, leading to carbonization and structural damage to the kernels, affecting their processing and eating quality. Mud-spotted corn is caused by soil adhering to the kernels during harvesting or transportation, reducing the appearance quality of the kernels and easily inducing secondary mold growth.
[0004] Currently, the detection of mold in corn kernels mainly relies on manual visual sorting or physicochemical testing methods. Manual inspection is inefficient and highly subjective, making it difficult to meet the needs of large-scale, rapid testing. While physicochemical testing methods offer higher accuracy, they suffer from long testing cycles, sample destructiveness, and high costs. The detection of thermal damage in corn kernels mainly relies on manual visual sorting or germination tests; however, germination tests are time-consuming and can damage the seeds. The detection of mud spots in corn kernels mainly relies on water immersion and sedimentation methods, which also suffer from long testing cycles, making them difficult to widely apply in grain purchasing and processing sites. Therefore, there is an urgent need for a non-destructive, rapid, and accurate detection method capable of simultaneously identifying multiple corn kernel defects. Summary of the Invention
[0005] The purpose of this invention is to solve the aforementioned technical problems by proposing a rapid detection method for multiple defects in corn kernels using hyperspectral imaging. By collecting and analyzing hyperspectral information from the front, back, and sides of the corn kernels, a non-destructive, rapid, and accurate identification of various defect types can be achieved. Hyperspectral imaging technology can acquire spatial information of corn kernels while continuously acquiring their spectral information in the visible-near-infrared band. It is highly sensitive to changes in internal composition and differences in surface structure, providing a new technical means for identifying defects such as mold, heat damage, and mud spots in corn kernels. This invention uses hyperspectral technology as the main technical means, quantitatively analyzing the evolution of hyperspectral information in corn kernels when quality defects occur, and combining it with spectral data processing technology to propose a rapid detection method for multiple defects in corn kernels using hyperspectral imaging. This provides fundamental technical support for the detection of mold, heat damage, and mud spot contamination in corn kernels and for corn seed screening.
[0006] The technical solution adopted to achieve the above objectives is: A rapid detection method for multiple types of defects in maize kernels using hyperspectral imaging includes the following steps: Step S1: Collect hyperspectral image data of corn kernels, preprocess the hyperspectral image data, including radiometric correction, noise removal, background removal, corn region segmentation and size normalization, and generate standard reflectance products; Step S2: Extract the corn kernel reflectance information after preprocessing in Step S1 and perform normalization processing; through normalization processing, the spectral reflectance characteristics of the hyperspectral image data are standardized, so that the spectral characteristics between different samples are comparable, providing a stable input for subsequent feature selection and defect identification, and establishing a corn kernel database according to different categories of corn kernels. Step S3: Use the feature screening method to identify the spectral data after normalization in step S2, select sensitive bands with high identification ability for corn kernel defects, and construct a feature subset; Step S4: Using the feature subset from step S3, the defect type of corn kernels is determined based on the improved Yolov8 model to obtain the determination results from different perspectives; the improvements to the improved Yolov8 model include adjusting the input layer to adapt to multi-channel hyperspectral data, optimizing the network structure, and optimizing the detector. Step S5: Encode the judgment result obtained in step S4, and comprehensively judge the quality of corn kernels using a comprehensive judgment method based on multi-view information fusion; pre-construct a set of numerical codes with unique and reversible summation characteristics, and assign them to the judgment results of corn kernel defect types respectively; after the judgment of defect types of corn kernels from different angles is completed, sum the corresponding numerical codes to obtain the comprehensive judgment value, thereby achieving a unique judgment of corn kernel quality.
[0007] Preferably, in step S1, the acquired hyperspectral image data of corn kernels is preprocessed, including the following steps: Step S11: Radiation Correction and Noise Band Removal: Radiometric calibration was performed before acquiring corn kernel image data; bands with low signal-to-noise ratios and those severely affected by system noise were removed. Step S12: Background removal and corn kernel region segmentation: Under a specific spectral band, the reflectance of pixels below a set grayscale threshold is set to zero, and the portion above the threshold is the corn kernel region; the smallest bounding rectangle containing all non-zero pixels is determined as the region of interest representing the corn kernels; the corn kernel region is separated from the background to obtain an effective image region containing only corn kernels.
[0008] Step S13: Trim and standardize the size of the segmented corn kernel area: The minimum bounding rectangle of the segmented corn kernel region is extracted as the region of interest. The region of interest is then cropped and expanded to a specific pixel using zero padding to ensure that the input size of all samples remains consistent.
[0009] Preferably, in step S2: the spectral reflectance of all effective pixels in the region of interest of the front, back and side of each corn kernel is statistically analyzed, and the spectral reflectance characteristics of the hyperspectral image data are standardized by normalization processing to make the spectral characteristics of different samples comparable, and a corn kernel database is established according to different categories of corn kernels.
[0010] Preferably, the normalization process in step S2 includes: (1) Calculate the sum of all bands of the hyperspectral image data for each corn kernel: In the formula, Indicates the first band; Indicates the first The sum of the bands of the hyperspectral images of corn kernels is a grayscale image with the same row and column size as the hyperspectral images of corn kernels. (2) Average brightness: In the formula, It is the mean of the sum of the bands in the hyperspectral image of the i-th corn kernel. for Effective pixel value within the image refers to the pixel value of the corn kernel-covered area. (3) Calculate the corrected ratio: In the formula, N represents the hyperspectral images of 1000 corresponding grain grains. Ideally, the more grains, the better; Indicates the first The ratio of the sum of the mean values of all bands in the hyperspectral image of a corn kernel to the ideal mean; (4) Correction coefficient In the formula, Indicates to The number of decimal places retained after rounding can be adjusted according to the actual situation. (5) Correct the reflectivity of each band: In the formula, Indicates the first The reflectance value of a hyperspectral image of a corn kernel after correction in the i-th band.
[0011] Preferably, in step S3, a feature screening method is used to identify spectral bands, selecting sensitive bands with high identification ability for early mold, severe mold, heat damage, and mud spot defects, and constructing a feature subset. The process of constructing the feature subset includes: combining the spectral difference characteristics of normal grains, early moldy grains, severely moldy grains, heat-damaged grains, and mud spot grains, using the Random Forest Importance Assessment (MDA) algorithm to assess the importance of each band, dividing the entire spectrum into five intervals; using the Random Forest Importance Assessment (MDA) algorithm to assess the importance of each feature within the five wavelength ranges, and selecting representative bands from each interval based on the obtained importance scores, thus screening out representative bands that respond significantly to different defect types.
[0012] Preferably, in step S3, the Random Forest Importance Assessment (MDA) algorithm includes: (1) Calculate the original mean square error outside the bag for a single tree: (6) in, Indicates the first Out-of-bag data for each tree Indicates its sample size. Indicates sample The true value Indicates the first Tree samples The original predicted value; (2) Calculate the out-of-bag mean square error after feature permutation: (7) in, This represents the out-of-bag mean square error after feature permutation. Representation of features random permutation operation, Representation of features Predicted value after permutation; (3) The importance of the original features of the random forest is calculated from the original mean square error outside the bag for a single tree and the mean square error outside the bag after feature permutation. The calculation formula includes: (8) in, Indicates the importance of the original features. This represents the total number of decision trees in the random forest; (4) Standardize feature importance to enhance the comparability between features. The calculation formula includes: (9) in, Indicating the importance of standardized features, This represents the total number of features.
[0013] Preferably, the specific improvements to the improved Yolov8 model in step S4 include: Step S41: Input layer improvement: Modify the channel dimension of the first convolutional kernel in the YOLOv8 model; Step S42: Network structure optimization: The spectral-channel-spatial attention (SCSA) mechanism is incorporated into the backbone of the YOLOv8 model; Step S43: Detector optimization: Replace the original detector in YOLOv8 with RT-DETR.
[0014] Preferably, in step S4, before using the improved YOLOv8 to detect defects in corn kernels, a processed dataset is prepared, including N kernels each from the front, back, and side of each category. The dataset is divided into training and testing sets according to a ratio to obtain a mature improved YOLOv8 deep learning model. After training, the sensitive band spectral features of the front, back, and side of the corn kernels that were not used in the training are used as input. The improved YOLOv8 defect discrimination model is used to identify the category to which the kernels belong, and the results of the front defect type determination, the back defect type determination, and the side defect type determination are output.
[0015] Preferably, in step S5, the implementation steps of the comprehensive judgment method for corn kernel quality based on multi-view information fusion specifically include: Step S51: Pre-construct a set of numerical codes with unique and reversible summation properties, and assign them to the five quality discrimination results of corn kernels respectively; Step S52: After the quality judgment of the front, back and side of the corn kernels is completed, the numerical codes corresponding to the three sides are summed to obtain the comprehensive judgment value; Step S53: Based on the comprehensive discrimination value, accurately determine the overall quality of corn kernels and retain the traceability of the single-sided discrimination results.
[0016] Preferably, in step S5, the calculation method and process of the comprehensive judgment method for corn kernel quality based on multi-view information fusion includes: (1) The three sides of a corn kernel are the front, back, and side, and their corresponding quality judgment results are expressed as follows: (10) in, Indicates the front. Indicates the opposite. The numbers represent the side view, with 0 indicating normal, 1 indicating mud spots, 4 indicating heat loss, 13 indicating early mold growth, and 40 indicating severe mold growth. (2) The discriminant code S for corn kernels is defined as: (11) Any discriminant code S can be uniquely mapped to the corresponding combination, thus enabling a unique determination of the quality of the three sides of corn kernels.
[0017] The beneficial effects of this invention are as follows: (1) This invention utilizes hyperspectral imaging technology to achieve non-destructive and rapid detection of various defects in corn kernels, such as early mold, severe mold, heat damage, and mud spots, thereby enabling seed quality testing and effectively compensating for the shortcomings of traditional seed vigor testing methods.
[0018] (2) The present invention can realize real-time, rapid and accurate detection of corn mold information, effectively improve the detection efficiency of corn mold information, reduce detection costs and improve the detection efficiency of corn quality.
[0019] (3) The present invention simultaneously obtains spatial and spectral information of corn kernels, thereby improving the accuracy of defect identification.
[0020] (4) The method of the present invention has good scalability and can be used in conjunction with automated sorting equipment; (5) This invention avoids the problem of missed detection of defects caused by single-sided detection by jointly detecting and comprehensively judging the hyperspectral information of the front, back and side of the corn kernels, and significantly improves the accuracy and robustness of early mold, severe mold, heat damage and mud spot defects. Attached Figure Description
[0021] Figure 1 This is a flowchart of the method of the present invention; Figure 2 Hyperspectral image data of normal corn, early moldy corn, severely moldy corn, heat-damaged corn, and mud-spotted corn. Figure 3 Spectral curves of normal corn, early mold, severe mold, heat-damaged, and mud-spotted corn; Figure 4 The normalized spectral curve of maize; Figure 5 This is a query table for comprehensive judgment of corn kernel quality based on multi-perspective information fusion; Figure 6 To determine the correspondence between code S and corn kernel quality; Figure 7 The spectral differences of corn kernels with different types of defects. Detailed Implementation
[0022] The present invention will now be further described with reference to the accompanying drawings.
[0023] See Figure 1-7 : A rapid detection method for multiple types of defects in maize kernels using hyperspectral imaging includes the following steps: Step S1: Use a hyperspectral imaging system to acquire hyperspectral image data of the front, back, and side of corn kernels respectively. Preprocess the acquired hyperspectral image data of the front, back, and side of corn kernels. The preprocessing includes radiometric correction, noise removal, background removal, corn region segmentation, and size normalization to generate a standard reflectance product.
[0024] Step S2: Extract reflectance information from the front, back, and side regions of interest of the corn kernels after preprocessing in Step S1, and perform normalization processing to reduce the impact of changes in light intensity and instrument differences on the detection results. Through normalization processing, the spectral reflectance characteristics of the hyperspectral image data are standardized, making the spectral characteristics of different samples comparable, providing stable input for subsequent feature selection and defect identification, and establishing a corn kernel database based on different categories of corn kernels. Step S3: Use feature screening methods to identify spectral bands, select sensitive bands with high identification ability for early mold growth, severe mold growth, heat damage and mud spot defects, and construct feature subsets.
[0025] Step S4: Using the feature subset from Step S3, determine the defect types on the front, back, and sides of corn kernels based on the improved Yolov8 model, obtaining the determination results for the front, back, and sides. Improvements to the improved Yolov8 model include adjusting the input layer to adapt to multi-channel hyperspectral data, optimizing the network structure, and optimizing the detector.
[0026] Step S5: Encode the front, back, and side judgment results obtained in Step S4, and comprehensively judge the quality of corn kernels using a multi-view information fusion-based comprehensive judgment method for corn kernel quality. A set of unique and reversibly summable numerical codes is pre-constructed, each corresponding to a defect type judgment result of the corn kernel. After judging the defect types of corn kernels from different angles, the corresponding numerical codes are summed to obtain a comprehensive judgment value, achieving a unique judgment of corn kernel quality.
[0027] In this embodiment, the hyperspectral imaging system includes a hyperspectral camera, a calibration plate, VIX-N220 software, a custom U-shaped card slot, a conveyor, a stable halogen lamp light source, and a data processing terminal. The components are configured as follows: the hyperspectral imaging spectrometer is mounted 30cm directly above the conveyor belt; the halogen lamp and the spectrometer lens are at the same vertical height, with a horizontal distance of 10cm; the light beam angle is 45° to the vertical and pointing downwards to ensure a uniform light field for the sample. Radiometric calibration is performed using the calibration plate and VIX-N220 software during hyperspectral image data acquisition. The hyperspectral imaging system is existing technology and will not be described in detail in this embodiment.
[0028] The corn kernel spectral measurement process is as follows: Corn kernels to be tested are sequentially arranged on a conveyor device. They are then inspected three times (front, back, and side) and passed through the conveyor device three times. Hyperspectral image data is collected for each side during the pass. After one side is acquired, the kernels are returned to the starting point and passed through the acquisition area again from the opposite side. For front and back hyperspectral image data acquisition, the kernels are placed flat on the conveyor device. For side hyperspectral image data acquisition, a custom-designed U-shaped slot is used. The kernels are placed into the U-shaped slot, and gravity causes them to automatically adhere to the slot wall, with the side naturally facing the camera lens. Each side image is captured twice, from the left and right sides, and the combined images are used to obtain the side hyperspectral image data. To improve acquisition efficiency and reduce spectral noise, the spectral sampling interval is set to 20 nm. During image acquisition, the sample movement speed is set to 1 cm / s to prevent corn image deformation. Ten samples are acquired each time for imaging, with an average image acquisition time of 8 seconds per image. The spectral acquisition range is 400–1000 nm. This invention utilizes hyperspectral imaging technology to achieve non-destructive and rapid detection of various defects in corn kernels, such as early mold, severe mold, heat damage, and mud spots, thereby enabling seed quality testing and effectively overcoming the shortcomings of traditional seed vigor testing methods. It has good scalability and can be used in conjunction with automated sorting equipment. This invention simultaneously acquires spatial and spectral information of corn kernels, improving the accuracy of defect identification.
[0029] In step S1: Hyperspectral image data of the front, back, and side of corn kernels are acquired using a hyperspectral imaging system (see...). Figure 2 The acquired hyperspectral image data of the front, back, and side of corn kernels are preprocessed, including radiometric correction, noise removal, background removal, corn region segmentation, and size normalization, to generate a standard reflectance product. The preprocessing in step S1 includes: Step S11: Radiation correction and noise band removal.
[0030] Before acquiring corn kernel image data, radiometric calibration was performed using a calibration plate and VIX-N220 software (this is existing technology and will not be described in detail here) to reduce the impact of light field inhomogeneity, sensor dark current, and other interferences on hyperspectral imaging. Simultaneously, the 400-460nm and 900-1000nm bands, which have low signal-to-noise ratios and are severely affected by system noise, were removed to improve the reliability of subsequent spectral analysis.
[0031] Step S12: Background removal and corn kernel region segmentation.
[0032] Comparative analysis of hyperspectral image data from multiple categories revealed that the corn kernel region exhibited the largest grayscale value difference between itself and the background in the 820nm band. Therefore, in the 820nm band, the reflectance of pixels below a grayscale threshold of 50 was set to zero, while the region above the threshold was defined as the corn kernel region. The smallest bounding rectangle containing all non-zero pixels was then identified as the region of interest (ROI) representing the corn kernels. This process separated the corn kernel region from the background, resulting in an effective image region containing only the corn kernels.
[0033] Step S13: Trim and standardize the size of the segmented corn kernel area.
[0034] The minimum bounding rectangle of the segmented corn kernel region is extracted as the region of interest. The region of interest is then cropped and expanded to 640×640 pixels using zero-padding to ensure that the input size of all samples remains consistent, thus meeting the consistency requirements of subsequent feature extraction and model processing. Figure 3 The images show the spectral curves of normal corn, early moldy corn, severely moldy corn, heat-damaged corn, and mud-spotted corn according to the present invention.
[0035] In step S2, reflectance information from the front, back, and side regions of corn kernels after preprocessing in step S1 is extracted and normalized to reduce the impact of light intensity variations and instrument differences on the detection results.
[0036] Statistical analysis was performed on the spectral reflectance of all effective pixels in the region of interest (ROI) of each corn kernel (front, back, and side). The spectral reflectance characteristics of the hyperspectral image data were standardized by normalization to make the spectral characteristics of different samples comparable, providing stable input for subsequent feature selection and defect identification. A corn kernel database was established based on different categories of corn kernels. Figure 4 This is the normalized maize spectral curve of the present invention.
[0037] Normalization processing and procedures include: (1) Calculate the sum of all bands in the hyperspectral image data of each corn kernel: In the formula, Indicates the first band; Indicates the first The sum of the bands in a single hyperspectral image of a corn kernel is a grayscale image, with the same row and column sizes as the hyperspectral image of the corn kernel.
[0038] (2) Average brightness: In the formula, It is the mean of the sum of the bands in the hyperspectral image of the i-th corn kernel. for Effective pixel value within an image refers to the pixel value of the area covered by corn kernels.
[0039] (3) Calculate the corrected ratio: In the formula, N represents the hyperspectral images of 1000 corresponding grain grains. Ideally, the more grains, the better; Indicates the first The ratio of the sum of the mean values of all bands in the hyperspectral image of a corn kernel to the ideal mean; (4) Correction coefficient In the formula, Indicates to The result after rounding to two decimal places can be adjusted according to the actual situation.
[0040] (5) Correct the reflectivity of each band: In the formula, Indicates the first The reflectance value of a hyperspectral image of a corn kernel after correction in the i-th band.
[0041] In step S3, a feature screening method is used to identify spectral bands and select sensitive bands that have a high ability to identify early mold growth, severe mold growth, heat damage and mud spot defects to construct a feature subset.
[0042] By combining the spectral differences of normal grains, early-stage moldy grains, severely moldy grains, heat-damaged grains, and grains with mud spots, the Random Forest Importance Assessment (MDA) algorithm was used to evaluate the importance of each band. To avoid data redundancy and reduced spectral diversity caused by directly selecting the top-ranked bands, a comprehensive spectral curve was proposed. Combining the red, green, blue, and infrared spectral ranges, the entire spectrum was divided into five intervals: 460-500 nm, 520-600 nm, 620-700 nm, 720-800 nm, and 820-900 nm. The MDA algorithm was used to evaluate the importance of each feature within the five wavelength ranges. Based on the obtained importance scores, representative bands were selected from each interval, identifying the representative bands 480 nm, 600 nm, 620 nm, 720 nm, and 820 nm that showed significant responses to different defect types. This reduced the dimensionality of the spectral data while maintaining spectral diversity and improving detection efficiency.
[0043] Random Forest Importance Assessment (MDA) algorithms include: (1) Calculate the original mean square error outside the bag for a single tree: (6) in, Indicates the first Out-of-bag data for each tree Indicates its sample size. Indicates sample The true value Indicates the first Tree samples The original predicted value.
[0044] (2) Calculate the out-of-bag mean square error after feature permutation: (7) in, This represents the out-of-bag mean square error after feature permutation. Representation of features random permutation operation, Representation of features Predicted value after permutation.
[0045] (3) The importance of the original features of the random forest is calculated from the original mean square error outside the bag for a single tree and the mean square error outside the bag after feature permutation. The calculation formula includes: (8) in, Indicates the importance of the original features. This represents the total number of decision trees in the random forest.
[0046] (4) Standardize feature importance to enhance the comparability between features. The calculation formula includes: (9) in, Indicating the importance of standardized features, This represents the total number of features.
[0047] In step S4, using the feature subset from step S3, the defect types of the front, back, and sides of the corn kernels are determined based on the improved YOLOv8 model, and the determination results for the front, back, and sides are obtained.
[0048] To improve detection efficiency and accuracy, targeted improvements were made to the YOLOv8 architecture. Key improvements include adjusting the input layer to accommodate multi-channel hyperspectral data, optimizing the network structure, and optimizing the detector. Specific improvements include: (1) Input layer improvements: The channel dimension of the first convolutional kernel of the YOLOv8 model was modified to support hyperspectral image data input, enabling the model to capture the reflectance characteristics of hyperspectral data in various wavelength ranges, while learning spatial and spectral features, and making full use of the rich spectral information contained in hyperspectral image data.
[0049] (2) Network structure optimization: The Spectral-Channel-Spatial Attention (SCSA) mechanism is integrated into the backbone of the YOLOv8 model. SCSA is a dual-domain attention mechanism designed to jointly utilize spectral and spatial information, avoiding the data insufficiency problem of single information sources. By dynamically allocating weights for spectral bands and spatial regions, the model can more effectively capture key spectral features and spatial distribution characteristics, thereby promoting deep fusion of the spectral and spatial domains. When hyperspectral imaging is applied to corn kernel defect detection, it may be difficult to accurately distinguish different defective corn kernels based solely on spectral or spatial features. To address this limitation, the SCSA mechanism is introduced to simultaneously extract global spectral and spatial features from hyperspectral image data.
[0050] (3) Detector optimization: The original detector in YOLOv8 was replaced with RT-DETR. RT-DETR is an enhanced version of the traditional DETR object detector. By introducing new modules and mechanisms, it effectively overcomes the real-time limitations of DETR, significantly improving processing speed and detection efficiency. As the final decoding component in the detection process, RT-DETR is built on the Transformer architecture and can directly generate detection output from the extracted feature maps without using traditional post-processing techniques such as Non-Maximum Suppression (NMS), simplifying the processing flow and improving detection speed while maintaining detection accuracy. Corn kernel damage detection typically requires the rapid localization and classification of a large number of small targets, placing high demands on both speed and accuracy. Therefore, this improvement is more suitable for the task requirements.
[0051] Before using the improved YOLOv8 for corn kernel defect detection, a processed dataset needs to be prepared, including 200 kernels each from the front, back, and sides of each category. The dataset should be divided into training and testing sets in a 7:3 ratio, with 70% used for training and 30% for testing, to obtain a mature improved YOLOv8 deep learning model. After training, the sensitive band spectral features of the front, back, and sides of the corn kernels (not used in the training) can be used as input. The improved YOLOv8 defect discrimination model will identify the category of each kernel and output the defect type determination results for the front, back, and sides. Defect types include early mold, severe mold, heat damage, mud spots, and normal.
[0052] In step S5, the front, back, and side judgment results obtained in step S4 are encoded, and the quality of corn kernels is comprehensively judged by a corn kernel quality comprehensive judgment method based on multi-view information fusion.
[0053] To efficiently and accurately obtain the defect categories of corn kernels and reduce the number of detection steps, this invention proposes a comprehensive corn kernel quality discrimination method based on multi-view information fusion. The design concept and implementation steps of this method specifically include: A pre-constructed set of unique, reversibly summable numerical codes {0,1,4,13,40} is used to correspond to five quality classification results for corn kernels: normal, early mold, severe mold, heat damage, and mud spots. After quality classification is performed on the front, back, and side of the corn kernels, the corresponding numerical codes are summed to obtain a comprehensive classification value. Since the numerical code set satisfies the condition that the sum of any three codes uniquely corresponds to a combination, the comprehensive classification value can uniquely reflect the combination of quality classification results from the front, back, and side of the corn kernels, thus achieving unambiguous fusion of multi-perspective quality information. Based on the comprehensive classification value, the overall quality of the corn kernels can be accurately determined while preserving the traceability of single-sided classification results.
[0054] The calculation methods and processes include: (1) The three sides of a corn kernel are the front, back, and side, and their corresponding quality judgment results are expressed as follows: (10) in, Indicates the front. Indicates the opposite. The numbers represent the side view, with 0 indicating normal, 1 indicating mud spots, 4 indicating heat loss, 13 indicating early mold growth, and 40 indicating severe mold growth.
[0055] (2) The discriminant code S for corn kernels is defined as: (11) Because the encoding set {0,1,4,13,40} has the uniqueness of summation of three-number combinations (the encoding set can also be other combinations), any discrimination code S can be uniquely mapped to the corresponding combination. If two or three sides are judged as abnormal kernels, the discrimination is carried out in the order of importance: severe mold > early mold = heat damage > mud spots > normal. Among them, early mold and heat damage are judged by comparing the confidence of each side, and the discrimination result of the side with the highest confidence is taken, thereby achieving a unique judgment of the quality of the three sides of the corn kernel. This invention avoids the problem of missed defects caused by single-side detection by jointly detecting and comprehensively judging the hyperspectral information of the front, back and side sides of the corn kernel, and significantly improves the accuracy and robustness of early mold, severe mold, heat damage and mud spot defects. Figure 5 This is a comprehensive judgment query table for corn kernel quality based on multi-perspective information fusion, as described in this invention. See also... Figure 6 The quality of corn kernels can be evaluated based on the discriminant code S. The smaller the value of the discriminant code S, the better the quality of the corn kernels, with S=0 indicating the best quality. The larger the value of the discriminant code S, the worse the quality of the corn kernels, with S=120 indicating the worst quality. Figure 7 This invention identifies spectral differences in corn kernels with different types of defects. It simultaneously acquires spatial and spectral information of corn kernels, improving the accuracy of defect identification.
[0056] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. However, these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A rapid detection method for multiple types of defects in maize kernels using hyperspectral imaging, characterized in that: Includes the following steps: Step S1: Collect hyperspectral image data of corn kernels, preprocess the hyperspectral image data, including radiometric correction, noise removal, background removal, corn region segmentation and size normalization, and generate standard reflectance products; Step S2: Extract the corn kernel reflectance information after preprocessing in Step S1 and perform normalization processing; through normalization processing, the spectral reflectance characteristics of the hyperspectral image data are standardized, so that the spectral characteristics between different samples are comparable, providing a stable input for subsequent feature selection and defect identification, and establishing a corn kernel database according to different categories of corn kernels. Step S3: Use the feature screening method to identify the spectral data after normalization in step S2, select sensitive bands with high identification ability for corn kernel defects, and construct a feature subset; Step S4: Using the feature subset from step S3, the defect type of corn kernels is determined based on the improved Yolov8 model to obtain the determination results from different perspectives; the improvements to the improved Yolov8 model include adjusting the input layer to adapt to multi-channel hyperspectral data, optimizing the network structure, and optimizing the detector. Step S5: Encode the judgment result obtained in step S4, and comprehensively judge the quality of corn kernels using a comprehensive judgment method based on multi-view information fusion; pre-construct a set of numerical codes with unique and reversible summation characteristics, and assign them to the judgment results of corn kernel defect types respectively; after the judgment of defect types of corn kernels from different angles is completed, sum the corresponding numerical codes to obtain the comprehensive judgment value, thereby achieving a unique judgment of corn kernel quality.
2. The rapid detection method for multiple defects in maize kernels using hyperspectral imaging according to claim 1, characterized in that: In step S1, the acquired hyperspectral image data of corn kernels is preprocessed, including the following steps: Step S11: Radiation Correction and Noise Band Removal: Radiometric calibration was performed before acquiring corn kernel image data; bands with low signal-to-noise ratios and those severely affected by system noise were removed. Step S12: Background removal and corn kernel region segmentation: Under a specific spectral band, the reflectance of pixels below a set grayscale threshold is set to zero, and the portion above the threshold is the corn kernel region; the smallest bounding rectangle containing all non-zero pixels is determined as the region of interest representing the corn kernels; the corn kernel region is separated from the background to obtain an effective image region containing only corn kernels. Step S13: Trim and standardize the size of the segmented corn kernel area: The minimum bounding rectangle of the segmented corn kernel region is extracted as the region of interest. The region of interest is then cropped and expanded to a specific pixel using zero padding to ensure that the input size of all samples remains consistent.
3. The rapid detection method for multiple defects in maize kernels using hyperspectral imaging according to claim 2, characterized in that: In step S2: the spectral reflectance of all effective pixels in the region of interest of the front, back and side of each corn kernel is statistically analyzed. The spectral reflectance characteristics of the hyperspectral image data are standardized by normalization to make the spectral characteristics of different samples comparable. A corn kernel database is established according to different categories of corn kernels.
4. The rapid detection method for multiple defects in maize kernels using hyperspectral imaging according to claim 3, characterized in that: The normalization process in step S2 includes: (1) Calculate the sum of all bands of the hyperspectral image data for each corn kernel: In the formula, Indicates the first band; Indicates the first The sum of the bands of the hyperspectral images of corn kernels is a grayscale image with the same row and column size as the hyperspectral images of corn kernels. (2) Average brightness: In the formula, It is the mean of the sum of the bands in the hyperspectral image of the i-th corn kernel. for Effective pixel value within the image refers to the pixel value of the corn kernel-covered area. (3) Calculate the corrected ratio: In the formula, N represents the hyperspectral images of 1000 corresponding grain grains. Ideally, the more grains, the better; Indicates the first The ratio of the sum of the mean values of all bands in the hyperspectral image of a corn kernel to the ideal mean; (4) Correction coefficient In the formula, Indicates to The number of decimal places retained after rounding can be adjusted according to the actual situation. (5) Correct the reflectivity of each band: In the formula, Indicates the first The reflectance value of a hyperspectral image of a corn kernel after correction in the i-th band.
5. The rapid detection method for multiple defects in maize kernels using hyperspectral imaging according to any one of claims 1-4, characterized in that: In step S3, a feature screening method is used to identify spectral bands, and sensitive bands with high identification ability for early mold growth, severe mold growth, heat damage and mud spot defects are selected to construct a feature subset. The process of constructing the feature subset includes: combining the spectral differences of normal grains, early moldy grains, severely moldy grains, heat-damaged grains, and mud-spotted grains, using the Random Forest Importance Assessment (MDA) algorithm to assess the importance of each band, dividing the entire spectrum into five intervals; using the Random Forest Importance Assessment (MDA) algorithm to assess the importance of each feature within the five wavelength ranges, and selecting representative bands from each interval based on the obtained importance scores, thus screening out representative bands that show significant responses to different defect types.
6. The rapid detection method for multiple defects in maize kernels using hyperspectral imaging according to claim 5, characterized in that: In step S3, the Random Forest Importance Assessment (MDA) algorithm includes: (1) Calculate the original mean square error outside the bag for a single tree: (6) in, Indicates the first Out-of-bag data for each tree Indicates its sample size. Indicates sample The true value Indicates the first Tree samples The original predicted value; (2) Calculate the out-of-bag mean square error after feature permutation: (7) in, This represents the out-of-bag mean square error after feature permutation. Representation of features random permutation operation, Representation of features Predicted value after permutation; (3) The importance of the original features of the random forest is calculated from the original mean square error outside the bag for a single tree and the mean square error outside the bag after feature permutation. The calculation formula includes: (8) in, Indicates the importance of the original features. This represents the total number of decision trees in the random forest; (4) Standardize feature importance to enhance the comparability between features. The calculation formula includes: (9) in, Indicating the importance of standardized features, This represents the total number of features.
7. The rapid detection method for multiple defects in maize kernels using hyperspectral imaging according to any one of claims 1-6, characterized in that: In step S4, the specific improvements to the improved Yolov8 model include: Step S41: Input layer improvement: Modify the channel dimension of the first convolutional kernel in the YOLOv8 model; Step S42: Network structure optimization: The spectral-channel-spatial attention (SCSA) mechanism is incorporated into the backbone of the YOLOv8 model; Step S43: Detector optimization: Replace the original detector in YOLOv8 with RT-DETR.
8. The rapid detection method for multiple defects in maize kernels using hyperspectral imaging according to claim 7, characterized in that: In step S4, before using the improved YOLOv8 to detect defects in corn kernels, a processed dataset is prepared, including N kernels each from the front, back, and side of each category. The dataset is divided into training and testing sets according to the proportions to obtain a mature improved YOLOv8 deep learning model. After training, the sensitive band spectral features of the front, back, and side of the corn kernels that were not involved in the training are used as input. The improved YOLOv8 defect discrimination model is used to identify the category to which the kernels belong, and outputs the front defect type determination result, the back defect type determination result, and the side defect type determination result.
9. The rapid detection method for multiple defects in maize kernels using hyperspectral imaging according to any one of claims 1-8, characterized in that: In step S5, the specific implementation steps of the comprehensive judgment method for corn kernel quality based on multi-view information fusion include: Step S51: Pre-construct a set of numerical codes with unique and reversible summation properties, and assign them to the five quality discrimination results of corn kernels respectively; Step S52: After the quality judgment of the front, back and side of the corn kernels is completed, the numerical codes corresponding to the three sides are summed to obtain the comprehensive judgment value; Step S53: Based on the comprehensive discrimination value, accurately determine the overall quality of corn kernels and retain the traceability of the single-sided discrimination results.
10. The rapid detection method for multiple defects in maize kernels using hyperspectral imaging according to claim 9, characterized in that: In step S5, the calculation method and process of the comprehensive judgment method for corn kernel quality based on multi-view information fusion include: (1) The three sides of a corn kernel are the front, back, and side, and their corresponding quality judgment results are expressed as follows: (10) in, Indicates the front. Indicates the opposite. The numbers represent the side view, with 0 indicating normal, 1 indicating mud spots, 4 indicating heat loss, 13 indicating early mold growth, and 40 indicating severe mold growth. (2) The discriminant code S for corn kernels is defined as: (11) Any discriminant code S can be uniquely mapped to the corresponding combination, thus enabling a unique determination of the quality of the three sides of corn kernels.