Grain mildew degree image intelligent grading method and system

By combining the adaptive watershed algorithm and multi-dimensional feature extraction with a convolutional neural network for mold grading, the problem of automated grading and safety risk assessment of grain mold detection was solved, realizing quantitative grading and safety risk assessment of the degree of grain mold, and improving detection efficiency and accuracy.

CN121767983APending Publication Date: 2026-03-31TIANJIN INST OF FOOD SAFETY TESTING TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-22
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

Existing technologies rely on manual judgment for grain mold detection, which is inefficient, cannot quantify and grade the degree of mold, and lack the functions of preliminary identification of mold species and safety risk assessment, making it difficult to meet the requirements of large-scale management of modern grain storage.

Method used

An adaptive watershed algorithm is used to separate adhered particles. Combined with multi-dimensional mold feature extraction and a pre-trained convolutional neural network model for mold grading, the automatic grading of the degree of mold in grain is realized, and the initial identification of mold species and safety risk assessment are performed.

Benefits of technology

It enables quantitative grading and safety risk assessment of grain mold levels, improves detection efficiency, enhances the accuracy and consistency of detection results, and supports grain-by-grain analysis of bulk and bagged grains.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121767983A_ABST
    Figure CN121767983A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of grain quality detection, in particular to a grain mildew degree image intelligent grading method and system.The grain mildew degree image intelligent grading method comprises the steps that an annular light source is adopted for collecting images, a watershed algorithm is adopted for separating adhered particles, four kinds of features including color abnormity, mildew spot proportion, form distortion and glossiness attenuation are extracted, and a neural network outputs four-level mildew grades; according to the method, mold types are preliminarily judged, safety risk indexes are calculated, and four types of apparent characteristics including color abnormity, mold spot distribution, form distortion and glossiness change are comprehensively analyzed through multi-dimensional mildew characteristic collaborative extraction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of grain quality testing technology, and in particular to a method and system for intelligent image grading of grain mold degree. Background Technology

[0002] Grain is a vital strategic resource related to national welfare and people's livelihood, and its safe storage directly impacts national food security. During grain storage and processing, mold is a major cause of grain quality deterioration and the production of mycotoxins. When toxin-producing molds such as Aspergillus flavus, Penicillium, and Fusarium grow and multiply on the surface of grain, they produce harmful substances such as aflatoxin, ochratoxin, and deoxynivalenol, seriously threatening human and animal health. Therefore, timely and accurate detection of grain mold levels and graded management are of great significance for ensuring grain quality and safety.

[0003] Currently, grain mold detection mainly relies on manual sensory assessment, with inspectors judging by observing changes in the color of the grains and smelling the moldy odor. This traditional method has the following technical drawbacks: First, manual sensory assessment is highly subjective; different inspectors may yield different results for the same sample, making it difficult to guarantee the consistency and reliability of the test results. Second, early mold growth on the surface of grains is subtle and difficult to detect with the naked eye, easily leading to missed detections. By the time mold becomes visible to the naked eye, the optimal treatment window has often passed. Third, manual grain-by-grain inspection is inefficient and cannot meet the needs of rapid testing of large quantities of grain, making it difficult to adapt to the large-scale management requirements of modern grain storage.

[0004] In the prior art, Chinese invention patent with publication number CN118691684A discloses a machine vision-based method and system for calibrating moldy sunflower seeds. The method uses dual cameras to acquire sunflower seed images and performs Poisson equation fusion. It uses a prototype network model to identify qualified sunflower seed images from complete sunflower seed images and removes them to obtain moldy sunflower seed images. Finally, it combines camera calibration to output the location information of moldy sunflower seeds. While the above-mentioned scheme achieves automation of mold detection to some extent, it still has the following shortcomings: First, the scheme is only applicable to the specific variety of sunflower seeds, and the image fusion and target detection algorithms used are difficult to directly extend to mold detection scenarios for bulk grains such as wheat, corn, and rice; Second, the scheme adopts a reverse strategy of identifying qualified samples and then rejecting them, without directly extracting and analyzing mold characteristics, and lacks support for quantitative grading of mold severity; Third, the scheme only achieves a binary classification of whether or not moldy, without performing multi-level classification according to the national grain mold grading standards, and cannot output refined grading results of normal, slightly moldy, moderately moldy, and severely moldy; Fourth, the scheme does not involve the identification and judgment of mold species, and cannot provide a basis for subsequent targeted treatment; Fifth, the scheme lacks a safety risk assessment function and cannot provide food safety recommendations based on a comprehensive assessment of mold severity and mold species.

[0005] Therefore, there is an urgent need for an intelligent detection method and system that can automatically grade the degree of mold in grains, support the preliminary identification of mold species, and provide a safety risk assessment. Summary of the Invention

[0006] The purpose of this invention is to provide an intelligent image-based grading method and system for the degree of mold in grains, in order to solve the technical problems in the prior art where grain mold detection relies on manual judgment, resulting in low efficiency, inability to quantify and grade the degree of mold, and lack of functions for preliminary identification of mold species and safety risk assessment.

[0007] To achieve the above objectives, the present invention provides an intelligent image-based grading method for the degree of mold in grains, comprising the following steps:

[0008] Step S1: Image acquisition of the grain sample to be tested. The grain sample is uniformly illuminated by a ring light source to obtain a standardized grain image.

[0009] Step S2: Perform particle segmentation preprocessing on the standardized grain images, use the adaptive watershed algorithm to separate the adhering particles, and generate a sequence of single grain images;

[0010] Step S3: Extract multi-dimensional mold features from each single grain image in the single grain image sequence. The extracted mold features include color abnormality index, mold spot area ratio, morphological distortion degree, and gloss attenuation coefficient.

[0011] Step S4: Input the extracted multi-dimensional mold features into the pre-trained mold grading convolutional neural network model, and output the mold grade of each grain. The mold grades include four levels: normal, mild mold, moderate mold, and severe mold.

[0012] Step S5: For grains identified as moldy, make a preliminary judgment on the type of mold, and preliminarily distinguish between Aspergillus flavus, Penicillium and Fusarium based on the color and morphological characteristics of the mold spots;

[0013] Step S6: Calculate the percentage of grains with each mold grade, combine the initial judgment of mold types to calculate the safety risk index, and generate mold grading results and safety risk assessment report.

