Method and system for rapidly screening endomycetes in peanuts

By pre-processing and feature extraction of peanut samples, combined with Bayesian probability classification model, the problem of difficult to identify the boundaries of peanut mildew areas in the prior art is solved, and higher detection accuracy and anti-interference ability are achieved.

CN119992539AActive Publication Date: 2025-05-13SISHUI JINCHUAN PEANUT FOOD CO LTD

Patent Information

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

AI Technical Summary

Technical Problem

The prior art is difficult to accurately identify the transitional boundary of peanut moldy areas, especially in the early stages of moldy or internal mycelium diffusion, resulting in low boundary confidence in the detection results and significantly increasing the risk of false detection and missed detection.

Method used

By collecting the original hyperspectral image of peanut samples, pre-processing is performed to generate enhanced hyperspectral images, dynamically adjusting the filter core size, segmenting the mold candidate areas based on grayscale thresholds, performing consistency verification of spectral and spatial characteristics, performing texture direction analysis and principal component dimensionality reduction, generating fusion feature vectors, and inputting Bayesian probability classification model to generate boundary confidence of moldy areas.

Benefits of technology

It significantly improves the accuracy and anti-interference ability of border detection in mildew areas, reduces the risks of missed detection and missed detection, and improves the credibility of detection results, especially suitable for detection in the early stages of mildew and internal diffusion areas.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119992539A_ABST
    Figure CN119992539A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a system for rapidly screening peanut endophytic mildew, particularly relates to the technical field of nondestructive testing of agricultural products, and is used for solving the problems of false detection and missing detection caused by low contrast and gradient boundary in an initial mildew stage and an internal diffusion sample in an existing detection method. Based on a hyperspectral imaging technology, a filtering kernel size is dynamically adjusted through conjoint analysis of frequency domain energy distribution and spatial local variance, and detail features of a gradient boundary in an image are enhanced; verifying and screening high-confidence candidate regions by adopting spectrum and spatial feature consistency, analyzing and extracting principal component features representing a mildew diffusion trend in combination with a texture direction, and dynamically splicing the principal component features with a spectrum gradient direction to construct a fusion feature vector; quantizing boundary confidence through a Bayesian probability classification model, combining with a neighborhood similarity constraint region growing algorithm to generate a mildewed mark graph with continuous space and consistent features, and introducing a dynamic threshold correction mechanism to adaptively optimize a segmentation standard; and the detection precision and the anti-interference capability of the fuzzy boundary 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 nondestructive detection of agricultural products, and more specifically, to a method and system for rapid screening of internal mold in peanuts. Background Art

[0002] Peanut mold detection usually relies on image processing algorithms combined with spectral analysis to achieve the identification and segmentation of moldy areas. For example, detection methods based on ultraviolet fluorescence images or hyperspectral imaging distinguish normal from moldy areas through grayscale mapping, cluster analysis and other steps. They mainly rely on the spectral or morphological differences between moldy and normal tissues in the image. For peanut samples with severe mold and clear boundaries, conventional algorithms (such as threshold segmentation and support vector machine classification) can achieve higher detection accuracy. However, for samples in the early stages of mold or with internal hyphae diffusion, the transition boundary between the moldy area and the normal tissue often presents fuzzy features such as low contrast and gradient density, which makes it difficult to achieve effective segmentation through simple image enhancement or spectral feature screening.

[0003] The limitations of existing technologies are: due to the spectral gradient characteristics between moldy areas and normal tissues (such as the gentle change in reflectivity in the near-infrared band) and the spatial morphological ambiguity (such as the density gradient caused by hyphae diffusion), it is difficult to accurately define the transition boundary, which directly leads to low boundary confidence in the segmentation results and a significantly increased risk of false detection and missed detection. Especially in peanut samples in the early stages of mold or with complex anatomical structures, the credibility of the test results is difficult to meet the needs of high-precision screening. Summary of the invention

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

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

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

[0007] S1, collect the original hyperspectral image of the peanut sample, the original hyperspectral image contains grayscale data of multiple bands;

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

[0009] S3, segmenting the moldy candidate area from the enhanced hyperspectral image based on a preset grayscale threshold;

[0010] S4, verifying the consistency of spectral and spatial characteristics of the candidate mildew areas, screening the candidate areas that conform to the mildew diffusion law to generate a set of valid candidate areas;

[0011] S5, performing texture direction analysis, consistency screening and principal component dimension reduction on the valid candidate region set, and generating a fused feature vector by feature concatenation;

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

[0013] In a preferred embodiment, an original hyperspectral image of a peanut sample is collected, and the original hyperspectral image contains grayscale data of multiple bands, including:

[0014] Hyperspectral imaging equipment is used to collect hyperspectral reflectance data of peanut samples within a preset wavelength range;

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

[0016] The spatial resolution of the hyperspectral imaging device was dynamically adjusted according to the physical size of the peanut sample to ensure that the area covered by a single pixel was smaller than a preset anatomical structure threshold.

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

