A rapid screening method and system for internal mold of peanuts

Through the combination of hyperspectral imaging and Bayesian probability classification model, the dynamic adjustment of filter core size and multi-dimensional feature fusion is solved, and the accuracy of peanut mold area boundary detection is achieved, and the mold area marking with high confidence is improved, which is improved detection reliability and robustness.

CN119992539BActive Publication Date: 2025-07-11SISHUI JINCHUAN PEANUT FOOD CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510472127.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-16
Publication Date
2025-07-11
Estimated Expiration
2045-04-16

AI Technical Summary

Technical Problem

The prior art is difficult to accurately define the transitional boundary between the moldy area of peanuts and normal tissues, especially in the early stages of moldy or complex anatomical structures, resulting in low boundary confidence in the detection results and high risk of false detection and missed detection.

Method used

Hyperspectral imaging technology is used to combine Bayesian probability classification model, and the boundary confidence of moldy areas is generated by dynamically adjusting the filter core size, multi-dimensional feature fusion and consistency verification of spectral and spatial characteristics, and a moldy area marking map is generated by combining the region growth algorithm.

Benefits of technology

It significantly improves the accuracy and anti-interference ability of border detection in moldy areas, can accurately capture the gradual transition characteristics of moldy diffusion, reduces the false detection rate, and improves the reliability and robustness of early moldy sample detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119992539B_ABST
    Figure CN119992539B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for rapid screening of internal mold in peanuts, specifically relating to the technical field of non-destructive testing of agricultural products, and is used to solve the problems of false detection and missed detection caused by low contrast and gradual boundaries in the initial stage of mildew and samples with internal diffusion in existing detection methods; based on hyperspectral imaging technology, the filter kernel size is dynamically adjusted through the joint analysis of frequency-domain energy distribution and spatial local variance to enhance the detailed features of the gradual boundaries in the image; the spectral and spatial feature consistency verification is used to screen high-confidence candidate regions, and the principal component features representing the mildew diffusion trend are extracted by combining texture direction analysis, and a fusion feature vector is constructed by dynamically splicing with the spectral gradient direction; the boundary confidence is quantified through a Bayesian probability classification model, and a region growing algorithm with neighborhood similarity constraint is used to generate a mildew marking map with continuous space and consistent features, and at the same time, a dynamic threshold correction mechanism is introduced to adaptively optimize the segmentation standard; the detection accuracy and anti-interference ability of fuzzy boundaries are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of non-destructive testing of agricultural products. More specifically, the present invention relates to a method and system for rapid screening of internal mold in peanuts. Background Art

[0002] Peanut mildew detection usually relies on image processing algorithms combined with spectral analysis means to identify and segment mildew areas. For example, detection methods based on ultraviolet fluorescence images or hyperspectral imaging distinguish normal and mildew areas through steps such as gray mapping and clustering analysis, mainly relying on spectral or morphological differences between mildew and normal tissues in the image. For peanut samples with severe mildew and clear boundaries, conventional algorithms (such as threshold segmentation and support vector machine classification) can achieve high detection accuracy. However, for samples in the initial stage of mildew or with internal mycelium diffusion, the transition boundary between the mildew area and normal tissue often exhibits fuzzy features such as low contrast and gradual density, making it difficult to achieve effective segmentation through simple image enhancement or spectral feature screening.

[0003] The limitations of the prior art are as follows: Due to the spectral gradual change characteristics (such as the gentle change of reflectance in the near-infrared band) and spatial morphological ambiguity (such as density gradient caused by mycelium diffusion) between the mildew area and normal tissue, it is difficult to accurately define the transition boundary, which will directly lead to low boundary confidence in the segmentation result and a significant increase in the risk of false detection and missed detection. Especially in peanut samples in the initial stage of mildew or with complex anatomical structures, the credibility of the detection result is difficult to meet the requirements of high-precision screening. Summary of the Invention

[0004] In order to overcome the above-mentioned defects of the prior art, embodiments of the present invention provide a method and system for rapid screening of internal mold in peanuts to solve the problems raised in the above background art.

[0005] To achieve the above object, the present invention provides the following technical solutions:

[0006] A method for rapid screening of internal mold in peanuts, comprising the following steps:

[0007] S1. Collect the original hyperspectral image of the peanut sample, and the original hyperspectral image contains gray-scale data of multiple bands;

[0008] S2. Preprocess the original hyperspectral image to generate an enhanced hyperspectral image, and dynamically adjust the filter kernel size according to the combined relationship between the frequency-domain energy distribution and the spatial local variance;

[0009] S3. Segment the mildew candidate area from the enhanced hyperspectral image based on a preset gray-scale threshold;

[0010] S4. Perform consistency verification on the spectral and spatial characteristics of the mildew candidate area, and screen the candidate areas that conform to the mildew diffusion law to generate a set of effective candidate areas;

[0011] S5. Perform texture direction analysis, consistency screening, and principal component dimensionality reduction on the set of effective candidate regions, and generate a fused feature vector through feature splicing;

[0012] S6. Input the fused feature vector into a Bayesian probability classification model to generate the boundary confidence of the mildew candidate regions, and perform region growing on the pixel points greater than the preset boundary confidence threshold to generate a mildew region marking map.

[0013] In a preferred embodiment, collect the original hyperspectral image of the peanut sample. The original hyperspectral image contains grayscale data of multiple bands, including:

[0014] Collect the hyperspectral reflectance data of the peanut sample using a hyperspectral imaging device within a preset wavelength range;

[0015] Perform step-by-step spectral calibration on the hyperspectral reflectance data to generate an original hyperspectral image containing grayscale data of multiple bands;

[0016] Dynamically adjust the spatial resolution of the hyperspectral imaging device according to the physical size of the peanut sample to ensure that the area covered by a single pixel is less than the preset anatomical structure threshold.