[0014] Preferably, step S2 employs an improved watershed algorithm based on gradient adaptation, achieving a separation accuracy of no less than 95% for adhering particles.

[0015] Preferably, in step S3, the color anomaly index is calculated based on the HSV color space, the proportion of mold area is obtained through connected component analysis after binarization segmentation, the morphological distortion is calculated based on the roundness and aspect ratio of the particle outline, and the gloss attenuation coefficient is quantified based on the intensity change of the specular reflection component.

[0016] Preferably, the mold grading convolutional neural network model in step S4 adopts a multi-scale feature pyramid structure, including a shallow texture feature extraction branch and a deep semantic feature extraction branch.

[0017] Preferably, in step S5, the mold spots of Aspergillus flavus are yellowish-green and the spore heads are radial, the mold spots of Penicillium are blue-green and the colony edges are regular, and the mold spots of Fusarium are pink to white and the hyphae are cottony.

[0018] Preferably, in step S6, the safety risk index is calculated based on the weight of the mold grade, the proportion of moldy particles, and the mold toxicity coefficient.

[0019] This invention also provides an intelligent image grading system for the degree of mold in grains, comprising:

[0020] The image acquisition module is used to acquire images of the grain samples to be tested. It uses a ring light source to uniformly illuminate the grain samples and obtain standardized grain images.

[0021] The particle segmentation module is used to perform particle segmentation preprocessing on standardized grain images. It uses an adaptive watershed algorithm to separate adhered particles and generate a sequence of single grain images.

[0022] The feature extraction module is used to extract multi-dimensional mold features from each single grain image in the single grain image sequence. The extracted mold features include color abnormality index, mold area ratio, morphological distortion degree and gloss attenuation coefficient.

[0023] The mold grading module is used to input the extracted multi-dimensional mold features into a pre-trained mold grading convolutional neural network model and output the mold grade of each grain.

[0024] The mold pre-identification module is used to pre-identify the type of mold in grains that are determined to be moldy, and to initially distinguish between Aspergillus flavus, Penicillium and Fusarium based on the color and morphological characteristics of the mold spots;

[0025] The risk assessment module is used to calculate the percentage of grains with each mold grade, combine the initial judgment of mold types to calculate the safety risk index, and generate mold grading results and safety risk assessment reports.

[0026] The beneficial effects of this invention are as follows:

[0027] First, this invention uses an adaptive watershed algorithm to achieve automatic separation of adhered particles, supporting particle-by-particle analysis of bulk and bagged grain samples. It solves the technical difficulty of traditional methods in handling particle adhesion problems, and the particle separation accuracy reaches over 95%.

[0028] Secondly, this invention extracts mold features from multiple dimensions in a coordinated manner and comprehensively analyzes four types of appearance features: color abnormality, mold spot distribution, morphological distortion, and gloss change. Compared with single feature determination methods, the comprehensiveness and accuracy of mold identification are significantly improved.

[0029] Third, this invention classifies samples into four levels—normal, mildly moldy, moderately moldy, and severely moldy—according to the national grain mold grading standards, thereby achieving quantitative grading of mold levels and providing a scientific basis for grain grading and disposal.

[0030] Fourth, this invention innovatively introduces a preliminary identification function for mold species, distinguishing common toxin-producing molds such as Aspergillus flavus, Penicillium, and Fusarium by the color and morphological characteristics of mold spots, providing a reference for subsequent mycotoxin detection and targeted treatment.

[0031] Fifth, this invention calculates a safety risk index by comprehensively considering the mold level, the proportion of moldy grains, and the types of mold, and automatically generates a safety risk assessment report, providing comprehensive technical support for grain quality management decisions.

[0032] Sixth, this invention uses a ring light source for uniform illumination to eliminate shadow interference, and combines it with a pre-trained convolutional neural network model to achieve end-to-end automated detection. The detection time for a single sample is no more than 30 seconds, and the detection efficiency is more than 8 times higher than that of manual methods. Attached Figure Description

[0033] Figure 1 This is a flowchart of the intelligent image grading method for the degree of mold in grain provided in an embodiment of the present invention.

[0034] Figure 2 This is an architecture diagram of the intelligent image grading system for the degree of mold in grain provided in an embodiment of the present invention. Detailed Implementation

[0035] Please refer to the attached document. Figures 1-2 The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0036] like Figure 1 As shown in the illustration, this invention provides an intelligent image-based grading method for the degree of mold in grains. This method is mainly applied to mold detection scenarios during grain storage and processing, and supports intelligent grading and detection of mold levels in bulk grain samples such as wheat, corn, and rice. This embodiment uses a wheat sample as an example for illustration, but those skilled in the art will understand that this method is also applicable to other types of grain samples.

[0037] Step S1: Image Acquisition. In one embodiment of the present invention, the specific implementation process of the image acquisition step is as follows: First, the grain sample to be tested is laid flat on the image acquisition platform. The sampling amount is preferably 100 grams to 500 grams, and the sample thickness is controlled within the range of single-layer to double-layer particles to ensure that each grain can be clearly imaged. The image acquisition platform uses a dark matte background plate, preferably dark gray or black, with a reflectivity of less than 5%, to enhance the contrast between the grain and the background.

[0038] The ring light source is a key technical element in this step, serving to eliminate shadow interference and uneven reflection problems caused by traditional point or parallel light sources. In this embodiment, the ring light source is composed of an LED array, with a color temperature set to the standard white light range of 5500K to 6500K, and an illuminance uniformity of no less than 90%. The inner diameter of the ring light source is set to match the outer diameter of the image acquisition lens, preferably in the range of 60 mm to 100 mm, and the outer diameter is set to 1.5 to 2 times the inner diameter. The ring light source is installed around the industrial camera lens, with the illumination angle set at an angle of 45 degrees to 60 degrees to the horizontal plane, so that the light is uniformly distributed in a ring on the surface of the grain sample, effectively eliminating the particle shadow problem caused by unidirectional light sources.