[0018] The morphological closing operation and contrast optimization are sequentially performed on the original hyperspectral image 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] According to the combined relationship between the proportion of high-frequency energy in the frequency domain energy distribution diagram and the variance peak in the spatial local variance matrix, the filter kernel size of the morphological closing operation is dynamically adjusted.

[0021] In a preferred embodiment, segmenting the moldy candidate area from the enhanced hyperspectral image based on a preset grayscale threshold includes:

[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 a preset grayscale threshold according to a linear combination of grayscale mean and grayscale standard deviation in a multi-band grayscale statistical matrix;

[0024] The enhanced hyperspectral image is compared pixel by pixel based on the preset grayscale threshold, and the continuous pixel areas with grayscale values ​​exceeding the threshold are marked as moldy candidate areas.

[0025] In a preferred embodiment, the consistency of spectral and spatial features of the mold candidate area is verified, and the candidate area that conforms to the mold diffusion law is screened to generate a valid candidate area set, including:

[0026] Calculate the spectral gradient direction of the mold candidate area, where the spectral gradient direction is determined by synthesizing the grayscale difference vectors of adjacent bands of the mold candidate area;

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

[0028] Verify the cosine value of the angle between the spectral gradient direction and the spatial morphological change rate of the mold candidate area, and select the mold candidate areas whose cosine value of the angle is greater than a preset correlation threshold to generate a set of valid candidate areas;

[0029] According to the statistical distribution of the spectral gradient direction and spatial morphological change rate of each area in the valid candidate area set, the preset correlation threshold is dynamically adjusted to exclude isolated abnormal areas.

[0030] In a preferred embodiment, the adjacent band grayscale difference vector has the average grayscale difference of the moldy candidate area in two adjacent bands as a vector component.

[0031] In a preferred embodiment, the spatial morphology change rate is calculated by the linear regression slope of the aspect ratio of the minimum circumscribed rectangle of the moldy candidate area versus the band number.

[0032] In a preferred embodiment, texture direction analysis, consistency screening and principal component dimension reduction are performed on the valid candidate region set, and a fused feature vector is generated by feature concatenation, including:

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

[0034] Based on the distribution consistency of energy and contrast in texture directional parameters, the main direction matching the mildew diffusion direction is selected to generate directional consistency parameters;

[0035] The principal component analysis is performed on the directional consistency parameters, and the principal component is dynamically retained to generate a dimension reduction feature vector according to the correlation between the principal component variance contribution rate and the spectral attenuation direction of the moldy candidate area;

[0036] The dimension-reduced feature vector and the spectral gradient direction of the valid candidate region set are concatenated according to the spatial position correspondence 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 a boundary confidence of a candidate mildew region, and region growing is performed on pixels greater than a preset boundary confidence threshold to generate a mildew region marker map, including:

[0038] The fused feature vector is input into the Bayesian probability classification model, and the boundary confidence of the moldy candidate area is calculated based on the conditional probability distribution of the feature components;

[0039] According to the comparison result of the boundary confidence of the moldy candidate area and the preset boundary confidence threshold, eight-neighborhood similarity region growing is performed on the pixel points greater than the preset boundary confidence threshold, and the pixels satisfying the similarity constraint are merged to generate a moldy area marking map;

[0040] The boundary confidence threshold is dynamically corrected based on the confidence mean value of the region in the moldy area marking map and the neighborhood gradient change rate to exclude pseudo-boundary areas with discrete confidence distribution.

[0041] In another aspect, the present invention provides a peanut mold rapid screening system, comprising the following modules:

[0042] Original image acquisition module: used to collect original hyperspectral images of peanut samples. The original hyperspectral images contain grayscale data of multiple bands.

[0043] Dynamic filter 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 frequency domain energy distribution and spatial local variance;

[0044] Grayscale threshold segmentation module: used to segment the mold candidate area from the enhanced hyperspectral image based on the preset grayscale threshold;

[0045] Feature screening and verification module: used to verify the consistency of spectral and spatial features of the candidate mildew area, and screen the candidate areas that meet the mildew diffusion law to generate a set of valid candidate areas;

[0046] Texture dimension reduction and fusion module: used to perform texture direction analysis, consistency screening and principal component dimension reduction on the valid candidate area set, and generate a fused feature vector by 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 moldy candidate area, and perform region growth on the pixel points greater than the preset boundary confidence threshold to generate the moldy area marking map.

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

[0049] 1. The accuracy and anti-interference ability of the boundary detection of the moldy area are significantly improved by dynamically adjusting the filter kernel size and multi-dimensional feature fusion mechanism. In view of the low contrast and gradient density characteristics of the early stage of moldy and internal diffusion areas, a combined analysis strategy of frequency domain energy distribution and spatial local variance is adopted to adaptively optimize the filtering parameters in the preprocessing process, effectively suppress noise interference while retaining weak signal characteristics, and enhance the recognizability of the gradient boundary in the image. Combined with the consistency verification mechanism of spectral and spatial features, a subset that conforms to the directional law of moldy diffusion is selected from the candidate area to avoid mis-segmentation caused by local noise or morphological ambiguity, ensuring that subsequent analysis focuses on the target area with high confidence. Through texture direction analysis and principal component dimensionality reduction, the key texture features that characterize the trend of moldy diffusion are extracted, and dynamically spliced ​​with the spectral gradient direction to generate a fusion feature vector, providing a multi-dimensional joint judgment for boundary determination.

[0050] 2. Based on the Bayesian probability classification and regional growth collaborative optimization strategy, the processing ability of fuzzy boundaries is further enhanced; by integrating the probability distribution modeling of feature vectors, the confidence of the moldy area boundary is quantified, and the neighborhood similarity constraint is combined to drive the regional growth process, so that the boundary marking results achieve a balance between spatial continuity and feature consistency; the dynamic threshold correction mechanism iteratively adjusts the segmentation standard according to the mean regional confidence and the gradient change rate, adaptively adapting to the detection needs of different mold degrees and sample structures, and avoiding the missed detection of weak diffusion areas or complex boundaries by fixed thresholds; while reducing the false detection rate, it can accurately capture the gradual transition characteristics of mold diffusion, which is especially suitable for the detection of early moldy samples with internal hyphae penetration and blurred boundaries, significantly improving the reliability and robustness of the screening results. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] Figure 1 This is a flow chart of a method for rapid screening of mold in peanuts according to the present invention;