[0017] In a preferred embodiment, preprocess the original hyperspectral image to generate an enhanced hyperspectral image, and dynamically adjust the filter kernel size according to the combined relationship between the frequency domain energy distribution and the spatial local variance, including:

[0018] Perform morphological closing operation and contrast optimization on the original hyperspectral image in sequence to generate an enhanced hyperspectral image;

[0019] Perform two-dimensional Fourier transform on the enhanced hyperspectral image to generate a frequency domain energy distribution map, and calculate the local variance in blocks to generate a spatial local variance matrix;

[0020] Dynamically adjust the filter kernel size of the morphological closing operation according to the combined relationship between the high-frequency energy ratio in the frequency domain energy distribution map and the variance peak value in the spatial local variance matrix.

[0021] In a preferred embodiment, segment the mildew candidate regions from the enhanced hyperspectral image based on a preset grayscale threshold, including:

[0022] Calculate the grayscale mean and grayscale standard deviation of each band in the enhanced hyperspectral image to generate a multi-band grayscale statistical matrix;

[0023] Dynamically set the preset grayscale threshold according to the linear combination of the grayscale mean and grayscale standard deviation in the multi-band grayscale statistical matrix;

[0024] Perform pixel-by-pixel comparison on the enhanced hyperspectral image based on a preset grayscale threshold, and mark the continuous pixel region with a grayscale value exceeding the threshold as a mildew candidate region.

[0025] In a preferred embodiment, perform consistency verification on the spectral and spatial characteristics of the mildew candidate regions, and screen the candidate regions that conform to the mildew diffusion law to generate an effective candidate region set, including:

[0026] Calculate the spectral gradient direction of the mildew candidate region, and the spectral gradient direction is determined by synthesizing the gray difference vectors of adjacent bands of the mildew candidate region;

[0027] Calculate the spatial morphological change rate of the mildew candidate region;

[0028] Verify the cosine value of the angle between the spectral gradient direction and the spatial morphological change rate of the mildew candidate region, and screen the mildew candidate regions with a cosine value of the angle greater than the preset correlation threshold to generate an effective candidate region set;

[0029] According to the statistical distribution of the spectral gradient direction and the spatial morphological change rate of each region in the effective candidate region set, dynamically adjust the preset correlation threshold to exclude isolated abnormal regions.

[0030] In a preferred embodiment, the gray difference vector of adjacent bands uses the average gray difference between adjacent two bands of the mildew candidate region as a vector component.

[0031] In a preferred embodiment, the spatial morphological change rate is calculated by the linear regression slope of the aspect ratio of the minimum bounding rectangle of the mildew candidate region changing with the band number.

[0032] In a preferred embodiment, perform texture direction analysis, consistency screening, and principal component dimensionality reduction on the effective candidate region set, and generate a fused feature vector through feature splicing, including:

[0033] Perform gray-level co-occurrence matrix analysis on the effective candidate region set, and extract the energy and contrast of each effective candidate region in four main directions to generate texture directionality parameters;

[0034] Based on the distribution consistency of energy and contrast in the texture directionality parameters, screen the main direction that matches the mildew diffusion direction to generate a direction consistency parameter;

[0035] Perform principal component analysis on the direction consistency parameter, and dynamically retain the principal components according to the correlation between the principal component variance contribution rate and the spectral attenuation direction of the mildew candidate region to generate a dimensionality-reduced feature vector;

[0036] Splice the dimensionality-reduced feature vector and the spectral gradient direction of the effective candidate region set according to the spatial position correspondence relationship to generate a fused feature vector.

[0037] In a preferred embodiment, the fused feature vector is input into a Bayesian probability classification model to generate the boundary confidence of the mildew candidate region, and region growing is performed on the pixel points greater than the preset boundary confidence threshold to generate a mildew region labeling map, including:

[0038] Input the fused feature vector into the Bayesian probability classification model, and calculate the boundary confidence of the mildew candidate region based on the conditional probability distribution of the feature components;

[0039] According to the comparison result between the boundary confidence of the mildew candidate region and the preset boundary confidence threshold, perform eight-neighborhood similarity region growing on the pixel points greater than the preset boundary confidence threshold, and merge the pixels that meet the similarity constraints to generate a mildew region labeling map;

[0040] Dynamically correct the boundary confidence threshold based on the confidence mean value of the regions in the mildew region labeling map and the neighborhood gradient change rate, and exclude the pseudo-boundary regions with discrete confidence distributions.

[0041] On the other hand, the present invention provides a rapid screening system for internal mildew of peanuts, including the following modules:

[0042] Original image acquisition module: used to acquire the original hyperspectral image of the peanut sample, and the original hyperspectral image contains grayscale data of multiple bands;

[0043] Dynamic filtering adjustment module: used to preprocess the original hyperspectral image to generate an enhanced hyperspectral image, and dynamically adjust the filter kernel size according to the combined relationship between the frequency domain energy distribution and the spatial local variance;

[0044] Gray-scale threshold segmentation module: used to segment the mildew candidate region from the enhanced hyperspectral image based on the preset gray-scale threshold;

[0045] Feature screening and verification module: used to verify the consistency of the spectral and spatial features of the mildew candidate region, and screen the candidate regions that conform to the mildew diffusion law to generate a set of effective candidate regions;

[0046] Texture dimension reduction and fusion module: used to perform texture direction analysis, consistency screening and principal component dimension reduction on the set of effective candidate regions, and generate a fused feature vector through feature splicing;

[0047] Region confidence generation module: used to input the fused feature vector into the Bayesian probability classification model to generate the boundary confidence of the mildew candidate region, and perform region growing on the pixel points greater than the preset boundary confidence threshold to generate a mildew region labeling map.

[0048] Compared with the prior art, the present invention has the following beneficial effects:

[0049] 1. By dynamically adjusting the filter kernel size and multi-dimensional feature fusion mechanism, the accuracy and anti-interference ability of mildew area boundary detection are significantly improved; in view of the low contrast and gradually changing density characteristics of the initial mildew stage and the internal diffusion area, a combined analysis strategy of frequency domain energy distribution and spatial local variance is adopted to adaptively optimize the filter parameters in the preprocessing process, effectively suppressing noise interference while retaining weak signal features and enhancing the distinguishability of the gradually changing boundaries in the image; combined with the consistency verification mechanism of spectral and spatial features, a subset that conforms to the mildew diffusion direction law is screened out from the candidate areas, avoiding mis-segmentation caused by local noise or morphological blurring, and ensuring that subsequent analysis focuses on high-confidence target areas; through texture direction analysis and principal component dimensionality reduction, key texture features representing the mildew diffusion trend are extracted and dynamically spliced with the spectral gradient direction to generate a fusion feature vector, providing a multi-dimensional joint criterion for boundary determination;

[0050] 2. Based on the collaborative optimization strategy of Bayesian probability classification and region growing, the processing ability of fuzzy boundaries is further strengthened; by modeling the probability distribution of the fusion feature vector, the confidence of the mildew area boundary is quantified, and the region growing process is driven by combining neighborhood similarity constraint conditions, so that the boundary marking result reaches a balance between spatial continuity and feature consistency; the dynamic threshold correction mechanism iteratively adjusts the segmentation standard according to the average region confidence and the gradient change rate, adaptively adapting to the detection requirements of different mildew degrees and sample structures, and avoiding missed detection of weak diffusion areas or complex boundaries by fixed thresholds; while reducing the false detection rate, it can accurately capture the gradually changing transition features of mildew diffusion, especially suitable for the detection of early mildew samples with internal hypha penetration and fuzzy boundaries, significantly improving the reliability and robustness of the screening results. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] Figure 1 is a flowchart of a rapid screening method for internal mildew of peanuts according to the present invention;

[0052] Figure 2 is a schematic structural diagram of a rapid screening system for internal mildew of peanuts according to the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0053] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0054] Example 1: Figure 1 A rapid screening method for internal mildew of peanuts according to the present invention is given, which includes the following steps:

[0055] S1. Collect the original hyperspectral image of the peanut sample, where the original hyperspectral image contains grayscale data of multiple bands;

[0056] S2. Preprocess the original hyperspectral image to generate an enhanced hyperspectral image, and dynamically adjust the filter kernel size according to the combined relationship between the frequency-domain energy distribution and the spatial local variance;

[0057] S3. Segment the mildew candidate regions from the enhanced hyperspectral image based on a preset grayscale threshold;

[0058] S4. Perform consistency verification on the spectral and spatial characteristics of the mildew candidate regions, and screen the candidate regions that conform to the mildew diffusion law to generate an effective candidate region set;

[0059] S5. Perform texture direction analysis, consistency screening, and principal component dimensionality reduction on the effective candidate region set, and generate a fused feature vector through feature splicing;

[0060] S6. Input the fused feature vector into the Bayesian probability classification model to generate the boundary confidence of the mildew candidate regions, and perform region growing on the pixel points with a boundary confidence greater than the preset boundary confidence threshold to generate a mildew region marking map.

[0061] S1. Collect the original hyperspectral image of the peanut sample, where the original hyperspectral image contains grayscale data of multiple bands, including:

[0062] Collect the hyperspectral reflectance data of the peanut sample by using a hyperspectral imaging device within a preset wavelength range. The preset wavelength range is set according to the spectral absorption characteristics of the mildew region, specifically including the visible light band and the near-infrared band. For example, the visible light band range is 400 nm to 700 nm, and the near-infrared band range is 900 nm to 1700 nm. The hyperspectral imaging device adopts a line scanning mode. During the scanning process, the peanut sample is fixed on the stage, and the light source uses a halogen lamp, whose spectral output covers the preset wavelength range. The light intensity is adjusted in real time according to the surface reflectance of the sample. For example, when the detected surface reflectance of the sample is lower than 20%, the light source power is adjusted to 150 W; when the reflectance is higher than 80%, the light source power is adjusted to 50 W. The spectral resolution of the hyperspectral imaging device is set to 10 nm, and the initial value of the spatial resolution is set to 0.1 mm × 0.1 mm per pixel, ensuring that the area covered by a single pixel can resolve the microscopic structures of the peanut internal embryo and the mildew region.

[0063] Perform step-by-step spectral calibration on the hyperspectral reflectance data to generate an original hyperspectral image containing grayscale data of multiple bands. The spectral calibration process includes the following steps: First, place a barium sulfate standard whiteboard with a reflectance of 98% on the stage and collect its hyperspectral reflectance data as the calibration reference. Second, compare the original reflectance data of the peanut sample with the reference data of the standard whiteboard band by band, and calculate the gain coefficient and offset for each band. The gain coefficient is the ratio of the whiteboard reflectance to the original reflectance of the sample, and the offset is the whiteboard reflectance minus the original reflectance of the sample. Finally, convert the calibrated reflectance data into grayscale data. The conversion method is to normalize the calibrated reflectance to the range of 0 to 1 and then multiply by 255 to obtain grayscale values from 0 to 255.

[0064] Dynamically adjust the spatial resolution of the hyperspectral imaging device according to the physical size of the peanut sample. The physical size is measured from the original hyperspectral image through an image processing algorithm. Specifically, extract the maximum circumscribed rectangle of the peanut sample, calculate the number of pixels on its long side and short side, and combine the actual size of a single pixel, which is 0.1 mm, to calculate the actual length and width of the sample. If the actual length of the sample is greater than 20 mm, adjust the spatial resolution to 0.05 mm × 0.05 mm per pixel; if the actual length of the sample is less than or equal to 20 mm, maintain the initial resolution. The preset anatomical structure threshold is set according to the minimum size of the peanut embryo. For example, when the minimum size of the embryo is 2 mm, the area covered by a single pixel should be less than 0.5 mm × 0.5 mm.