[0039] The industrial camera employs an area-array CMOS sensor with a resolution of at least 12 megapixels, preferably in the range of 20 to 40 megapixels. The camera lens focal length is determined based on the imaging distance and field of view, preferably a 35mm to 50mm fixed-focus lens, with an aperture set to f / 4 to f / 8 to obtain sufficient depth of field. The camera mounting height is set so that the image size of a single grain is at least 50 pixels by 50 pixels to ensure the effectiveness of subsequent feature extraction. In this embodiment, for wheat samples with an average grain size of approximately 6mm, the camera mounting height is set to 200mm to 300mm, corresponding to a spatial resolution of approximately 0.05mm to 0.08mm per pixel.

[0040] During image acquisition, the camera exposure time is automatically adjusted based on the brightness of the ring light source and the reflectivity of the sample, with an optimal range of 1 to 20 milliseconds to avoid overexposure or underexposure. Images are saved in uncompressed RAW or low-compression TIFF format to preserve complete color information and detailed texture. Each acquisition captures a standardized grain image with the same resolution as the camera sensor.

[0041] In addition, before image acquisition, the system performs white balance calibration and color correction, using a standard color chart for color space mapping to ensure color consistency across different batches of images. White balance calibration uses an 18% grayscale chart as a reference, and color correction uses a 24-color standard color chart for matrix transformation.

[0042] Step S2: Particle segmentation preprocessing. Particle segmentation is a prerequisite for particle-by-particle analysis, and its core challenge lies in handling the common particle adhesion problem in bulk grains. In one embodiment of the present invention, the particle segmentation preprocessing step adopts an improved watershed algorithm based on gradient adaptation, and the specific implementation process is as follows.

[0043] First, the standardized grain images are preprocessed by converting the RGB color images to grayscale images using a weighted average method. Then, the grayscale images are subjected to Gaussian filtering to eliminate noise, with the Gaussian kernel size set to 5 x 5 pixels and the standard deviation set to 1.0 to 1.5.

[0044] Next, the gradient magnitude map of the grayscale image is calculated. In this embodiment, the Sobel operator is used to calculate the gradient components in the horizontal and vertical directions respectively, and then the gradient magnitude is calculated. The kernel size of the Sobel operator is set to 3 by 3 pixels. The gradient magnitude map reflects the degree of drastic change in pixel grayscale in the image; the gradient magnitude is larger at the edges of particles and smaller inside the particles.

[0045] Traditional watershed algorithms directly segment the gradient magnitude map, which easily leads to oversegmentation. To address this issue, this invention introduces an improved watershed algorithm with label control. Specifically, foreground and background labels are first obtained through adaptive thresholding. The foreground label acquisition process is as follows: a distance transform is performed on the grayscale image, and the Euclidean distance from each foreground pixel to the nearest background pixel is calculated to obtain a distance map; the distance map is then thresholded, with the threshold set to 0.3 to 0.5 times the maximum value of the distance map, and the connected regions after thresholding are used as foreground labels; the centroid of each connected region corresponds to a seed point of a grain of rice. The background label acquisition process is as follows: the grayscale image is subjected to Otsu's global thresholding method, and the segmentation result is inverted before morphological dilation is performed. The dilation structuring element is a circle with a radius of 3 to 5 pixels, and the dilated result is used as the determined background region.

[0046] After obtaining the foreground and background labels, the gradient magnitude map is modified by forcing the gradient values ​​at the labeled locations to local minima. The modified gradient magnitude map is then used as input to the watershed algorithm, where a watershed transform is performed to obtain the segmentation result. The output of the watershed transform is a labeled image, where each connected region is assigned a unique integer label. Regions with a label value of 0 represent watershed ridges, corresponding to particle boundaries.

[0047] To address the separation of adhered particles, this invention further introduces an adaptive gradient mechanism. Specifically, when calculating the gradient magnitude, the gradient weights are adaptively adjusted based on local image characteristics. For adhered regions, since the grayscale transition at the contact point between two grains is relatively smooth, traditional gradient calculations may fail to detect obvious edges. Therefore, this invention employs a multi-scale gradient fusion strategy, calculating small-scale and large-scale gradients separately. The small-scale gradient uses a 3x3 Sobel kernel, and the large-scale gradient uses a 7x7 Sobel kernel. The final gradient is a weighted sum of the two, with the weights adaptively determined based on local variance. Regions with larger local variance are given greater weight to the small-scale gradient, and regions with smaller local variance are given greater weight to the large-scale gradient.

[0048] The separation accuracy calculation formula of the gradient adaptive watershed algorithm proposed in this invention is as follows:

[0049] ,

[0050] in, To improve separation accuracy, The number of particles that were correctly separated. This represents the actual total number of particles in the sample. In the test of this embodiment, the separation accuracy reached 96.2% for a wheat sample with an adhesion rate of approximately 30%.

[0051] After segmentation, sub-images of each grain are extracted from the original color image based on the segmentation results. Each sub-image is obtained by cropping the bounding rectangle of the grain and adding 5 to 10 pixels of border padding around it to preserve complete edge information. The extracted sub-image sequence is numbered from left to right and top to bottom to form a single-grain image sequence, which serves as input for subsequent feature extraction steps.

[0052] Step S3: Multi-dimensional mold feature extraction. Mold feature extraction is the core step in achieving accurate grading. In one embodiment of the present invention, four types of multi-dimensional mold features are extracted for each single grain image, including color anomaly index, mold spot area ratio, morphological distortion degree, and gloss attenuation coefficient. These four types of features characterize the mold state of the grain from different perspectives, complementing each other to form a complete description of mold features.

[0053] Color abnormality is the most obvious sign of grain mold. Moldy grains usually exhibit different color characteristics from healthy grains, such as yellowing, greening, blackening, or the appearance of localized discolored spots. In this embodiment, the color abnormality index is calculated based on the HSV color space. First, the image of a single grain is converted from the RGB color space to the HSV color space. The HSV color space decomposes color information into three channels: hue (H), saturation (S), and lightness (V). Compared to the RGB color space, it is more in line with human color perception habits and has better robustness to changes in lighting.

[0054] The calculation process for the color anomaly index is as follows: First, a standard HSV color model for healthy grains is established. This model is obtained through statistical analysis of a large number of healthy samples, including the mean and standard deviation of the H, S, and V channels. For the grain to be tested, the Mahalanobis distance between its HSV channel values ​​and the standard model is calculated. The color anomaly index is defined as:

[0055] ,