[0052] Figure 2 The present invention is a schematic structural diagram of a system for rapidly screening mold in peanuts. DETAILED DESCRIPTION

[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0054] Embodiment 1: Figure 1 The present invention provides a method for rapid screening of mold in peanuts, which comprises the following steps:

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

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

[0057] S3, segmenting the moldy candidate area from the enhanced hyperspectral image based on a preset grayscale threshold;

[0058] S4, verifying the consistency of spectral and spatial characteristics of the candidate mildew areas, screening the candidate areas that conform to the mildew diffusion law to generate a set of valid candidate areas;

[0059] S5, performing texture direction analysis, consistency screening and principal component dimensionality reduction on the valid candidate region set, and generating a fused feature vector by feature concatenation;

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

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

[0062] A hyperspectral imaging device is used to collect hyperspectral reflectance data of peanut samples within a preset wavelength range. The preset wavelength range is set according to the spectral absorption characteristics of the moldy area, specifically including the visible light band and the near-infrared band, wherein the visible light band ranges from 400 nanometers to 700 nanometers, and the near-infrared band ranges from 900 nanometers to 1700 nanometers. 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 adopts a halogen lamp, whose spectral output covers the preset wavelength range. The illumination intensity is adjusted in real time according to the reflectivity of the sample surface. For example, when the reflectivity of the sample surface is detected to be lower than 20%, the light source power is adjusted to 150 watts; when the reflectivity is higher than 80%, the light source power is adjusted to 50 watts. The spectral resolution of the hyperspectral imaging device is set to 10 nanometers, and the initial value of the spatial resolution is set to 0.1 mm × 0.1 mm per pixel, ensuring that the single pixel coverage area can analyze the microstructure of the embryo and the moldy area inside the peanut.

[0063] The hyperspectral reflectance data was spectrally calibrated step by step to generate an original hyperspectral image containing grayscale data of multiple bands. The spectral calibration process includes the following steps: first, a barium sulfate standard white plate with a reflectance of 98% was placed on the stage, and its hyperspectral reflectance data was collected as a calibration benchmark; second, the original reflectance data of the peanut sample was compared with the benchmark data of the standard white plate band by band, and the gain coefficient and offset of each band were calculated. The gain coefficient was the ratio of the white plate reflectance to the original reflectance of the sample, and the offset was the white plate reflectance minus the original reflectance of the sample; finally, the calibrated reflectance data was converted into grayscale data. The conversion method was to normalize the calibrated reflectance to the range of 0 to 1 and then multiply it by 255 to obtain a grayscale value of 0 to 255.

[0064] The spatial resolution of the hyperspectral imaging device is dynamically adjusted according to the physical size of the peanut sample. The physical size is measured from the original hyperspectral image by an image processing algorithm. Specifically, the maximum circumscribed rectangle of the peanut sample is extracted, the number of pixels on its long side and the number of pixels on its short side are calculated, and the actual length and width of the sample are calculated based on the actual size of a single pixel of 0.1 mm. If the actual length of the sample is greater than 20 mm, the spatial resolution is adjusted to 0.05 mm × 0.05 mm per pixel; if the actual length of the sample is less than or equal to 20 mm, the initial resolution is maintained. 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 must be less than 0.5 mm × 0.5 mm.

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