[0065] S2. Preprocess the original hyperspectral image to generate an enhanced hyperspectral image, and dynamically adjust the filter kernel size according to the combined relationship between the frequency-domain energy distribution and the spatial local variance, including:

[0066] Perform morphological closing operation and contrast optimization on the original hyperspectral image in sequence to generate an enhanced hyperspectral image. The morphological closing operation uses a circular structuring element, and the diameter of the structuring element is set according to the roughness of the surface texture of the peanut sample. For example, when there are obvious cracks or depressions on the sample surface, the diameter of the structuring element is set to 3 pixels to fill small holes; when the surface is relatively smooth, the diameter of the structuring element is set to 5 pixels to suppress granular noise. The parameters of the contrast optimization are dynamically adjusted according to the overall grayscale distribution of the image. For example, stretch the grayscale range through histogram equalization to enhance the grayscale difference in low-contrast regions. The generation process of the enhanced hyperspectral image is as follows: First, perform the morphological closing operation on each band of the original hyperspectral image separately, and then perform contrast optimization on the image after the closing operation to output the enhanced hyperspectral image.

[0067] Perform a two-dimensional Fourier transform on the enhanced hyperspectral image to generate a frequency-domain energy distribution map, and calculate the local variance in blocks to generate a spatial local variance matrix. The two-dimensional Fourier transform is performed separately for each band of the enhanced hyperspectral image to generate the corresponding frequency-domain energy distribution map. The proportion of high-frequency energy in the frequency-domain energy distribution map is obtained by calculating the ratio of the sum of the energy in the high-frequency region (e.g., the region where the frequency is higher than 1 / 10 of the reciprocal of the image width) to the sum of the energy in the entire frequency band. When calculating the local variance in blocks, the enhanced hyperspectral image is divided into multiple sub-blocks, and the size of the sub-blocks is set according to the image resolution. For example, each sub-block contains an 8-pixel × 8-pixel area, and the variance value of the pixel grayscale within each sub-block is calculated and arranged in spatial position to generate a spatial local variance matrix.

[0068] Dynamically adjust the filter kernel size of the morphological closing operation according to the combined relationship between the proportion of high-frequency energy in the frequency-domain energy distribution map and the variance peak value in the spatial local variance matrix. The proportion of high-frequency energy is used to evaluate the intensity of high-frequency noise. For example, when the proportion of high-frequency energy is greater than 60%, it is determined that the salt-and-pepper noise is dominant; the variance peak value in the spatial local variance matrix is used to evaluate the non-uniformity of the noise spatial distribution. For example, when the variance peak value is greater than the preset threshold, it is determined that the Gaussian noise is dominant. Adjust the filter kernel size according to the noise type combination: if the proportion of high-frequency energy is greater than 60% and the variance peak value is greater than the threshold, adjust the filter kernel size of the morphological closing operation to 3 pixels × 3 pixels; if only the proportion of high-frequency energy is greater than 60%, adjust the filter kernel size to 5 pixels × 5 pixels; if only the variance peak value is greater than the threshold, keep the filter kernel size at the default value of 7 pixels × 7 pixels.

[0069] S3. Segment the mildew candidate regions from the enhanced hyperspectral image based on a preset grayscale threshold, including:

[0070] Calculate the grayscale mean and grayscale standard deviation of each band in the enhanced hyperspectral image to generate a multi-band grayscale statistical matrix. The grayscale mean is used to characterize the overall brightness level of each band. The specific calculation method is: sum the grayscale values of all pixels in a certain band and then divide by the total number of pixels. For example, the grayscale mean of band k is the arithmetic average of the grayscale values of all pixels in this band. The grayscale standard deviation reflects the degree of dispersion of the pixel grayscale values. The calculation method is: first calculate the sum of the squared differences between each pixel grayscale value and the mean, then divide by the total number of pixels and take the square root. For example, the standard deviation of band k is the average fluctuation amplitude of the grayscale values in this band deviating from the mean. The rows of the multi-band grayscale statistical matrix correspond to the band numbers, and the columns sequentially store the grayscale mean and standard deviation of each band. For example, the grayscale mean of band 1 is stored in the first row and first column of the matrix, and the grayscale standard deviation of band 1 is stored in the first row and second column, and so on to form a complete statistical feature table. The construction logic of this matrix is based on statistical principles. The mean reflects the overall brightness, and the standard deviation quantifies the local fluctuation, providing a data basis for subsequent dynamic threshold adjustment.

[0071] Dynamically set a preset gray threshold according to the linear combination of the gray mean and the gray standard deviation in the multi-band gray statistical matrix. The linear combination proportionality coefficient is positively correlated with the spectral absorption characteristics of the mildew area, and the spectral absorption characteristics are characterized by the degree of reduction in the reflectance of the mildew substance in a specific band (such as the near-infrared band). For example, in the range of 900 nanometers to 1700 nanometers in the near-infrared band, the reflectance of the mildew area is 30% to 50% lower than that of the normal tissue due to the light absorption of the hyphae. The proportionality coefficient is adjusted according to the reflectance difference: if the reflectance difference in a certain band is 40%, the proportionality coefficient is set to 1.5; if the difference is 25%, the coefficient is set to 1.2; when the difference is less than 15%, the coefficient is set to 1.0. The calculation formula for the preset gray threshold is: Threshold = Gray Mean + Proportionality Coefficient × Gray Standard Deviation. For example, if the gray mean in a certain near-infrared band is 120, the standard deviation is 18, and the proportionality coefficient is 1.5, then the threshold is 120 + 1.5×18 = 147. The technical logic of this rule is: the mean provides the reference brightness, the standard deviation reflects the noise intensity, and the proportionality coefficient dynamically adjusts the tightness of the threshold according to the mildew light absorption intensity. For example, a high proportionality coefficient (1.5) increases the threshold in the strong absorption band to reduce false detection.