[0056] in, This is a color anomaly index. , , These represent the average values ​​of hue, saturation, and brightness of the grains to be tested. , , These represent the mean hue, saturation, and brightness values ​​of a standard model for healthy grains. , , These represent the standard deviations of hue, saturation, and lightness for a standard model of healthy grains. The higher the color abnormality index, the further the grain color deviates from the normal range, and the higher the likelihood of mold.

[0057] In this embodiment, for wheat samples, the HSV standard model parameters for healthy grains are: =25 to 35 degrees (corresponding to yellowish-brown tones) =0.3 to 0.5, =0.5 to 0.7. When the color anomaly index A value less than 2.0 is considered normal color. A score between 2.0 and 4.0 is considered a mild color anomaly. A score between 4.0 and 6.0 is considered moderate color abnormality. A value greater than 6.0 is considered a severe color anomaly.

[0058] Mold spots are visible spots or colonies formed by mold growth on the surface of grains, and their size directly reflects the severity of mold growth. In this embodiment, the area ratio of mold spots was obtained through image segmentation and connected component analysis.

[0059] The specific process for mold detection is as follows: First, the single grain image is converted to the Lab color space. The a channel of the Lab color space represents red-green hue, and the b channel represents yellow-blue hue, exhibiting high sensitivity to color changes in mold spots. Then, a mold response map is calculated based on the a and b channels. This map is calculated using a Gaussian mixture model, pre-trained with mold samples, capable of detecting mold regions of different colors such as green, yellow, and black. Next, adaptive thresholding is performed on the mold response map. The threshold is determined using a local adaptive method, and the segmentation result is a binary image of the mold spots. Finally, morphological opening operations are performed on the binary mold image to eliminate small noise points. The structuring element of the opening operation is a circle with a radius of 2 pixels. Subsequently, connected component analysis is performed, and the total area of ​​all connected components of all mold spots is calculated.

[0060] The formula for calculating the percentage of moldy area is:

[0061] ,

[0062] in, This represents the percentage of the area covered by mold. This represents the total pixel area of ​​the moldy region. This represents the total pixel area of ​​the grain region. In this embodiment, a mold spot area ratio of less than 1% is considered as no obvious mold spots, a ratio between 1% and 5% is considered as mild mold spots, a ratio between 5% and 15% is considered as moderate mold spots, and a ratio greater than 15% is considered as severe mold spots.

[0063] During the grain mold growth process, the growth and metabolic activities of mold can cause morphological changes in the grains, such as shrinkage, swelling, or localized depressions. These morphological distortions are important visual characteristics of mold growth. In this embodiment, the degree of morphological distortion is calculated based on the geometric features of the grain outline.

[0064] The process of extracting morphological distortion is as follows: First, the foreground of a single grain image is segmented to obtain a binary mask image of the grain; then, the outer contour of the grain is extracted using an edge detection algorithm, and the contour is represented in the form of a pixel coordinate sequence; next, the geometric feature parameters of the contour are calculated, including roundness, aspect ratio and convexity ratio.

[0065] Circularity is defined as:

[0066] ,

[0067] in, For roundness, The area enclosed by the outline. This represents the perimeter of the outline. The value of roundness ranges from 0 to 1, with a roundness of 1 for a perfect circle and a smaller roundness for more irregular shapes.

[0068] The aspect ratio is defined as the ratio of the length to the width of the bounding rectangle of the grain.

[0069] ,

[0070] in, Aspect ratio, Let be the length of the longer side of the circumscribed rectangle. This is the length of the shorter side of the circumscribed rectangle. The aspect ratio of healthy grains is usually within a certain range, but shrinkage or expansion caused by mold can change the aspect ratio.

[0071] The convexity ratio is defined as the ratio of the area of ​​the contour to the area of ​​the convex hull.

[0072] ,

[0073] in, For convexity ratio, For the outline area, This represents the area of ​​the convex hull of the profile. The convexity ratio ranges from 0 to 1, and is less than 1 when the profile has concavity.

[0074] The degree of morphological distortion is calculated by combining the above three geometric features:

[0075] ,

[0076] in, For morphological distortion degree, , , These are the standard values ​​for the roundness, aspect ratio, and convexity ratio of healthy grains. , , These are weighting coefficients, and the sum of the weighting coefficients is 1. In this embodiment, for the wheat sample, =0.75, =1.8, =0.95, weighting coefficient set to =0.4, =0.3, =0.3. The greater the degree of morphological distortion, the further the grain shape deviates from the normal range.

[0077] Healthy grains typically have a certain degree of gloss, while mold growth increases surface roughness and reduces gloss. In this embodiment, the gloss attenuation coefficient is quantified based on the intensity of the specular reflection component.

[0078] The extraction process for the gloss attenuation coefficient is as follows: First, gloss analysis is performed using the highlight areas generated on the grain surface by a ring light source. In the acquired grain images, due to the uniform illumination of the ring light source, healthy grain surfaces exhibit ring-shaped highlight bands. The brightness and area of ​​these highlight bands are positively correlated with the gloss of the grain surface. The method for extracting the highlight areas is as follows: The V channel of a single grain image is analyzed, and a high brightness threshold is set. The threshold is set to 1.3 to 1.5 times the mean of the V channel; pixels exceeding the threshold are identified as highlight pixels.

[0079] The formula for calculating the gloss attenuation coefficient is:

[0080] ,

[0081] in, This is the gloss attenuation coefficient. The specular reflection intensity of the grain to be tested. The specular reflection intensity is used as a reference sample of healthy grains. The specular reflection intensity is calculated by combining the average brightness and area ratio of the highlight region.

[0082] ,

[0083] in, This represents the average brightness value of the highlight area. This represents the proportion of the glossy area to the total area of ​​the grain. The gloss attenuation coefficient ranges from 0 to 1; a higher value indicates a more significant decrease in gloss and a higher likelihood of mold growth. In this embodiment, a gloss attenuation coefficient less than 0.2 is considered normal gloss, a coefficient between 0.2 and 0.4 is considered mild gloss attenuation, a coefficient between 0.4 and 0.6 is considered moderate gloss attenuation, and a coefficient greater than 0.6 is considered severe gloss attenuation.