[0066] The original hyperspectral image is sequentially subjected to morphological closing operation and contrast optimization to generate an enhanced hyperspectral image. The morphological closing operation uses a circular structure element, and the diameter of the structure 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 structure element is set to 3 pixels to fill tiny holes; when the surface is relatively smooth, the diameter of the structure element is set to 5 pixels to suppress particle noise. The parameters of contrast optimization are dynamically adjusted according to the overall grayscale distribution of the image. For example, the grayscale range is stretched by histogram equalization to enhance the grayscale difference in low-contrast areas. The generation process of the enhanced hyperspectral image is as follows: first, a morphological closing operation is performed on each band of the original hyperspectral image, and then the contrast of the image after the closing operation is optimized to output the enhanced hyperspectral image.

[0067] The enhanced hyperspectral image is subjected to a two-dimensional Fourier transform to generate a frequency domain energy distribution map, and the local variance is calculated in blocks to generate a spatial local variance matrix. The two-dimensional Fourier transform is performed for each band of the enhanced hyperspectral image to generate a 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 total energy of the high-frequency area (for example, the area with a frequency higher than the inverse 1 / 10 of the image width) to the total energy of the entire frequency band. When calculating the local variance in blocks, the enhanced hyperspectral image is divided into multiple sub-blocks, and the sub-block size is set according to the image resolution. For example, each sub-block contains an 8 pixel × 8 pixel area. The variance value of the pixel grayscale in each sub-block is calculated and arranged according to the spatial position to generate a spatial local variance matrix.

[0068] The filter kernel size of the morphological closing operation is dynamically adjusted according to the combined relationship between the high-frequency energy ratio in the frequency domain energy distribution diagram and the variance peak in the spatial local variance matrix. The high-frequency energy ratio is used to evaluate the intensity of high-frequency noise. For example, when the high-frequency energy ratio is greater than 60%, it is determined to be dominated by salt and pepper noise; the variance peak in the spatial local variance matrix is ​​used to evaluate the non-uniformity of the noise spatial distribution. For example, when the variance peak is greater than the preset threshold, it is determined to be dominated by Gaussian noise. The filter kernel size is adjusted according to the combination of noise types: if the high-frequency energy ratio is greater than 60% and the variance peak is greater than the threshold, the filter kernel size of the morphological closing operation is adjusted to 3 pixels × 3 pixels; if only the high-frequency energy ratio is greater than 60%, the filter kernel size is adjusted to 5 pixels × 5 pixels; if only the variance peak is greater than the threshold, the filter kernel size remains at the default value of 7 pixels × 7 pixels.

[0069] S3, segmenting the mold candidate area 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 up the grayscale values ​​of all pixels in a certain band and divide it by the total number of pixels. For example, the grayscale mean of band k is the arithmetic mean of the grayscale values ​​of all pixels in the band. The grayscale standard deviation reflects the degree of discreteness of the pixel grayscale value. The calculation method is: first calculate the sum of the squares of the difference between the grayscale value of each pixel and the mean, and then divide it 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 value of the band from the mean. The rows of the multi-band grayscale statistical matrix correspond to the band numbers, and the columns store the grayscale mean and standard deviation of each band in turn. For example, the first row and the first column of the matrix store the grayscale mean of band 1, and the first row and the second column store the grayscale standard deviation of band 1. This can be deduced to form a complete statistical feature table. The logic of constructing this matrix is ​​based on statistical principles. The mean reflects the overall brightness, and the standard deviation quantifies local fluctuations, providing a data basis for subsequent dynamic adjustment of the threshold.

[0071] The preset grayscale threshold is dynamically set according to the linear combination of the grayscale mean and grayscale standard deviation in the multi-band grayscale statistical matrix. The linear combination proportional coefficient is positively correlated with the spectral absorption characteristics of the moldy area, and the spectral absorption characteristics are characterized by the degree of reduction in the reflectivity of the moldy material in a specific band (such as the near-infrared band). For example, in the near-infrared band range of 900 nanometers to 1700 nanometers, the reflectivity of the moldy area is 30% to 50% lower than that of normal tissue due to the absorption of light by hyphae. The proportional coefficient is adjusted according to the reflectivity difference: if the reflectivity difference in a certain band is 40%, the proportional 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 grayscale threshold is: threshold = grayscale mean + proportional coefficient × grayscale standard deviation. For example, if the grayscale mean of a near-infrared band is 120, the standard deviation is 18, and the proportional coefficient is 1.5, then the threshold is 120+1.5×18=147. The technical logic of this rule is: the mean provides the benchmark brightness, the standard deviation reflects the noise intensity, and the proportional coefficient dynamically adjusts the threshold tightness according to the mildew absorbance intensity. For example, a high proportional coefficient (1.5) increases the threshold in the strong absorption band to reduce false detection.