[0072] Perform pixel-by-pixel comparison on the enhanced hyperspectral image based on the preset gray threshold, and mark the continuous pixel area with a gray value exceeding the threshold as a mildew candidate area. The pixel-by-pixel comparison process is as follows: for the enhanced hyperspectral image of each band, sequentially traverse the gray value of each pixel. If its value is greater than the preset threshold of that band, it is marked as a candidate point. Perform region growing on the marked candidate points to merge adjacent pixels to form a continuous region. The adjacent determination condition is: there are at least three adjacent candidate points in the eight neighborhood directions (up, down, left, right, and four diagonal directions) of the pixel. The continuous region needs to meet the minimum area constraint. For example, the number of pixels covered by the region needs to be greater than 10×10 pixels to exclude the misjudgment of isolated noise points. The basis for setting the minimum area is the minimum size of the peanut embryo (such as 2 mm×2 mm), which is converted to 20×20 pixels in combination with the resolution (0.1 mm / pixel), and conservatively set to 10×10 pixels to be compatible with the resolution differences of different devices. Finally, all continuous regions that meet the area constraint form a set of mildew candidate regions. For example, a 20×20 pixel continuous region is marked as a candidate region, while an isolated 5×5 pixel region is filtered.

[0073] S4. Conduct consistency verification on the spectral and spatial characteristics of the mildew candidate regions, and screen the candidate regions that conform to the mildew diffusion law to generate a set of effective candidate regions, including:

[0074] Calculate the spectral gradient direction of the mildew candidate region. The spectral gradient direction is determined by synthesizing the gray difference vectors of adjacent bands in the mildew candidate region. Specifically, for each mildew candidate region, calculate the average gray difference between its adjacent two bands. For example, the gray difference between band k and band k + 1 is the average gray value of the region in band k minus the average gray value of band k + 1. Take the gray differences of adjacent bands as vector components. For example, the gray difference from band k to k + 1 is the x-component of the vector, and the gray difference from band k + 1 to k + 2 is the y-component of the vector. After synthesizing the two-dimensional vector, calculate its direction angle. The range of the direction angle is from 0 degrees to 360 degrees, representing the spectral gradient direction. For example, if the gray difference from band k to k + 1 is -15 and the difference from band k + 1 to k + 2 is -10, then the vector is (-15, -10), and the direction angle is 33.7 degrees, indicating that the spectral gray value decreases as the band number increases, pointing to the third quadrant.

[0075] Among them, k represents the current band number of the hyperspectral image. For example, k is the near-infrared band at 900 nm, and k + 1 is 910 nm. The x-component of the vector is the average gray difference between the mildew candidate region in band k and k + 1, which is used to characterize the change amount of the spectral gradient in adjacent bands. The y-component of the vector is the average gray difference between the mildew candidate region in band k + 1 and k + 2, which is used to characterize the change amount of the spectral gradient in the subsequent adjacent bands.

[0076] Calculate the spatial morphological change rate of the mildew candidate region. The spatial morphological change rate is calculated by the linear regression slope of the aspect ratio of the minimum bounding rectangle of the mildew candidate region changing with the band number. Specifically, for each mildew candidate region, extract the aspect ratio of its minimum bounding rectangle in each band. For example, the aspect ratio in band k is the length of the long side of the rectangle divided by the length of the short side. Take the band number as the independent variable and the aspect ratio as the dependent variable, and perform a linear regression analysis to obtain the slope value. The larger the absolute value of the slope, the higher the rate of change of the aspect ratio with the band. For example, the aspect ratio sequence of a mildew candidate region from band k to k + 5 is [1.2, 1.5, 1.8, 2.1, 2.4], and the linear regression slope is 0.3, indicating that for each additional band, the aspect ratio increases by 0.3, reflecting that the mildew diffusion direction has significant anisotropy.

[0077] Verify the cosine value of the angle between the spectral gradient direction and the spatial morphological change rate of the mildew candidate region. The cosine value of the angle is obtained by calculating the dot product of the spectral gradient direction vector and the spatial morphological change rate vector and dividing it by the product of the magnitudes of the two vectors. For example, if the spectral gradient direction vector is (Δk, Δk + 1) = (-15, -10) and the spatial morphological change rate vector is (1, 0.3) (the slope 0.3 corresponds to the direction vector), then the dot product is (-15×1) + (-10×0.3) = -18, the product of the magnitudes is approximately 18.75, and the cosine value of the angle is -18 / 18.75 ≈ -0.96. Screen the mildew candidate regions with the cosine value of the angle greater than the preset correlation threshold (e.g., 0.7) to generate a set of effective candidate regions. A negative value indicates that the spectral gradient direction is opposite to the spatial morphological change direction, but when the absolute value is greater than the threshold, it is still regarded as strongly correlated. For example, the direction of spectral attenuation caused by the spread of hyphae is opposite to the direction of morphological expansion.

[0078] According to the statistical distribution of the spectral gradient direction and the spatial morphological change rate of each region in the set of effective candidate regions, dynamically adjust the preset correlation threshold to exclude isolated abnormal regions. The statistical distribution is obtained by calculating the mean and standard deviation of the cosine values of the angles in the set of effective candidate regions. For example, the mean is 0.85 and the standard deviation is 0.1. The dynamic adjustment rule is: if the mean and the standard deviation satisfy mean - 3×standard deviation > the current threshold, then adjust the threshold up to mean - 2×standard deviation; if mean + 3×standard deviation < the current threshold, then adjust the threshold down to mean + 2×standard deviation. For example, if the initial threshold is set to 0.7, and the mean of the cosine values of the angles in the effective regions is 0.85 and the standard deviation is 0.1, then mean - 3×standard deviation = 0.55 < 0.7, and the threshold is adjusted up to mean - 2×standard deviation = 0.85 - 0.2 = 0.65; if the mean is 0.6 and the standard deviation is 0.05, then mean + 3×standard deviation = 0.75 > 0.7, and the threshold is adjusted down to 0.6 + 0.1 = 0.7. This rule ensures that the threshold adapts to the distribution characteristics of the effective regions and excludes isolated abnormal regions that deviate from the main distribution.