[0084] Step S4: Mold Grading. After extracting multi-dimensional mold features, this step inputs the extracted features into a pre-trained mold grading convolutional neural network model to automatically determine the mold grade. In one embodiment of the invention, the mold grading convolutional neural network model adopts a multi-scale feature pyramid structure, which can simultaneously extract shallow texture features and deep semantic features, effectively improving the accuracy of mold grading.

[0085] The structural design of the convolutional neural network model for mold grading is as follows: The network input is a single grain image, with the image size uniformly scaled to 224 pixels by 224 pixels. The main body of the network uses an improved ResNet-50 as the backbone network, which contains four residual block groups, each outputting feature maps at different scales. Based on the backbone network, this invention introduces a feature pyramid network structure, fusing high-level semantic features with low-level detailed features through top-down paths and lateral connections.

[0086] The specific implementation of the feature pyramid network is as follows: First, the feature maps output by the 2nd, 3rd, and 4th residual block groups of the backbone network are denoted as follows: , , Their spatial resolutions are 1 / 4, 1 / 8, and 1 / 16 of the input image, respectively. Then, a top-down feature pyramid is constructed: Directly by After a 1x1 convolution, the number of channels is adjusted to 256. Depend on After upsampling by 2 times and The result is obtained by adding the 1x1 convolution results; Depend on After upsampling by 2 times and The results of the 1x1 convolutions are added together to obtain the final result. , , After smoothing by 3x3 convolution, a fused feature vector is formed through global average pooling and concatenation.

[0087] In addition to image-based depth features, the model also incorporates four types of handcrafted features extracted in step S3. The fusion method involves constructing a 4-dimensional handcrafted feature vector from the color anomaly index, mold area ratio, morphological distortion degree, and gloss attenuation coefficient. This vector is then mapped to a 64-dimensional feature space via a two-layer fully connected network. Finally, it is concatenated with the depth feature vector output from the feature pyramid to form the final fused feature vector. This fused feature vector is then processed through two fully connected networks and a Softmax activation function to output the probability distributions for the four mold levels.

[0088] The rule for determining the mold level is as follows: the level with the highest probability value is taken as the output result. The four levels correspond to normal (level 0), slightly moldy (level 1), moderately moldy (level 2), and severely moldy (level 3), respectively. The classification of mold levels is based on the national grain mold grading standard (GB / T 20569-2006), and the specific standards are as follows: Normal grains have normal appearance and color, no mold spots, no off-odor, and no morphological distortion; Slightly moldy grains have slight discoloration on the surface in the form of spots or streaks, the area of ​​mold spots is less than 5%, and the morphology is basically normal; Moderately moldy grains have obvious discoloration on the surface, the area of ​​mold spots is between 5% and 15%, and may be accompanied by slight shrinkage or expansion; Severely moldy grains have severe discoloration or blackening on the surface, the area of ​​mold spots is greater than 15%, the morphology is severely distorted, or they have begun to rot.

[0089] The model training employed a cross-entropy loss function and the Adam algorithm as the optimizer. The initial learning rate was set to 0.0001, and cosine annealing was used to dynamically adjust the learning rate. The training dataset contained 10,000 labeled single-grain images: 3,000 normal samples, 3,000 slightly moldy samples, 2,500 moderately moldy samples, and 1,500 severely moldy samples. Data augmentation strategies included random rotation (0 to 360 degrees), random flipping (horizontal and vertical), random brightness adjustment (±20%), and random contrast adjustment (±20%). The training run consisted of 100 epochs, with a batch size of 32.

[0090] In this embodiment, an independent test set containing 2000 labeled images was used for evaluation. The model achieved a four-class classification accuracy of 94.6%, with an accuracy rate of 96.2% for normal samples, 93.1% for slightly moldy samples, 93.8% for moderately moldy samples, and 95.4% for severely moldy samples. Compared to traditional machine learning methods that solely use handcrafted features, the deep learning and handcrafted feature fusion method proposed in this invention improves accuracy by 8.3 percentage points.

[0091] Step S5: Preliminary identification of mold species. After determining the mold level of the grains, this step further involves a preliminary identification of the mold species for grains identified as moldy. Identification of mold species is of significant reference value for assessing the risk of mycotoxins and determining subsequent treatment plans. In one embodiment of the present invention, based on the color and morphological characteristics of the mold spots, three common toxin-producing molds—Aspergillus flavus, Penicillium, and Fusarium—are preliminarily distinguished.

[0092] The differences in mold characteristics between Aspergillus flavus, Penicillium, and Fusarium are as follows: Aspergillus flavus colonies are initially white, turning yellowish-green to dark green later, with spore heads radiating outwards and the edges of the mold spots being velvety; Penicillium colonies are bluish-green to grayish-green, with a powdery or granular surface and relatively regular, round edges; Fusarium colonies are diverse in color, commonly pink, purplish-red, or white, with cottony hyphae and irregularly radiating edges of the mold spots.

[0093] The specific process for preliminary identification of mold species is as follows: First, extract the mold spot area from the mold spot detection results in step S3; then, extract the color and morphological features for each mold spot area.

[0094] Color feature extraction: The mold patch area was converted to the HSV color space, and the mean and standard deviation of the hue H were calculated. The hue range of Aspergillus flavus is 60 to 100 degrees (yellow-green hue), the hue range of Penicillium is 100 to 180 degrees (blue-green hue), and the hue range of Fusarium is 0 to 30 degrees or 300 to 360 degrees (pink-red hue) as well as hueless (white).

[0095] Morphological feature extraction: Calculate the shape descriptor of the mold patch region, including roundness, edge roughness, and texture entropy. Roundness is used to distinguish between regular-edged Penicillium and irregular-edged Aspergillus flavus and Fusarium; edge roughness is calculated by the ratio of the contour perimeter to the convex hull perimeter and is used to distinguish between velvety edges and smooth edges; texture entropy is calculated by the gray-level co-occurrence matrix and is used to distinguish between powdery surfaces and cottony surfaces.

[0096] The initial identification of mold species was achieved using a decision tree classifier. The decision tree's rules are as follows:

[0097] First, determine if the mold spot color is pinkish-red. If so, it is preliminarily identified as Fusarium. If not, further determine if it is yellowish-green. If so, it is preliminarily identified as Aspergillus flavus. If it is bluish-green, it is preliminarily identified as Penicillium. If it is black or another color, it is marked as an unknown mold species. Based on the initial color judgment, further confirmation is made through morphological characteristics: Aspergillus flavus has an edge roughness greater than 1.2 and a roundness less than 0.7; Penicillium has a roundness greater than 0.8 and a texture entropy greater than 4.5; Fusarium has a texture entropy less than 4.0 and a radially distributed edge.

[0098] It should be noted that the initial identification of mold species in this step is only a preliminary screening result based on image features, and its accuracy is affected by factors such as image resolution, degree of mold growth, and mixed mold growth. In practical applications, if definitive mold species identification is required, further verification should be performed using methods such as microbial culture, microscopic examination, or molecular biological detection. The initial identification results in this step can serve as a reference and early warning information for subsequent accurate detection.

[0099] In this embodiment, 500 images of moldy grains, confirmed by microbial identification, were used for evaluation. The overall accuracy rate for preliminary mold species identification was 88.4%, with Aspergillus flavus identification accuracy at 90.2%, Penicillium identification accuracy at 87.6%, and Fusarium identification accuracy at 86.8%. Discrepancies between the preliminary identification results and the actual mold species mainly occurred during mixed mold growth or in the early stages of mold growth.

[0100] Step S6: Safety Risk Assessment and Report Generation. After completing the mold grading and preliminary identification of mold types, this step integrates the above analysis results, calculates the quantity percentage of grains of each grade, calculates the safety risk index, and generates a complete mold grading result and safety risk assessment report.

[0101] First, count the quantity and percentage of grains with each level of mold in the grain sample. Let the total number of grains detected in the sample be... The normal number of grains is The number of slightly moldy grains is The number of moderately moldy grains was The number of severely moldy grains was The percentages for each level are as follows: , , , The total percentage of moldy particles was... .

[0102] Secondly, based on the preliminary identification results of mold species, the detection status of various molds was statistically analyzed. Let the detection percentage of Aspergillus flavus be... The detection rate of Penicillium was 10%. The detection rate of Fusarium was 10%. .

[0103] The safety risk index is calculated by comprehensively considering the mold grade, the proportion of moldy particles, and mycotoxin toxicity. The calculation formula is as follows:

[0104] ,

[0105] in, This is the Safety Risk Index. This is the weighting coefficient for the mold level. For the first Percentage of moldy particles of each grade The mycotoxicity coefficient, For the first The detection rate of mold-like fungi. In this embodiment, the weighting coefficient for mold grade is set to... =1.0 (mild) =2.5 (moderate) =5.0 (severe); the mycotoxin toxicity coefficient was set to =3.0 (Aspergillus flavus, produces aflatoxin, a strong carcinogen). =2.0 (Penicillium, which produces penicillin) =2.5 (Fusarium, which produces vomitoxin and zearalenone).

[0106] Based on the safety risk index values, the grain samples were divided into four safety levels:

[0107] Security Level A (Secure): The sample showed only slight mold growth and can be stored and used normally.

[0108] Security Level B (Attention): The sample has a certain risk of mold growth, and it is recommended to dispose of it first or store it separately.

[0109] Security Level C (Warning): The sample is severely moldy. It is recommended to conduct mycotoxin testing and determine the intended use based on the test results.

[0110] Safety level D (Hazardous): The sample was severely moldy and should not be consumed. It may be considered for use as an industrial raw material or for disposal.

[0111] Finally, the system automatically generates a safety risk assessment report, which includes: basic sample information (testing time, sample number, grain type, sampling quantity), a summary of test results (total number of grains tested, quantity and percentage of each grade, total percentage of moldy grains), preliminary judgment of mold species (detection status of various molds), safety risk assessment (safety risk index, safety level, disposal recommendations), and typical images of moldy grains. The report is output in PDF format and also supports data export to Excel format for subsequent statistical analysis.

[0112] In the practical application test of this embodiment, the system tested 100 wheat samples, with an average testing time of 25 seconds per sample, including 3 seconds for image acquisition, 5 seconds for particle segmentation, 12 seconds for feature extraction and grading, and 5 seconds for initial mold detection and report generation. The detection efficiency is approximately 8 times higher than manual visual inspection. The system's mold detection rate is 97.8%, the false negative rate is 2.2%, and the misdetection rate is 3.5%. Its overall detection performance meets the quality testing requirements of grain storage and procurement.

[0113] like Figure 2 As shown in the figure, this embodiment of the invention also provides an intelligent image grading system for the degree of grain mold, which is used to implement the intelligent image grading method for the degree of grain mold described in the above method embodiment. The system includes an image acquisition module 1, a grain segmentation module 2, a feature extraction module 3, a mold grading module 4, a mold pre-judgment module 5, and a risk assessment module 6.

[0114] Image acquisition module 1 is used to acquire images of the grain sample to be tested. In this embodiment, image acquisition module 1 includes an image acquisition platform, a ring light source, an industrial camera, and an image acquisition control unit. The image acquisition platform uses a dark matte background plate to place the grain sample to be tested. The ring light source is installed around the lens of the industrial camera to provide uniform illumination to the grain sample to eliminate shadow interference. The color temperature of the ring light source is 5500K to 6500K, and the illuminance uniformity is not less than 90%. The industrial camera uses an area array CMOS sensor with a resolution of not less than 12 million pixels to acquire images of the grain sample. The image acquisition control unit is used to control the switching and brightness adjustment of the ring light source, control the exposure parameters and trigger acquisition of the industrial camera, perform white balance calibration and color correction, and output a standardized grain image. The output of image acquisition module 1 is a standardized grain image, which is transmitted to particle segmentation module 2 for subsequent processing.

[0115] The grain segmentation module 2 is used to perform grain segmentation preprocessing on the standardized grain image, using an adaptive watershed algorithm to separate adhered grains and generate a sequence of single-grain grain images. In this embodiment, the grain segmentation module 2 includes an image preprocessing unit, a gradient calculation unit, a label generation unit, and a watershed segmentation unit. The image preprocessing unit converts the RGB color image to a grayscale image and performs Gaussian filtering for noise reduction. The gradient calculation unit calculates the gradient magnitude map using the multi-scale Sobel operator and adaptively adjusts the gradient weights based on local variance. The label generation unit generates foreground labels through distance transformation and thresholding, and generates background labels through Otsu's method segmentation and morphological dilation. The watershed segmentation unit performs watershed transformation based on the labeled gradient magnitude map, outputs segmentation label images, and extracts single-grain grain sub-images from the original image based on the segmentation results to form a sequence of single-grain grain images. The input of the grain segmentation module 2 is a standardized grain image, and the output is a sequence of single-grain grain images, which is transmitted to the feature extraction module 3 for subsequent processing.