[0072] The enhanced hyperspectral image is compared pixel by pixel based on the preset grayscale threshold, and the continuous pixel area with grayscale value exceeding the threshold is marked as the moldy candidate area. The pixel-by-pixel comparison process is as follows: for the enhanced hyperspectral image of each band, the grayscale value of each pixel is traversed in turn. If its value is greater than the preset threshold of the band, it is marked as a candidate point. The marked candidate points are regionally grown, and the adjacent pixels are merged to form a continuous area. The adjacent judgment condition is: the pixel has adjacent candidate points in at least three directions in the eight neighborhood directions (up, down, left, right and four diagonal directions). The continuous area must meet the minimum area constraint, for example, the number of pixels covered by the area must be greater than 10×10 pixels to exclude the misjudgment of isolated noise points. The minimum area is set based on 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 is conservatively set to 10×10 pixels to accommodate the resolution differences of different devices. Finally, all continuous regions that meet the area constraint constitute a set of candidate moldy regions. For example, a continuous region of 20×20 pixels is marked as a candidate region, while isolated 5×5 pixel regions are filtered out.

[0073] S4. Verify the consistency of spectral and spatial characteristics of the candidate mildew areas, and screen the candidate areas that meet the mildew diffusion law to generate a set of valid candidate areas, including:

[0074] Calculate the spectral gradient direction of the mold candidate area. The spectral gradient direction is determined by synthesizing the grayscale difference vectors of the adjacent bands of the mold candidate area. In specific implementation, for each mold candidate area, calculate the average grayscale difference in the two adjacent bands, for example, the grayscale difference between band k and band k+1 is the average grayscale of the area in band k minus the average grayscale of band k+1. The grayscale difference of adjacent bands is used as a vector component, for example, the grayscale difference from band k to k+1 is the vector x component, and the grayscale difference from band k+1 to k+2 is the vector y component. After synthesizing the two-dimensional vector, calculate its direction angle, which ranges from 0 degrees to 360 degrees, indicating the spectral gradient direction. For example, if the grayscale 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), the direction angle is 33.7 degrees, and pointing to the third quadrant indicates that the spectral grayscale decreases as the band increases.

[0075] Among them, k represents the current band number of the hyperspectral image, for example, k is the near-infrared band of 900 nanometers, and k+1 is 910 nanometers; the vector x component is the average grayscale difference between the moldy candidate area in bands k and k+1, which is used to characterize the change of the spectral gradient in adjacent bands; the vector y component is the average grayscale difference between the moldy candidate area in bands k+1 and k+2, which is used to characterize the change of the spectral gradient in subsequent adjacent bands.

[0076] Calculate the spatial morphological change rate of the moldy candidate area. The spatial morphological change rate is calculated by the linear regression slope of the aspect ratio of the minimum circumscribed rectangle of the moldy candidate area with the band number. In the specific implementation, for each moldy candidate area, extract its minimum circumscribed rectangle aspect ratio in each band, for example, the aspect ratio of 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, perform linear regression analysis, and get the slope value. The larger the absolute value of the slope, the higher the rate at which the aspect ratio changes with the band. For example, the aspect ratio sequence of a moldy candidate area in bands k to k+5 is [1.2, 1.5, 1.8, 2.1, 2.4], and the linear regression slope is 0.3, which means that the aspect ratio increases by 0.3 with each additional band, reflecting that the direction of mold diffusion has significant anisotropy.

[0077] Verify the cosine value of the angle between the spectral gradient direction and the spatial morphological change rate of the mold candidate area. 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 two vectors. For example, 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 modulus product is about 18.75, and the cosine value of the angle is -18 / 18.75≈-0.96. Filter the mold candidate areas with an angle cosine value greater than the preset correlation threshold (for example, 0.7) to generate a valid candidate area set. A negative value indicates that the spectral gradient direction is opposite to the spatial morphological change direction, but it is still considered to be strongly correlated when the absolute value is greater than the threshold. For example, the direction of spectral attenuation caused by hyphae diffusion is opposite to the direction of morphological expansion.

[0078] According to the statistical distribution of the spectral gradient direction and spatial morphological change rate of each area in the valid candidate area set, the preset correlation threshold is dynamically adjusted to exclude isolated abnormal areas. The statistical distribution is calculated by calculating the mean and standard deviation of the cosine value of the angle in the valid candidate area set, for example, the mean is 0.85 and the standard deviation is 0.1. The dynamic adjustment rule is: if the mean and standard deviation satisfy the mean - 3 × standard deviation > current threshold, the threshold is adjusted up to mean - 2 × standard deviation; if the mean + 3 × standard deviation < current threshold, the threshold is adjusted down to mean + 2 × standard deviation. For example, the initial threshold is set to 0.7. If the mean of the cosine value of the angle in the effective area is 0.85 and the standard deviation is 0.1, then the mean - 3 × standard deviation = 0.55 < 0.7, and the threshold is adjusted up to the mean - 2 × standard deviation = 0.85 - 0.2 = 0.65; if the mean is 0.6 and the standard deviation is 0.05, then the 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 is adaptive to the distribution characteristics of the effective area and excludes isolated abnormal areas that deviate from the main distribution.