[0079] S5. Perform texture direction analysis, consistency screening, and principal component dimensionality reduction on the set of effective candidate regions, and generate a fused feature vector through feature splicing, including:

[0080] Perform gray-level co-occurrence matrix analysis on the set of effective candidate regions, and extract the energy and contrast in four main directions for each effective candidate region to generate texture directionality parameters. The gray-level co-occurrence matrix analysis is performed for each effective candidate region. The four main directions include 0 degrees, 45 degrees, 90 degrees, and 135 degrees. The direction selection is based on covering the anisotropic characteristics of the image space. The energy parameter is obtained by calculating the sum of the squares of all elements in the gray-level co-occurrence matrix, which reflects the uniformity of the texture distribution. For example, the higher the energy value, the more uniform the texture. The contrast parameter is obtained by calculating the weighted sum of the elements far from the diagonal of the matrix, which reflects the sharpness of the texture edges. For example, the higher the contrast value, the sharper the edges. Energy and contrast parameters are generated for each effective candidate region in four directions. For example, if the energy value of a certain region in the 45-degree direction is 0.12 and the contrast value is 25.3, it means that the texture uniformity in this direction is low but the edge contrast is significant.

[0081] Based on the distribution consistency of energy and contrast in the texture directionality parameters, screen the main direction that matches the mildew diffusion direction to generate the direction consistency parameter. The distribution consistency is evaluated by calculating the coefficient of variation of energy and contrast. The coefficient of variation is defined as the standard deviation divided by the mean, and the smaller the value, the higher the distribution consistency. The screening rule is: retain the main direction with a coefficient of variation less than 0.2, and the angle between this main direction and the spectral gradient direction of the mildew candidate region (determined by step S4) is less than 15 degrees. For example, if the spectral gradient direction of a certain mildew candidate region is 30 degrees, the coefficient of variation of its 45-degree direction is 0.15, and the coefficient of variation of its 0-degree direction is 0.25, then select the 45-degree direction as the direction consistency parameter because it meets the coefficient of variation threshold and the angle with the spectral gradient direction is 15 degrees.

[0082] Perform principal component analysis on the direction consistency parameters, and dynamically retain the principal components according to the correlation between the principal component variance contribution rate and the spectral attenuation direction of the mildew candidate region to generate a dimensionality-reduced feature vector. Principal component analysis converts the direction consistency parameters (such as energy and contrast) into linearly independent principal components, which are sorted according to the variance contribution rate. Retain the principal components with the cumulative variance contribution rate greater than 85%, and further screen the principal components with the cosine value of the angle with the spectral gradient direction greater than 0.8. For example, the variance contribution rates of the first three principal components are 50%, 25%, and 10% respectively, with a cumulative of 85%. If the cosine value of the angle between the first principal component and the spectral gradient direction is 0.85 and the second principal component is 0.75, then only retain the first principal component to generate the dimensionality-reduced feature vector to ensure that the features after dimensionality reduction are strongly correlated with the mildew diffusion direction.

[0083] The dimensionality-reduced feature vectors and the spectral gradient directions of the set of effective candidate regions are concatenated according to the spatial position correspondence relationship to generate fused feature vectors. The spatial position correspondence relationship is achieved by aligning pixel coordinates, and the dimensionality-reduced feature vector of each pixel is concatenated with its corresponding spectral gradient direction in sequence. For example, if the dimensionality-reduced feature vector of a certain pixel is [0.5, -0.3] and its spectral gradient direction is 30 degrees, then the fused feature vector is [0.5, -0.3, 30]. The fused feature vector contains information on texture uniformity, edge contrast change, and spectral diffusion direction. For example, the texture parameter 0.5 represents medium uniformity, -0.3 represents a decrease in edge contrast, and the 30-degree direction reflects the spread of mildew along a specific angle. The combination of the three enhances the characterization ability of the features.

[0084] S6. Input the fused feature vectors into a Bayesian probability classification model to generate the boundary confidence of the mildew candidate regions, and perform region growing on the pixel points with a boundary confidence greater than the preset boundary confidence threshold to generate a mildew region marking map, including:

[0085] Input the fused feature vectors into the Bayesian probability classification model, and calculate the boundary confidence of the mildew candidate regions based on the conditional probability distribution of the feature components. The training data of the Bayesian probability classification model consists of the fused feature vectors generated in step S5, where the ratio of the mildew region samples to the normal region samples is 6:4, and the sample labels are marked after the experts visually determine the mildew region boundaries. During the training process, the model learns the conditional probability distribution of each feature component under the mildew and normal categories. For example, the first component (texture uniformity) of the fused feature vector follows a normal distribution with a mean of 0.7 and a variance of 0.1 under the mildew category, and a normal distribution with a mean of 0.3 and a variance of 0.2 under the normal category. The calculation logic of the boundary confidence is: according to the values of the components of the input fused feature vector, calculate the posterior probability of it belonging to the mildew category according to Bayes' formula. For example, if the fused feature vector of a certain pixel is [0.5, -0.3, 30], its joint conditional probability under the mildew category is 0.6, and under the normal category is 0.1, then the boundary confidence is 0.6 / (0.6 + 0.1) = 0.857. The initial value of the preset boundary confidence threshold is set to 0.7, and this value is obtained through historical data statistics. For example, after analyzing 1000 samples, it is determined that 80% of the mildew region confidences are higher than 0.7.

[0086] According to the comparison result between the boundary confidence of the mildew candidate regions and the preset boundary confidence threshold, perform eight-neighborhood similarity region growing on the pixel points with a boundary confidence greater than the preset boundary confidence threshold, and merge the pixels that meet the similarity constraints to generate a mildew region marking map. The conditions for eight-neighborhood similarity region growing include two constraints:

[0087] Similarity of fused feature vectors: The Euclidean distance between the fused feature vectors of adjacent pixels is less than 0.5. This threshold is set according to the normalization range of the feature vectors (for example, if the feature components are normalized to [-1, 1], 0.5 corresponds to 25% of the maximum difference).

[0088] Consistency of boundary confidence: The difference in confidence between adjacent pixels is less than 0.2, preventing mismerging of high-confidence seed points (such as 0.8) and low-confidence neighborhood points (such as 0.5).

[0089] During the region growing process, the pixels to be merged need to satisfy the spatial continuity condition: Each pixel is connected to at least three neighboring pixels, which conforms to the biological characteristics of mildew hypha diffusion (the hypha network needs at least three connection points). For example, if the seed pixel coordinates are (x, y), among its eight neighbors, five pixels satisfy the similarity constraint, but only three pixels are directly connected to the seed pixel, then only these three pixels are merged. The final mildew region marking map generates all connected regions that meet the conditions. For example, a continuous region consisting of 150 pixels is marked as a mildew region.

[0090] Dynamically correct the boundary confidence threshold based on the mean confidence of the regions in the mildew region marking map and the neighborhood gradient change rate, excluding pseudo-boundary regions with discrete confidence distributions. The mean confidence is the arithmetic mean of the boundary confidences of all pixels in the region. For example, if a region contains 100 pixels and the sum of their confidences is 80, then the mean is 0.8. The neighborhood gradient change rate is calculated as the sum of the absolute values of the confidence differences of the boundary pixels in the region divided by the number of boundary pixels. For example, if there are 20 boundary pixels and the sum of their confidence differences is 3.0, then the gradient change rate is 3.0 / 20 = 0.15. The dynamic correction rule is as follows:

[0091] If the mean confidence of the region > 0.8 and the gradient change rate < 0.1 (i.e., the boundary is smooth), increase the threshold by 5% (for example, adjust from 0.7 to 0.735); if the mean confidence of the region < 0.6 and the gradient change rate > 0.2 (i.e., the boundary is rugged), decrease the threshold by 5% (for example, adjust from 0.7 to 0.665).

[0092] After the threshold adjustment, re-perform region growing to generate an updated mildew region marking map, and iterate until the number of regions is stable (for example, the change in the number of regions in two consecutive iterations < 5%).

[0093] Example 2: Figure 2 The structural schematic diagram of a rapid screening system for peanut internal mildew according to the present invention is given. A rapid screening system for peanut internal mildew includes the following modules:

[0094] Original image acquisition module: Used to acquire the original hyperspectral image of the peanut sample. The original hyperspectral image contains grayscale data of multiple bands.

[0095] Dynamic filtering adjustment module: used to preprocess the original hyperspectral image to generate an enhanced hyperspectral image, and dynamically adjust the filter kernel size according to the combined relationship between the frequency-domain energy distribution and the spatial local variance;

[0096] Gray threshold segmentation module: used to segment the mildew candidate regions from the enhanced hyperspectral image based on a preset gray threshold;

[0097] Feature screening and verification module: used to verify the consistency of spectral and spatial features of the mildew candidate regions, and screen the candidate regions that conform to the mildew diffusion law to generate a set of effective candidate regions;

[0098] Texture dimensionality reduction and fusion module: used to perform texture direction analysis, consistency screening, and principal component dimensionality reduction on the set of effective candidate regions, and generate a fused feature vector through feature splicing;

[0099] Region confidence generation module: used to input the fused feature vector into a Bayesian probability classification model to generate the boundary confidence of the mildew candidate regions, and perform region growing on the pixel points greater than the preset boundary confidence threshold to generate a mildew region marking map.

[0100] The above embodiments can be implemented in whole or in part by software, hardware, firmware, or any other combination. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product.

[0101] Those of ordinary skill in the art can realize that the modules and algorithm steps of each example described in combination with the embodiments disclosed in this article can be implemented by electronic hardware, or by a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application of the technical solution and the invention constraints. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.

[0102] In addition, the functional modules in each embodiment of this application can be integrated into one processing module, or each module can exist physically alone, or two or more modules can be integrated into one module.

[0103] The above is only the specific implementation manner of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in this application, and all should be covered by the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.

[0104] Finally, the above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A rapid screening method for peanut internal mold, characterized in that, It includes the following steps: S1. Collect the original hyperspectral image of the peanut sample, where the original hyperspectral image contains gray-scale data of multiple bands; S2. Preprocess the original hyperspectral image to generate an enhanced hyperspectral image, and dynamically adjust the filter kernel size according to the combined relationship between the frequency-domain energy distribution and the spatial local variance; S3. Segment the mildew candidate regions from the enhanced hyperspectral image based on a preset gray-scale threshold; S4. Perform consistency verification on the spectral and spatial features of the mildew candidate regions, and screen the candidate regions that conform to the mildew diffusion law to generate a set of effective candidate regions; S5. Perform texture direction analysis, consistency screening, and principal component dimensionality reduction on the set of effective candidate regions, and generate a fused feature vector through feature splicing; S6. Input the fused feature vector into the Bayesian probability classification model to generate the boundary confidence of the mildew candidate regions, and perform region growing on the pixel points with a value greater than the preset boundary confidence threshold to generate a mildew region marking map.

2. The rapid screening method for peanut endomycetes according to claim 1, characterized in that, Collect the original hyperspectral image of the peanut sample, where the original hyperspectral image contains gray-scale data of multiple bands, including: Collect the hyperspectral reflectance data of the peanut sample using a hyperspectral imaging device within a preset wavelength range; Perform step-by-step spectral calibration on the hyperspectral reflectance data to generate the original hyperspectral image containing gray-scale data of multiple bands; Dynamically adjust the spatial resolution of the hyperspectral imaging device according to the physical size of the peanut sample to ensure that the area covered by a single pixel is smaller than the preset anatomical structure threshold.