[0116] Feature extraction module 3 is used to extract multi-dimensional mold features from each single grain image in the single grain image sequence. In this embodiment, feature extraction module 3 includes a color feature extraction unit, a mold spot feature extraction unit, a morphological feature extraction unit, and a gloss feature extraction unit. The color feature extraction unit is used to convert the image to the HSV color space and calculate the color anomaly index, which is calculated based on the Mahalanobis distance between the HSV value of the grain to be detected and the standard model of healthy grains. The mold spot feature extraction unit is used to detect mold spot areas in the Lab color space and calculate the proportion of mold spot area through binarization segmentation and connected component analysis. The morphological feature extraction unit is used to extract the grain outline, calculate the roundness, aspect ratio, and convexity ratio, and obtain the morphological distortion degree. The gloss feature extraction unit is used to detect highlight areas, calculate the specular reflection intensity, and obtain the gloss attenuation coefficient by comparing it with the reference value. The input of feature extraction module 3 is the single grain image sequence, and the output is a four-dimensional mold feature vector for each grain, which is transmitted to the mold grading module 4 for subsequent processing.

[0117] The mold grading module 4 is used to input the extracted multi-dimensional mold features into a pre-trained mold grading convolutional neural network model and output the mold grade of each grain. In this embodiment, the mold grading module 4 includes a deep feature extraction unit, a feature fusion unit, and a classification output unit. The deep feature extraction unit uses an improved ResNet-50 backbone network combined with a feature pyramid structure to extract multi-scale deep features from a single grain image. The feature fusion unit is used to map the manually extracted four-dimensional mold features through a fully connected network and then concatenate them with the deep feature vector to form a fused feature vector. The classification output unit is used to output the probability distribution of the four mold grades after passing the fused feature vector through a fully connected network and a Softmax activation function, and takes the grade with the highest probability as the output result. The mold grades include four levels: normal, lightly moldy, moderately moldy, and severely moldy. The input of the mold grading module 4 is a single grain image and a four-dimensional mold feature vector, and the output is the mold grade of each grain. The information of grains determined to be moldy is transmitted to the mold pre-judgment module 5 for further processing.

[0118] The mold preliminary judgment module 5 is used to make a preliminary judgment on the type of mold in grains identified as moldy. In this embodiment, the mold preliminary judgment module 5 includes a mold spot color analysis unit, a mold spot morphology analysis unit, and a type determination unit. The mold spot color analysis unit is used to extract the HSV color features of the mold spot area and determine the main color tone type of the mold spot. The mold spot morphology analysis unit is used to calculate shape descriptors such as the roundness, edge roughness, and texture entropy of the mold spot area. The type determination unit uses a decision tree classifier to preliminarily distinguish between Aspergillus flavus, Penicillium, and Fusarium based on the color and morphology features of the mold spots. Aspergillus flavus mold spots are yellowish-green with radial spore heads, Penicillium mold spots are bluish-green with regular colony edges, and Fusarium mold spots are pink to white with cottony hyphae. The input of the mold preliminary judgment module 5 is an image of the mold spot area of ​​the moldy grain, and the output is the preliminary mold type judgment result, which is transmitted to the risk assessment module 6 for further processing.

[0119] The risk assessment module 6 is used to statistically analyze the proportion of grains with different mold grades, calculate the safety risk index based on the preliminary judgment of mold species, and generate mold grading results and a safety risk assessment report. In this embodiment, the risk assessment module 6 includes a statistical analysis unit, a risk calculation unit, and a report generation unit. The statistical analysis unit summarizes the mold grading results of all grains, calculates the quantity and proportion of each grade, and calculates the detection quantity and proportion of various molds. The risk calculation unit calculates the safety risk index based on the mold grade weight, the proportion of moldy grains, and the mold toxicity coefficient, and determines the safety level of the sample based on the safety risk index. The report generation unit generates a safety risk assessment report, which includes basic sample information, a summary of test results, preliminary judgment of mold species, safety risk assessment, and treatment recommendations. The report supports PDF output and Excel data export. The inputs to the risk assessment module 6 are the mold grade of each grain and the preliminary judgment of mold species; the outputs are the mold grading results and the safety risk assessment report.

[0120] The six modules described above work together to form a complete intelligent image-based grading system for grain mold levels. The overall data flow of the system is as follows: Image acquisition module 1 acquires standardized grain images, which are then transmitted to particle segmentation module 2 for separating adhered particles. The resulting single-grain image sequence is transmitted to feature extraction module 3 for multi-dimensional mold feature extraction. The extracted features and images are transmitted to mold grading module 4 for mold level determination. Grains determined to be moldy are transmitted to mold pre-judgment module 5 for preliminary mold type determination. Finally, risk assessment module 6 integrates all results to calculate a safety risk index and generate an assessment report. The system supports batch detection and result storage and can interface with grain storage management systems for data sharing.

[0121] This invention achieves intelligent grading and detection of grain mold levels through the deep coupling and collaborative operation of six modules: image acquisition, particle segmentation, feature extraction, mold grading, initial mold detection, and risk assessment. These modules are closely interconnected: the image acquisition module uses a ring light source for uniform illumination to eliminate shadow interference, providing high-quality input for subsequent particle segmentation; the particle segmentation module uses a gradient adaptive watershed algorithm to separate adhered particles, ensuring each grain can be analyzed independently; the feature extraction module collaboratively characterizes mold features from four dimensions: color, mold spots, morphology, and gloss, overcoming the limitations of single-feature judgment; the mold grading module integrates deep learning features and manual features for four-level classification, achieving quantitative grading of mold levels; the initial mold detection module distinguishes common toxin-producing molds based on mold spot color and morphology, providing a basis for risk assessment; and the risk assessment module calculates a safety risk index based on mold level and mold type, providing decision support for grain quality management. These six modules form a complete closed-loop processing flow, with overall technical performance far superior to the simple summation of individual functions.