[0079] S5. Perform texture direction analysis, consistency screening and principal component dimension reduction on the valid candidate region set, and generate a fused feature vector by feature concatenation, including:

[0080] Gray-level co-occurrence matrix analysis is performed on the set of valid candidate regions, and the energy and contrast of each valid candidate region in four main directions are extracted to generate texture directional parameters. Gray-level co-occurrence matrix analysis is performed on each valid 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, reflecting the uniformity of 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 away from the matrix diagonal, reflecting the clarity of the texture edge. For example, the higher the contrast value, the sharper the edge. Each valid candidate region generates energy and contrast parameters in four directions. For example, the energy value of a region in the 45-degree direction is 0.12, and the contrast value is 25.3, indicating 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 directional parameters, the main direction that matches the direction of mildew diffusion is screened to generate a directional 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. 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 the main direction and the spectral gradient direction of the mildew candidate area (determined by step S4) is less than 15 degrees. For example, if the spectral gradient direction of a mildew candidate area is 30 degrees, the coefficient of variation of the 45-degree direction is 0.15, and the coefficient of variation of the 0-degree direction is 0.25, then the 45-degree direction is selected as the directional consistency parameter because it meets the coefficient of variation threshold and the angle with the spectral gradient direction is 15 degrees.

[0082] The principal component analysis is performed on the directional consistency parameters, and the principal components are dynamically retained to generate the reduced dimension feature vector according to the correlation between the principal component variance contribution rate and the spectral attenuation direction of the mold candidate area. The principal component analysis converts the directional consistency parameters (such as energy and contrast) into linearly independent principal components and sorts them by variance contribution rate. The principal components with a cumulative variance contribution rate greater than 85% are retained, and the principal components with a cosine value greater than 0.8 with the spectral gradient direction are further screened. For example, the variance contribution rates of the first three principal components are 50%, 25%, and 10%, respectively, and the cumulative value is 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 the first principal component is retained to generate the reduced dimension feature vector to ensure that the features after dimensionality reduction are strongly correlated with the direction of mold diffusion.

[0083] The dimensionality reduction feature vector and the spectral gradient direction of the valid candidate region set are spliced ​​according to the spatial position correspondence to generate a fused feature vector. The spatial position correspondence is achieved by aligning the pixel coordinates, and the dimensionality reduction feature vector of each pixel is spliced ​​with its corresponding spectral gradient direction in sequence. For example, the dimensionality reduction feature vector of a 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 also contains information about texture uniformity, edge contrast changes, and spectral diffusion direction. For example, a texture parameter of 0.5 indicates moderate uniformity, -0.3 indicates decreased edge contrast, and the 30-degree direction reflects that the mold spreads along a specific angle. The three are combined to enhance the representation ability of the feature.

[0084] S6. Inputting the fused feature vector into the Bayesian probability classification model to generate the boundary confidence of the moldy candidate area, performing region growing on the pixel points greater than the preset boundary confidence threshold to generate a moldy area marking map, including:

[0085] The fused feature vector is input into the Bayesian probability classification model, and the boundary confidence of the moldy candidate area is calculated based on the conditional probability distribution of the feature components. The training data of the Bayesian probability classification model is composed of the fused feature vector generated in step S5, in which the ratio of moldy area samples to normal area samples is 6:4, and the sample labels are annotated after the expert visually determines the boundary of the moldy area. During the training process, the model learns the conditional probability distribution of each feature component under the moldy and normal categories. For example, the first component (texture uniformity) of the fused feature vector obeys a normal distribution with a mean of 0.7 and a variance of 0.1 in the moldy category, and obeys a normal distribution with a mean of 0.3 and a variance of 0.2 in the normal category. The calculation logic of the boundary confidence is: according to the values ​​of each component of the input fused feature vector, the posterior probability of it belonging to the moldy category is calculated according to the Bayesian formula. For example, the fusion feature vector of a pixel is [0.5, -0.3, 30], and its joint conditional probability in the moldy category is 0.6, and in 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, which is obtained through historical data statistics. For example, after analyzing 1,000 samples, it is determined that 80% of the moldy areas have a confidence level higher than 0.7.

[0086] According to the comparison result of the boundary confidence of the moldy candidate area and the preset boundary confidence threshold, eight-neighborhood similarity region growing is performed on the pixels with a confidence greater than the preset boundary confidence threshold, and the pixels that meet the similarity constraint are merged to generate the moldy area labeling map. The conditions for eight-neighborhood similarity region growing include two constraints:

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