3. The rapid screening method for peanut internal mold according to claim 1, characterized in that Preprocess the original hyperspectral image to generate an enhanced hyperspectral image, and dynamically adjust the filter kernel size according to the combined relationship between the frequency-domain energy distribution and the spatial local variance, including: Perform morphological closing operation and contrast optimization on the original hyperspectral image in sequence to generate an enhanced hyperspectral image; Perform two-dimensional Fourier transform on the enhanced hyperspectral image to generate a frequency-domain energy distribution map, and calculate the local variance in blocks to generate a spatial local variance matrix; Dynamically adjust the filter kernel size of the morphological closing operation according to the combined relationship between the high-frequency energy ratio in the frequency-domain energy distribution map and the variance peak value in the spatial local variance matrix.

4. A rapid screening method for peanut internal mold according to claim 1, characterized in that, Segment the mildew candidate regions from the enhanced hyperspectral image based on a preset gray-scale threshold, including: Calculate the gray-scale mean and gray-scale standard deviation of each band in the enhanced hyperspectral image to generate a multi-band gray-scale statistical matrix; Dynamically set the preset gray-scale threshold according to the linear combination of the gray-scale mean and gray-scale standard deviation in the multi-band gray-scale statistical matrix; Perform pixel-by-pixel comparison on the enhanced hyperspectral image based on the preset gray-scale threshold, and mark the continuous pixel regions with gray-scale values exceeding the threshold as mildew candidate regions.

5. A rapid screening method for peanut internal mold according to claim 1, characterized in that, Perform consistency verification on the spectral and spatial features of the mildew candidate regions, and screen the candidate regions that conform to the mildew diffusion law to generate a set of effective candidate regions, including: Calculate the spectral gradient direction of the mildew candidate regions, where the spectral gradient direction is determined by synthesizing the gray-scale difference vectors of adjacent bands of the mildew candidate regions; Calculate the spatial morphological change rate of the mildew candidate regions; Verify the cosine value of the angle between the spectral gradient direction and the spatial morphological change rate of the mildew candidate regions, and screen the mildew candidate regions with a cosine value of the angle greater than the preset correlation threshold to generate a set of effective candidate regions; Dynamically adjust the preset correlation threshold according to the statistical distribution of the spectral gradient direction and the spatial morphology change rate of each region in the set of effective candidate regions to exclude isolated abnormal regions.

6. A rapid screening method for peanut internal mold according to claim 5, characterized in that, The gray difference vector between adjacent bands takes the average gray difference of the mildew candidate region in two adjacent bands as vector components.

7. A rapid screening method for peanut endophytic mold according to claim 5, characterized in that, The spatial morphology change rate is calculated by the linear regression slope of the aspect ratio of the minimum bounding rectangle of the mildew candidate region changing with the band number.

8. A rapid screening method for peanut internal mold according to claim 1, characterized in that, Perform texture direction analysis, consistency screening, and principal component dimensionality reduction on the set of effective candidate regions, and generate a fused feature vector through feature splicing, including: Perform gray-level co-occurrence matrix analysis on the set of effective candidate regions, and extract the energy and contrast of each effective candidate region in four main directions to generate texture directionality parameters; Based on the distribution consistency of energy and contrast in the texture directionality parameters, screen the main direction that matches the mildew diffusion direction to generate a direction consistency parameter; Perform principal component analysis on the direction consistency parameters, and dynamically retain the principal components according to the correlation between the principal component variance contribution rate and the spectral attenuation direction of the mildew candidate region to generate a dimensionality-reduced feature vector; Splice the dimensionality-reduced feature vector and the spectral gradient direction of the set of effective candidate regions according to the spatial position correspondence relationship to generate a fused feature vector.

9. A rapid screening method for peanut internal mold according to claim 1, characterized in that, Input the fused feature vector into the Bayesian probability classification model to generate the boundary confidence of the mildew candidate region, and perform region growing on the pixel points greater than the preset boundary confidence threshold to generate a mildew region marking map, including: Input the fused feature vector into the Bayesian probability classification model, and calculate the boundary confidence of the mildew candidate region based on the conditional probability distribution of the feature components; According to the comparison result between the boundary confidence of the mildew candidate region and the preset boundary confidence threshold, perform eight-neighborhood similarity region growing on the pixel points greater than the preset boundary confidence threshold, and merge the pixels that meet the similarity constraints to generate a mildew region marking map; Dynamically correct the boundary confidence threshold based on the mean confidence of the regions in the mildew region marking map and the neighborhood gradient change rate, and exclude the pseudo-boundary regions with discrete confidence distributions.

10. A rapid screening system for peanut internal mold, which is used to implement the rapid screening method for peanut internal mold described in any one of claims 1-9, and is characterized in that, Including the following modules: Original image acquisition module: used to acquire the original hyperspectral image of the peanut sample, and the original hyperspectral image contains gray data of multiple bands; Dynamic filtering adjustment module: used to preprocess the original hyperspectral image to generate an enhanced hyperspectral image, and dynamically adjust the filter kernel size according to the combined relationship between the frequency domain energy distribution and the spatial local variance; Gray threshold segmentation module: used to segment the mildew candidate region from the enhanced hyperspectral image based on the preset gray threshold; Feature screening and verification module: used to perform consistency verification on the spectral and spatial features of the mildew candidate region, and screen the candidate regions that conform to the mildew diffusion law to generate a set of effective candidate regions; Texture dimensionality reduction and fusion module: used to perform texture direction analysis, consistency screening, and principal component dimensionality reduction on the set of effective candidate regions, and generate a fused feature vector through feature splicing; Region confidence generation module: used to input the fused feature vector into the Bayesian probability classification model to generate the boundary confidence of the mildew candidate region, and perform region growing on the pixel points greater than the preset boundary confidence threshold to generate a mildew region marking map.

Citation Information

Patent Citations

  • Method for identifying moldy peanuts by using near-infrared high-spectrum image

    CN104598886A

  • Hyperspectral image-based tissue sample analysis method and system

    CN117197137A