[0122] The above description is merely a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A method for intelligent image-based grading of grain mold levels, characterized in that, Includes the following steps: Step S1: Image acquisition of the grain sample to be tested. The grain sample is uniformly illuminated by a ring light source to obtain a standardized grain image. The ring light source is installed around the lens of an industrial camera, and the illumination angle is set to be 45 to 60 degrees with the horizontal plane. Step S2: Perform particle segmentation preprocessing on the standardized grain image, use an improved watershed algorithm based on gradient adaptation to separate adhered particles, generate a sequence of single grain images, the improved watershed algorithm generates foreground markers through distance transformation and thresholding, generates background markers through Otsu's method segmentation and morphological dilation, and uses a multi-scale gradient fusion strategy to process adhered regions. Step S3: Extract multi-dimensional mold features from each single grain image in the single grain image sequence. The extracted mold features include color anomaly index, mold area ratio, morphological distortion degree, and gloss attenuation coefficient. The color anomaly index is obtained by calculating the Mahalanobis distance between the grain to be detected and the standard model of healthy grain based on the HSV color space. The mold area ratio is obtained by mold detection and connected component analysis in the Lab color space. Step S4: Input the extracted multi-dimensional mold features and the single grain image into the pre-trained mold grading convolutional neural network model, and output the mold level of each grain. The mold level includes four levels: normal, mild mold, moderate mold, and severe mold. The mold grading convolutional neural network model adopts a multi-scale feature pyramid structure to fuse deep features with manually extracted mold features for classification. Step S5: For grains identified as moldy, make a preliminary judgment on the type of mold, and preliminarily distinguish between Aspergillus flavus, Penicillium and Fusarium based on the color and morphological characteristics of the mold spots; Step S6: Calculate the percentage of grains of each moldy grade, combine the preliminary judgment results of the mold types to calculate the safety risk index, and generate mold grading results and safety risk assessment report.

2. The intelligent image-based grading method for grain mold degree according to claim 1, characterized in that, In step S1, the color temperature of the ring light source is 5500K to 6500K, the illuminance uniformity is not less than 90%, the resolution of the industrial camera is not less than 12 million pixels, and the imaging size of a single grain is not less than 50 pixels by 50 pixels.

3. The intelligent image-based grading method for grain mold degree according to claim 1, characterized in that, In step S2, the multi-scale gradient fusion strategy calculates the small-scale gradient and the large-scale gradient respectively. The small-scale gradient uses a 3x3 Sobel kernel, and the large-scale gradient uses a 7x7 Sobel kernel. The final gradient is the weighted sum of the two, and the weights are adaptively determined based on the local variance.

4. The intelligent image-based grading method for the degree of mold in grains according to claim 1, characterized in that, In step S2, the process of obtaining the foreground marker is as follows: perform distance transformation on the grayscale image, perform threshold processing on the distance map, and set the threshold to 0.3 to 0.5 times the maximum value of the distance map. The connected region after threshold processing is used as the foreground marker.

5. The intelligent image-based grading method for grain mold degree according to claim 1, characterized in that, In step S3, the morphological distortion degree is calculated based on the roundness, aspect ratio, and convexity ratio of the particle outline, and the calculation formula is as follows: in, For morphological distortion degree, For roundness, Aspect ratio, For convexity ratio, , , These are the standard values ​​for healthy grains. , , These are the weighting coefficients.

6. The intelligent image-based grading method for grain mold degree according to claim 1, characterized in that, In step S3, the formula for calculating the gloss attenuation coefficient is: , in, This is the gloss attenuation coefficient. The specular reflection intensity of the grain to be tested. The specular reflection intensity of the healthy grain reference sample is calculated by multiplying the average brightness value of the highlight area by the area ratio.

7. The intelligent image-based grading method for grain mold degree according to claim 1, characterized in that, In step S4, the mold grading convolutional neural network model uses an improved ResNet-50 as the backbone network. A feature pyramid network structure is introduced on the basis of the backbone network to fuse high-level semantic features with low-level detailed features through top-down paths and lateral connections.

8. The intelligent image-based grading method for grain mold degree according to claim 1, characterized in that, In step S5, the mold spots of Aspergillus flavus are yellowish-green and the spore heads are radial; the mold spots of Penicillium are blue-green and the colony edges are regularly circular; and the mold spots of Fusarium are pink to white and the hyphae are cottony.

9. The intelligent image-based grading method for the degree of mold in grains according to claim 1, characterized in that, In step S6, the formula for calculating the safety risk index is: , in, As a safety risk index, This is the weighting coefficient for the mold level. For the first Percentage of moldy particles by grade The mycotoxicity coefficient, For the first The detection rate of mold-like fungi, Indicates Aspergillus flavus. It represents Penicillium. It represents Fusarium.

10. A grain mold degree image intelligent grading system, used to implement the grain mold degree image intelligent grading method according to any one of claims 1-9, characterized in that, include: The image acquisition module is used to acquire images of the grain samples to be tested. It uses a ring light source to uniformly illuminate the grain samples and obtain standardized grain images. The particle segmentation module is used to perform particle segmentation preprocessing on the standardized grain image, and uses an improved watershed algorithm based on gradient adaptation to separate adhering particles and generate a sequence of single grain images. The feature extraction module is used to extract multi-dimensional mold features from each single grain image in the single grain image sequence. The extracted mold features include color abnormality index, mold area ratio, morphological distortion degree and gloss attenuation coefficient. The mold grading module is used to input the extracted multi-dimensional mold features and the single grain image into a pre-trained mold grading convolutional neural network model, and output the mold grade of each grain. The mold pre-identification module is used to pre-identify the type of mold in grains that are determined to be moldy, and to initially distinguish between Aspergillus flavus, Penicillium and Fusarium based on the color and morphological characteristics of the mold spots; The risk assessment module is used to calculate the percentage of grains with each mold grade, calculate the safety risk index based on the preliminary judgment of the mold types, and generate mold grading results and a safety risk assessment report.

Citation Information

Patent Citations

  • Mildew melon seed calibration method and system based on machine vision

    CN118691684A

Cited By

  • Grain detection device and detection method

    CN121995016A

  • A cereal detection device and method

    CN121995016B