[0088] Boundary confidence consistency: The confidence difference between adjacent pixels is less than 0.2 to prevent high-confidence seed points (such as 0.8) from being mistakenly merged with low-confidence neighborhood points (such as 0.5).

[0089] During the region growing process, the merged pixels must meet the spatial continuity condition: each pixel is connected to at least three neighboring pixels, which is consistent with the biological characteristics of moldy hyphae diffusion (the hyphae network requires at least three connection points). For example, the seed pixel coordinates are (x, y), and five pixels in its eight neighborhoods meet the similarity constraint, but only three pixels are directly connected to the seed pixel, so only these three pixels are merged. The moldy region labeling map eventually generates all connected regions that meet the conditions, for example, a continuous region consisting of 150 pixels is marked as a moldy region.

[0090] The boundary confidence threshold is dynamically corrected based on the confidence mean of the region in the moldy region marking map and the neighborhood gradient change rate to exclude pseudo-boundary regions with discrete confidence distribution. The confidence mean is the arithmetic mean of the confidence of all pixel boundaries in the region. For example, if a region contains 100 pixels and its total confidence is 80, 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 region boundary pixels divided by the number of boundary pixels. For example, if there are 20 pixels on the boundary and the total confidence difference is 3.0, the gradient change rate is 3.0 / 20=0.15. The dynamic correction rules are:

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

[0092] After the threshold is adjusted, the region growing is re-executed to generate an updated moldy region marking map, and the process is iterated until the number of regions is stable (for example, the change in the number of regions is less than 5% for two consecutive iterations).

[0093] Embodiment 2: Figure 2 A schematic diagram of the structure of a peanut mold rapid screening system of the present invention is provided, and the peanut mold rapid screening system comprises the following modules:

[0094] Original image acquisition module: used to collect original hyperspectral images of peanut samples. The original hyperspectral images contain grayscale data of multiple bands.

[0095] Dynamic filter 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 frequency domain energy distribution and spatial local variance;

[0096] Grayscale threshold segmentation module: used to segment the mold candidate area from the enhanced hyperspectral image based on the preset grayscale threshold;

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

[0098] Texture dimension reduction and fusion module: used to perform texture direction analysis, consistency screening and principal component dimension reduction on the valid candidate area set, and generate a fused feature vector by feature splicing;

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

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

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

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

[0103] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0104] Finally: The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for rapid screening of mold in peanuts, characterized in that: The steps include: S1, collect the original hyperspectral image of the peanut sample, the original hyperspectral image contains grayscale data of multiple bands; S2, preprocessing the original hyperspectral image to generate an enhanced hyperspectral image, and dynamically adjusting the filter kernel size according to the combined relationship between frequency domain energy distribution and spatial local variance; S3, segmenting the moldy candidate area from the enhanced hyperspectral image based on a preset grayscale threshold; S4, verifying the consistency of spectral and spatial characteristics of the candidate mildew areas, screening the candidate areas that conform to the mildew diffusion law to generate a set of valid candidate areas; S5, performing texture direction analysis, consistency screening and principal component dimension reduction on the valid candidate region set, and generating a fused feature vector by feature concatenation; S6. Input the fused feature vector into the Bayesian probability classification model to generate the boundary confidence of the moldy candidate area, and perform region growing on the pixel points greater than the preset boundary confidence threshold to generate a moldy area marking map.

2. A method for rapid screening of mold in peanuts according to claim 1, characterized in that: Collect the original hyperspectral image of the peanut sample. The original hyperspectral image contains grayscale data of multiple bands, including: Hyperspectral imaging equipment is used to collect hyperspectral reflectance data of peanut samples within a preset wavelength range; Performing step-by-step spectral calibration on the hyperspectral reflectance data to generate an original hyperspectral image containing grayscale data of multiple bands; The spatial resolution of the hyperspectral imaging device was dynamically adjusted according to the physical size of the peanut sample to ensure that the area covered by a single pixel was smaller than a preset anatomical structure threshold.

3. A method for rapid screening of mold in peanuts according to claim 1, characterized in that: The original hyperspectral image is preprocessed to generate an enhanced hyperspectral image, and the filter kernel size is dynamically adjusted according to the combined relationship between the frequency domain energy distribution and the spatial local variance, including: The morphological closing operation and contrast optimization are sequentially performed on the original hyperspectral image 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; According to the combined relationship between the proportion of high-frequency energy in the frequency domain energy distribution diagram and the variance peak in the spatial local variance matrix, the filter kernel size of the morphological closing operation is dynamically adjusted.

4. A method for rapid screening of mold in peanuts according to claim 1, characterized in that: Segmentation of mold candidate areas from enhanced hyperspectral images based on preset grayscale thresholds includes: Calculate the grayscale mean and grayscale standard deviation of each band in the enhanced hyperspectral image to generate a multi-band grayscale statistical matrix; Dynamically set a preset grayscale threshold according to a linear combination of grayscale mean and grayscale standard deviation in a multi-band grayscale statistical matrix; The enhanced hyperspectral image is compared pixel by pixel based on the preset grayscale threshold, and the continuous pixel areas with grayscale values ​​exceeding the threshold are marked as moldy candidate areas.

5. A method for rapid screening of mold in peanuts according to claim 1, characterized in that: Verify the consistency of spectral and spatial characteristics of the candidate mildew areas, and screen the candidate areas that meet the mildew diffusion law to generate a set of valid candidate areas, including: Calculate the spectral gradient direction of the mold candidate area, where the spectral gradient direction is determined by synthesizing the grayscale difference vectors of adjacent bands of the mold candidate area; Calculate the spatial morphological change rate of the candidate mildew area; Verify the cosine value of the angle between the spectral gradient direction and the spatial morphological change rate of the mold candidate area, and select the mold candidate areas whose cosine value of the angle is greater than a preset correlation threshold to generate a set of valid candidate areas; According to the statistical distribution of the spectral gradient direction and spatial morphological change rate of each area in the valid candidate area set, the preset correlation threshold is dynamically adjusted to exclude isolated abnormal areas.

6. A method for rapid screening of mold in peanuts according to claim 5, characterized in that: The grayscale difference vector of adjacent bands is composed of the average grayscale difference of the moldy candidate area in two adjacent bands as a vector component.

7. A method for rapid screening of mold in peanuts according to claim 5, characterized in that: The spatial morphological change rate was calculated by the linear regression slope of the aspect ratio of the minimum enclosing rectangle of the moldy candidate area versus the band number.

8. A method for rapid screening of mold in peanuts according to claim 1, characterized in that: Perform texture direction analysis, consistency screening and principal component dimension reduction on the valid candidate region set, and generate a fused feature vector by feature concatenation, including: Perform gray-level co-occurrence matrix analysis on the valid candidate region set, extract the energy and contrast of each valid candidate region in four main directions to generate texture directional parameters; Based on the distribution consistency of energy and contrast in texture directional parameters, the main direction matching the mildew diffusion direction is selected to generate directional consistency parameters; The principal component analysis is performed on the directional consistency parameters, and the principal component is dynamically retained to generate a dimension reduction feature vector according to the correlation between the principal component variance contribution rate and the spectral attenuation direction of the moldy candidate area; The dimension-reduced feature vector and the spectral gradient direction of the valid candidate region set are concatenated according to the spatial position correspondence to generate a fused feature vector.

9. A method for rapid screening of mold in peanuts according to claim 1, characterized in that: The fused feature vector is input into the Bayesian probability classification model to generate the boundary confidence of the mold candidate area, and the pixel points greater than the preset boundary confidence threshold are subjected to region growing to generate the mold area marking map, including: The fused feature vector is input into the Bayesian probability classification model, and the boundary confidence of the moldy candidate area is calculated based on the conditional probability distribution of the feature components; According to the comparison result of the boundary confidence of the moldy candidate area and the preset boundary confidence threshold, eight-neighborhood similarity region growing is performed on the pixel points greater than the preset boundary confidence threshold, and the pixels satisfying the similarity constraint are merged to generate a moldy area marking map; The boundary confidence threshold is dynamically corrected based on the confidence mean value of the region in the moldy area marking map and the neighborhood gradient change rate to exclude pseudo-boundary areas with discrete confidence distribution.

10. A peanut mold rapid screening system, used to implement a peanut mold rapid screening method according to any one of claims 1 to 9, characterized in that: Includes the following modules: Original image acquisition module: used to collect original hyperspectral images of peanut samples. The original hyperspectral images contain grayscale data of multiple bands. Dynamic filter 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 frequency domain energy distribution and spatial local variance; Grayscale threshold segmentation module: used to segment the mold candidate area from the enhanced hyperspectral image based on the preset grayscale threshold; Feature screening and verification module: used to verify the consistency of spectral and spatial features of the candidate mildew area, and screen the candidate areas that meet the mildew diffusion law to generate a set of valid candidate areas; Texture dimension reduction and fusion module: used to perform texture direction analysis, consistency screening and principal component dimension reduction on the valid candidate area set, and generate a fused feature vector by 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 moldy candidate area, and perform region growth on the pixel points greater than the preset boundary confidence threshold to generate the moldy area 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

  • Lung CT image correlation analysis method

    CN119313921A

  • Adaptive edge detection method fusing three-dimensional frequency domain and spatial domain information

    CN119722717A

  • Defect detection system for quality assurance using automated visual inspection

    US20030081215A1

Cited By

  • Meal replacement powder grinding quality detection method

    CN120411072A

  • Agricultural product quality detection method and system

    CN120468080A

  • Spectral data processing method and device based on adaptive convolution, equipment and medium

    CN120543829A

  • Mildew detection method for peanut screening and related device

    CN120594773A

  • Road greening project maintenance method and system based on machine learning

    CN120808206A