High-precision identification method and system for grain particles in gathered image

Through multi-stage image processing and deep learning methods, the problem of insufficient recognition accuracy of grain particles in grain cooking utensils is solved, and high-precision identification of grain rice grain varieties and rice water ratio mixing is achieved, which improves the cooking effect.

CN120580480AInactive Publication Date: 2025-09-02陈必东
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510660529.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-22
Publication Date
2025-09-02
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, cereal cooking utensils have problems with insufficient recognition accuracy when identifying grain varieties and mixing rice and water ratios, especially in the aggregated image, the recognition effect of grain particles is poor, which affects the cooking effect.

Method used

Multi-stage image processing and deep learning methods are adopted, including image preprocessing, segmentation, standardization, morphological feature screening and neural network recognition. High-precision recognition of grain particles is achieved through multi-scale Retinex enhancement, RICESAM model segmentation, Filter-I algorithm screening and neural network classification.

Benefits of technology

It improves the accuracy and efficiency of grain particle recognition, can accurately identify grain rice varieties, provide accurate reference for rice and water ratio, and improve cooking effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120580480A_ABST
    Figure CN120580480A_ABST
Patent Text Reader

Abstract

The invention discloses a high-precision identification method and system for grain grains in an aggregated image, and the method comprises the steps: obtaining an original image of rice grains, carrying out the preprocessing, and obtaining a clustered rice grain image data set; segmenting the clustered rice grain image to obtain a first rice grain image data set; standardizing the first rice grain image data set to obtain a second rice grain image data set; performing first screening and second screening on the second rice grain image data set in sequence to obtain a third rice grain image data set and a fourth rice grain image data set respectively; tracing and extracting rice grain original image data corresponding to the fourth rice grain image data set to form a fifth rice grain image data set containing the rice grain original image data; and in combination with a pre-trained neural network, performing type identification on the rice grain original image in the fifth rice grain image data set, and outputting the rice grain variety. According to the technical scheme disclosed by the invention, the variety of the cereal rice grains can be accurately identified, and a numerical reference is provided for the rice-water ratio of intelligent cooking of the cereal rice grains.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of deep learning and rice grain recognition, and more specifically, to a high-precision recognition method and system for grains in aggregated images. Background Art

[0002] Cereal foods, made from cereal crops, occupy a central position in the human diet. Cereal crops, in turn, are crops whose starchy seeds provide essential energy and nutrition. The cooking process of cereals is influenced by a variety of parameters and factors, including the type of cereal, the rice-to-water ratio during cooking, cooking time, and cooking utensils. For example, different cereal varieties have varying characteristics such as starch content, grain size, and shape, requiring widely varying cooking methods to achieve optimal results. The rice-to-water ratio is a key factor influencing the taste and texture of cereal foods. For example, a typical rice-to-water ratio of 1:1.2 to 1:1.5 is ideal. Too little water results in hard or even undercooked rice, while too much water makes the rice too soft. The effects of cooking time and cooking utensils on food are well-known based on existing experience. Therefore, changes in any single parameter or factor can have a profound impact on the cooking quality of cereal foods.

[0003] While existing technologies have achieved relatively mature solutions for cooking time and cooking utensils, the identification of grain varieties and the precise adjustment of the rice-to-water ratio in cooking utensils remain a challenging task. Due to the increasing number of cereal crop varieties, coupled with occlusion and similarity issues in image recognition, such as interference with recognition caused by mixed grains, insufficient robustness of image recognition under complex lighting and background interference, and a high rate of missed detection of small targets and broken grains, accurate identification of grains using cooking utensils, specifically identifying the hulled cereal variety and ensuring the appropriate rice-to-water ratio for rice cooking, has become a significant challenge.

[0004] Therefore, how to provide a high-precision recognition method and system for grain particles in aggregated images, which can accurately identify the variety of grain rice grains and provide a numerical reference for the rice-water ratio for intelligent cooking of grain rice grains, has become a technical problem that needs to be urgently solved by those skilled in the art. Summary of the Invention

[0005] To solve the above technical problems, the present invention provides a high-precision recognition method and system for grain particles in aggregated images, which can accurately identify the variety of grain rice grains and provide a numerical reference for the rice-water ratio of intelligent cooking of grain rice grains.

[0006] The technical solutions provided by the present invention are as follows:

[0007] The present invention provides a high-precision method and system for identifying grains in clustered images, comprising the following steps: S1, obtaining original images of rice grains of cereal crops; S2, preprocessing the original rice grain images to obtain a clustered rice grain image dataset; S3, segmenting the clustered rice grain image dataset to obtain a first rice grain image dataset containing rice grain images that meet a first rule; S4, standardizing the first rice grain image dataset to construct a second rice grain image dataset of a standard size; S5, performing a first screening on the second rice grain image dataset to remove rice grain images that do not meet morphological feature requirements, thereby obtaining a third rice grain image dataset;

[0008] S6. Combined with the pre-trained neural network, the third rice grain image dataset is subjected to a second screening to screen out images that meet the completeness requirements, thereby obtaining a fourth rice grain image dataset; S7. Based on the fourth rice grain image dataset, the original rice grain images corresponding to the fourth rice grain image dataset are extracted by tracing back to the source to form a fifth rice grain image dataset containing the original rice grain images; S8. Combined with the pre-trained neural network, the type of the rice grain original images in the fifth rice grain image dataset is identified, and the identification result of the rice grain variety is output.

[0009] Furthermore, in a preferred embodiment of the present invention, step S2 specifically includes:

[0010] S201, multi-scale Retinex enhancement: normalizing the original rice grain image and processing it using multiple Gaussian filters of different scales to generate corresponding filtered images;

[0011] Based on the difference between the original rice grain image and each filtered image, a multi-scale Retinex enhancement result is calculated and normalized and outputted;

[0012] S202, color space correction: converting the enhanced image to LAB color space, performing offset correction on the mean of the color channels, and then converting back to RGB space;

[0013] S203, global white balance and CLAHE enhancement: white balance gain adjustment is performed based on the global mean of the RGB channels, and block adaptive histogram equalization processing is performed on each channel to generate the final enhanced image.

[0014] Furthermore, in a preferred embodiment of the present invention, step S3 specifically includes:

[0015] S301, constructing a RICESAM model, inputting the clustered rice grain image dataset into the RICESAM model, and obtaining image embedding through the model's image encoder;

[0016] S302, determining segmentation hint information of the image, extracting its spatial features through a convolutional layer, and then encoding the spatial features into a hint embedding aligned with the image embedding based on a model hint encoder;

[0017] S303, according to the mask decoder of the RICESAM model, interactively combining the image embedding and the hint embedding to generate a segmentation mask of the image;

[0018] S304 : Perform morphological screening on the segmentation mask to obtain a final mask output of the rice grains, thereby obtaining a rice grain mask image in which the rice grains are separated from the black background, that is, a first rice grain image dataset.

[0019] Furthermore, in a preferred embodiment of the present invention, step S4 specifically includes:

[0020] S401, obtaining the numerical size of the rice grain mask image and the standard size of the standard image;

[0021] S402, determining the geometric center position of the rice grain outline in the rice grain mask image, and aligning the geometric center with the center coordinates of the rice grain mask image;

[0022] S403 , obtaining a scaling ratio, scaling the rice grain outline to a black background of a standard size, obtaining a single rice grain image, and then outputting the single rice grain image dataset, i.e., a second rice grain image dataset.

[0023] Furthermore, in a preferred embodiment of the present invention, step S5 specifically includes:

[0024] S501. Defining morphological characteristic parameters of a complete rice grain based on a complete rice grain image, wherein the morphological characteristic parameters include: rice grain area aA, rice grain outline perimeter aP, area-to-perimeter ratio aR, major axis length maL of the fitted ellipse, minor axis length miL of the fitted ellipse, fitted ellipse area eA, fitted ellipse perimeter eP, area difference aG, aspect ratio asR, and ellipse circularity rD.

[0025] S502, constructing a Filter-I algorithm based on morphological quantification according to the morphological feature parameters;

[0026] S503: Acquire the rice grain mask image from the second rice grain image dataset, and then input the rice grain mask image into the Filter-I algorithm to extract morphological feature parameters of each rice grain in the image;

[0027] S504: Preset a parameter threshold, compare and analyze the morphological characteristic parameters of the rice grains with the parameter threshold, and filter out the rice grain mask images that do not meet the parameter threshold requirement;

[0028] S505: Output the filtered rice grain mask image and merge it to obtain a third rice grain image dataset.

[0029] Furthermore, in a preferred embodiment of the present invention, in step S504, the method of comparing and analyzing the morphological characteristic parameters of the rice grains with the parameter thresholds includes:

[0030] According to the category of the morphological characteristic parameter, a threshold value range is set to determine whether the morphological characteristic parameter of the rice grain is within the threshold value range, and samples with obviously abnormal values ​​are screened out;

[0031] A similarity analysis is performed based on the complete rice grain profile and the actual rice grain profile characteristics to screen out samples that do not meet the similarity requirements, wherein the similarity analysis method comprises the following steps:

[0032] Get the actual rice grain contour point set And calculate the actual rice grain contour centroid

[0033] Based on the actual rice grain outline centroid and the fitted ellipse centroid, the center distance of the actual rice grain outline is calculated. And the normalized matrix The formula is as follows:

[0034]

[0035] Then, based on the normalized matrix, the Hu matrix of the actual rice grain profile is obtained.

[0036] Fit an ellipse according to the actual rice grain outline to generate a set of fitted ellipse points and calculate the centroid of the fitted ellipse outline. Repeat the above steps to obtain the Hu matrix of the fitted ellipse.

[0037] The Hu matrix of the actual rice grain outline and the Hu matrix of the fitted ellipse are combined to perform a similarity calculation to evaluate the matching degree between the rice grain outline and the fitted ellipse outline. The formula is as follows:

[0038]

[0039] Furthermore, in a preferred embodiment of the present invention, the similarity analysis method further comprises: calculating the similarity using a W-shaped algorithm, that is, converting the rice grain outline edge into a digitally described waveform, and then performing wave analysis to determine the degree of similarity; specifically comprising the following steps:

[0040] Get the centroid coordinates C(x c ,y c ):

[0041]

[0042] Among them, x i ,y i is the coordinate of the i-th point on the boundary of the rice grain, m i is the weight of the i-th point, N is the total number of rice grain contour boundary points;

[0043] Then the distance from the boundary point of the rice grain contour to the center of mass is calculated according to the Euclidean distance formula || P i C||:

[0044]

[0045] Calculate the adjacent points P on the rice grain contour i With P i-1 The segment length is used to obtain the cumulative arc length L. i :

[0046] L i =L i-1 +||P i P i-1 ||;

[0047] Among them, the initial cumulative arc length L0=0, the distance between adjacent points ||P i P i-1 ||Calculated by the following formula:

[0048]

[0049] Then the distance from the boundary point of the rice grain outline to the center of mass ||P i C|| is the vertical axis, the cumulative arc length L i A coordinate system is established for the horizontal axis, and a W-shaped curve is generated for the complete rice grain outline, i.e., a complete rice grain outline waveform diagram;

[0050] According to the above steps, an actual rice grain contour waveform is obtained, and wave analysis is performed based on the complete rice grain contour waveform and the actual rice grain contour waveform to quantify rice grain contour features and evaluate the degree of similarity.

[0051] Furthermore, in a preferred embodiment of the present invention, step S6 is specifically as follows:

[0052] Based on a pre-trained neural network, the filtered rice grain mask image is subjected to binary classification to divide the image into a complete rice grain mask image and an incomplete rice grain mask image, and then the complete mask image is output to obtain a fourth rice grain image dataset, which specifically includes the following steps:

[0053] S601, constructing a neural network classification model, and pre-training the neural network classification model;

[0054] S602: Inputting a rice grain mask image into the neural network classification model, first passing the image through a 32-channel, stride-2 convolutional layer to extract shallow features, and outputting a feature map with half the resolution and an expanded number of channels;

[0055] S603: Based on the inverted residual structure, stack multiple groups of bottleneck modules, and gradually extract deep features of the feature map through the multiple bottleneck modules;

[0056] S604: Then, the feature map is expanded through 1×1 convolution, and the feature map size is compressed by average pooling. Then, the number of image channels is mapped to the number of classification categories k through 1×1 convolution, and the image classification result is output.

[0057] Furthermore, in a preferred embodiment of the present invention, the neural network classification model is trained by performing D-FTL step-by-step transfer learning based on a preset neural network model, and the specific steps include:

[0058] Set initial parameters: Pre-train the neural network model based on the ImageNet dataset, and then obtain the neural network model weights to initialize the model;

[0059] Training on the clustered rice grain image dataset: Based on the clustered rice grain image dataset and data augmentation techniques, the initialization model is trained. All convolutional and fully connected layers are trained. The weights of the clustered rice grain model are normalized using the mean and variance of the original rice grain image dataset. The number of neurons in the last fully connected layer is adjusted based on the number of rice grain categories.

[0060] Single-grain rice image dataset training: Based on the weights of the clustered rice grain model, model training for the single-grain rice grain image dataset is initialized. During training, the network parameters of the shallower layers of the neural network model are frozen, and only the deep network and fully connected layers are trained. The number of neurons in the last fully connected layer is kept unchanged. The model is optimized based on the single-grain rice grain image dataset to obtain a neural network classification model for identifying rice grains.

[0061] The present invention also provides another technical method:

[0062] The present invention provides a high-precision method for identifying grains in an aggregated image, comprising:

[0063] An image acquisition module, used for acquiring original images of rice grains of cereal crops;

[0064] an image processing module connected to the image acquisition module;

[0065] The image processing module includes: an image preprocessing unit for enhancing the original rice grain image to obtain a clustered rice grain image dataset; an image segmentation unit connected to the image preprocessing unit, for segmenting the image to achieve rice grain size segmentation; and an image standardization unit connected to the image segmentation unit for adjusting the image size.

[0066] an image screening module connected to the image processing module;

[0067] The image screening module includes: a first screening unit for performing a first screening on the rice grain image according to the rice grain morphological characteristic parameters; a second screening unit connected to the first screening unit, and the second screening unit is used to perform a second screening on the rice grain image after the first screening according to the integrity requirement;

[0068] an image tracing module connected to the image screening module, the image tracing module being configured to perform tracing processing on the image output by the second screening unit to obtain an original image of rice grains corresponding to the image output by the second screening unit;

[0069] a rice grain image recognition module connected to the image tracing module, the rice grain image recognition module being configured to recognize and output the category of rice grains in the image based on a neural network classification model;

[0070] The model training module is used to establish and pre-train the neural network classification model.

[0071] The present invention provides a high-precision method and system for identifying grains in clustered images. The identification method comprises the following steps: S1, obtaining an original image of a grain of rice of a cereal crop; S2, preprocessing the original image of the grain of rice to obtain a clustered grain of rice image dataset; S3, segmenting the clustered grain of rice image dataset to obtain a first grain of rice image dataset containing grains that meet a first rule; S4, standardizing the first grain of rice image dataset to construct a second grain of rice image dataset of a standard size; S5, performing a first screening on the second grain of rice image dataset to remove grains that do not meet a first rule; S6: Using a pre-trained neural network to perform a second screening on the third rice grain image dataset to select images that meet the completeness requirements and obtain a fourth rice grain image dataset; S7: Based on the fourth rice grain image dataset, extract the original rice grain images corresponding to the fourth rice grain image dataset to form a fifth rice grain image dataset containing the original rice grain images; S8: Using a pre-trained neural network to perform type recognition on the original rice grain images in the fifth rice grain image dataset and output recognition results of the rice grain varieties.The high-precision recognition method for grains in aggregated images disclosed in the present invention adopts advanced image processing and machine learning algorithms to recognize and classify grains of cereal crops, which can significantly improve the recognition accuracy and acquisition efficiency of grains. The high-precision recognition method for grains in aggregated images mainly includes eight steps: the first step is to obtain the original image of the grains of cereal crops, which is mainly obtained by high-precision image acquisition equipment; the second step is to pre-process the image after obtaining the original image of the grains, enhance the image features, improve the recognition efficiency of the image, and obtain a rich collection of grains. The first step is to segment the original rice grain image and extract the independent rice grain contour image by using the image segmentation model to obtain the first rice grain image dataset, thereby realizing zero-sample segmentation of the grain image and significantly improving the efficiency of rice grain contour segmentation. Since the size of the rice grain mask image in the first rice grain image dataset does not support the subsequent image screening algorithm, step S4 standardizes the first rice grain image dataset according to the standard size to eliminate the data deviation caused by the difference in algorithm output and provide a unified size input for the subsequent algorithm. The fifth and sixth steps are to use the deep learning algorithm to perform the standard processing on the first rice grain image dataset. The rice grain mask image is screened by the method, wherein step S5 uses a neural network classification algorithm to perform a morphological feature parameter ratio analysis on the rice grain mask image to achieve the first screening of the image and remove the rice grain images that do not meet the morphological feature requirements; since after the preliminary screening, there are still irregular or abnormal masks that need to be further refined, step S6 combines the integrity difference of the rice grains to perform a second classification, specifically, based on the third rice grain image data set after the first screening, the rice grain mask image is subjected to a second screening process to achieve two filtering processes on the rice grain mask image to ensure the final image segmentation result. Quality; Next, for step S7, the fourth rice grain image data set after screening is traced to obtain the original rice grain image corresponding to the fourth rice grain image data, and the rice grain variety identification is performed using the original rice grain image, which not only retains the complete rice grain image feature information, so that the model has both high precision and strong generalization ability, but also avoids the risk of image distortion and impact on recognition results when directly using the rice grain mask image for recognition; the last step is to identify the rice grain variety, and identify the original rice grain image after tracing through the neural network classification model, and output the rice grain variety identification result, so as to achieve accurate identification of grain rice grains. It can be seen that the technical solution involved in the present invention, compared with the prior art, can accurately identify the variety of grain rice grains and provide a numerical reference for the rice-water ratio of intelligent cooking of grain rice grains. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0073] Figure 1 This is a flowchart of the steps of the method and system for high-precision identification of grains in aggregated images according to an embodiment of the present invention;

[0074] Figure 2 A flowchart of the steps of preprocessing the original rice grain image to obtain a clustered rice grain image dataset according to an embodiment of the present invention;

[0075] Figure 3 A flowchart of the steps of performing segmentation processing on the clustered rice grain image dataset to obtain a first rice grain image dataset containing rice grain images that meet a first rule, according to an embodiment of the present invention;

[0076] Figure 4 A flowchart of the steps of standardizing the first rice grain image dataset to construct a second rice grain image dataset of a standard size according to an embodiment of the present invention;

[0077] Figure 5 A flowchart of the steps of performing a first screening on the second rice grain image dataset, removing rice grain images that do not meet morphological feature requirements, and obtaining a third rice grain image dataset according to an embodiment of the present invention;

[0078] Figure 6 A flowchart of the steps of performing a second screening on the third rice grain image dataset in combination with a pre-trained neural network, screening out images that meet the integrity requirement, and obtaining a fourth rice grain image dataset, according to an embodiment of the present invention;

[0079] Figure 7 is a schematic diagram of a clustered rice grain image after image feature enhancement according to an embodiment of the present invention;

[0080] Figure 8 Schematic diagram of the stages and steps of segmenting the clustered rice grain image dataset involved in an embodiment of the present invention;

[0081] Figure 9 A schematic diagram of some of the morphological feature parameters involved in an embodiment of the present invention;

[0082] Figure 10 A schematic diagram of a waveform diagram for converting rice grain contour edges into digital descriptions according to an embodiment of the present invention;

[0083] Figure 11 This is a system architecture diagram of the high-precision recognition system for grains in aggregated images according to an embodiment of the present invention. DETAILED DESCRIPTION

[0084] In order to enable those skilled in the art to better understand the technical solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings of 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 those skilled in the art without making any creative efforts shall fall within the scope of protection of the present invention.

[0085] It should be noted that when an element is referred to as being “fixed on” or “set on” another element, it can be directly on the other element or indirectly set on the other element; when an element is referred to as being “connected to” another element, it can be directly connected to the other element or indirectly connected to the other element.

[0086] It should be understood that the terms "length", "width", "up", "down", "front", "back", "first", "second", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore cannot be understood as limiting the present invention.

[0087] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of the technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of such features. In the description of the present invention, "plurality" or "several" means two or more, unless otherwise specifically defined.

[0088] It should be noted that the structures, proportions, sizes, etc. depicted in the drawings of this specification are only used to match the contents disclosed in the specification so that people familiar with this technology can understand and read them. They are not used to limit the conditions under which the present invention can be implemented. Therefore, they have no substantive technical significance. Any structural modification, change in proportional relationship or adjustment of size should still fall within the scope of the technical content disclosed in the present invention without affecting the efficacy and purpose that can be achieved by the present invention.

[0089] Please Figures 1 to 11As shown, the present invention provides a high-precision identification method and system for grains in clustered images, which adopts advanced image processing and machine learning algorithms to identify and classify crops such as rice grains, solving the challenges of rice variety identification and optimal cooking parameter matching, and can be applied to multiple categories of cooking utensils. By providing an accurate numerical reference of rice-water ratio, it provides users with a high-quality cooking experience. The method specifically includes the following steps: S1, obtaining original images of rice grains of cereal crops; S2, preprocessing the original images of rice grains to obtain a clustered rice grain image dataset; S3, segmenting the clustered rice grain image dataset to obtain a first rice grain image dataset containing rice grain images that meet a first rule; S4, standardizing the first rice grain image S5: Perform a first screening on the second rice-grain image dataset to remove rice-grain images that do not meet the morphological feature requirements, thereby obtaining a third rice-grain image dataset. S6: Combined with a pre-trained neural network, perform a second screening on the third rice-grain image dataset to select images that meet the completeness requirements, thereby obtaining a fourth rice-grain image dataset. S7: Based on the fourth rice-grain image dataset, trace the source and extract the original rice grain images corresponding to the fourth rice-grain image dataset to form a fifth rice-grain image dataset containing the original rice grain images. S8: Combined with the pre-trained neural network, perform type recognition on the original rice grain images in the fifth rice-grain image dataset and output a rice variety recognition result. The technical solution of the present invention can accurately identify the variety of grain rice grains and provide a numerical reference for the rice-water ratio in intelligent grain rice cooking.

[0090] The following describes the method and system for high-precision recognition of grain particles in aggregated images disclosed in the present invention in detail with reference to specific embodiments. The method and system for high-precision recognition of grain particles in aggregated images specifically include the following steps:

[0091] S1. Obtain original images of rice grains of cereal crops.

[0092] Among them, in an embodiment of the present invention, the application scenario of the high-precision recognition method and system for grain particles in a clustered image is a cooking appliance such as an electric rice cooker. The method is explained and analyzed below using rice as an example; the method for grain particle recognition first needs to obtain the original image of rice grains. For this cooking appliance, a high-precision image acquisition device needs to be set up. Through the grain rice grain image acquisition device, high-resolution, high-quality rice images are captured, providing a solid foundation for subsequent image analysis.

[0093] S2. Preprocess the original rice grain image to obtain a clustered rice grain image dataset.

[0094] Among them, factors such as transparency, morphological uniformity, and external lighting can increase the complexity of the image recognition process. Furthermore, the similar transparency and morphological characteristics of rice grains make edge detection and morphological analysis difficult. Furthermore, external influences such as lighting and reflections can further weaken the generalization capabilities of recognition models based on color and shape features. Therefore, step S2 requires preprocessing the acquired original rice grain image. In this embodiment of the present invention, the preprocessing is an image feature enhancement method to improve image recognition efficiency.

[0095] Specifically, in a specific embodiment of the present invention, step S2 specifically includes: S201, multi-scale Retinex enhancement: normalizing the original rice grain image, and using multiple Gaussian filters of different scales to process it, respectively generating corresponding filtered images; based on the difference between the original rice grain image and each filtered image, calculating the multi-scale Retinex enhancement result, and normalizing the output; S202, color space correction: converting the enhanced image to the LAB color space, performing offset correction on the mean of the color channel, and then converting it back to the RGB space; S203, global white balance and CLAHE enhancement: performing white balance gain adjustment based on the global mean of the RGB channels, and performing block adaptive histogram equalization processing on each channel to generate the final enhanced image.

[0096] In this embodiment, for step S2, the Gaussian scale σ1=15, σ2=80, σ3=250, the CLAHE sub-region M=5, the contrast limit threshold τ=1.0, the original rice grain image I(x, y) is preprocessed to obtain a clustered rice grain image dataset, which specifically includes the following steps: S201, multi-scale Retinex enhancement: normalize the original rice grain image I(x, y): I n (x,y)=I(x,y) / 255, and initialize the multi-scale Retinex enhancement result R msr (x, y) = 0; Gaussian filters with standard deviations σ1 = 15, σ2 = 80, and σ3 = 250 are used to filter I n (x,y) is filtered to obtain G1(x,y), G2(x,y), and G3(x,y); the Retinex components at each scale are calculated:

[0097]

[0098] After accumulation, R msr (x,y) is linearly normalized to the range of [0,255];

[0099] S202, color space correction: R msr (x,y) is converted to LAB color space, and the global mean μ of channels a and b is calculated. a 、μb , and then perform offset correction on the a and b channel values ​​of each pixel:

[0100] a′(x,y)=clip(a(x,y)+(128-μ a ),0,255)

[0101] b′(x,y)=clip(b(x,y)+(128-μ b ),0,255);

[0102] After correction, convert back to RGB space to obtain image C(x,y);

[0103] S203, global white balance and CLAHE enhancement: calculate the RGB three-channel mean μ of the image C(x,y) R 、μ G 、μ B , calculate the global mean μ avg =(μ R +μ G +μ B ) / 3, and adjust the gain of each channel:

[0104] γ c =μ avg / μ c (C∈{R,G,B})

[0105] E c (x,y)=clip(C c (x,y)·γ c ,0,255);

[0106] Then, for each channel, E c (x, y) is divided into M×M, i.e., 5×5 sub-regions, and the CLAHE algorithm is applied with a contrast limiting threshold τ=1.0 to finally synthesize the enhanced image E(x, y).

[0107] Among them, in an embodiment of the present invention, image enhancement includes three stages, specifically: multi-scale Retinex enhancement, color space correction, and global white balance and CLAHE enhancement; first, multi-scale Retinex enhancement aims to eliminate uneven illumination and enhance the dynamic range of the image. It integrates local and global illumination information through different Gaussian scales to avoid over-enhancement or detail loss caused by a single scale; secondly, color space correction is based on the adjustment of mean shift, which is simple and efficient and suitable for real-time processing. It aims to correct color cast and optimize color balance; finally, global white balance and CLAHE enhancement are performed. CLAHE block optimization is used, combined with global white balance and local contrast enhancement, taking into account natural tones and detail clarity, and performing global tone optimization and local contrast enhancement on the image.

[0108] S3. Segment the clustered rice grain image dataset to obtain a first rice grain image dataset containing rice grain images that meet a first rule.

[0109] In this embodiment of the present invention, the Rice Images Segmentation (RICESAM) model is used to cluster and segment rice images. This model uses a grain segmentation dataset, adjusts the mask adapter of the decoding module, and is trained based on a SAM fine-tuned neural network model. This RICESAM model enables zero-shot segmentation of rice images, significantly improving the efficiency of rice outline segmentation.

[0110] Specifically, in a specific embodiment of the present invention, step S3 specifically includes: S301, constructing a RICESAM model, inputting the clustered rice grain image dataset into the RICESAM model, and obtaining image embedding through the model's image encoder; S302, determining the segmentation hint information of the image, extracting its spatial features through a convolutional layer, and then encoding the spatial features into a hint embedding aligned with the image embedding based on the model's hint encoder; S303, according to the mask decoder of the RICESAM model, interactively combining the image embedding and the hint embedding to generate a segmentation mask of the image; S304, performing morphological screening on the segmentation mask to obtain the final mask output of the rice grain particles, and obtaining a rice grain mask image in which the rice grain particles are separated from the black background, that is, the first rice grain image dataset.

[0111] Among them, in an embodiment of the present invention, the RICESAM model consists of three core components: an image encoder, a prompt encoder, and a mask decoder. In the application stage, the parameters of the encoder and decoder remain frozen, and the clustered rice grain image set of rice is first feature-encoded by the image encoder to obtain image embedding, while the prompt encoder processes various prompt information including points, boxes, and texts, which are input into the mask decoder together with the mask information processed by the convolution layer to generate the final segmentation output, that is, the segmentation mask of the image. In order to further improve the quality of the mask output, morphological operations are performed on the segmentation mask after it is obtained. By changing the shape, connectivity, and boundary structure of the mask, its geometric features are optimized to make it more suitable for subsequent image processing tasks. Finally, according to the final mask, the rice grain mask image is obtained, as shown in FIG. Figure 8 As shown, the first rice grain image dataset is output.

[0112] S4. Standardize the first rice grain image dataset to construct a second rice grain image dataset of standard size.

[0113] Among them, step S4 is used to adjust the size data of the image. Since the rice grain mask image size output by the RICESAM model segmentation is 1280*720, and the standard size supported by the subsequent screening algorithm, that is, the rice grain mask image size in the first rice grain image dataset does not support the subsequent image screening algorithm, step S4 standardizes the first rice grain image dataset according to the standard size to eliminate the data deviation caused by the algorithm output difference and provide a unified size input for the subsequent algorithm.

[0114] Specifically, in a specific embodiment of the present invention, step S4 includes: S401, obtaining the numerical size of the rice grain mask image and the standard size of the standard image; S402, determining the geometric center position of the rice grain contour in the rice grain mask image, and aligning the geometric center with the center coordinates of its rice grain mask image; S403, obtaining the scaling ratio, scaling the rice grain contour to a black background of standard size to obtain a single rice grain image, and then outputting the single rice grain image dataset, i.e., the second rice grain image dataset.

[0115] In this embodiment, for the mask image of 1280×720 pixels and the discrete rice image, a ratio of f=2.08 is used to scale the rice outline to a black background of 250×250 pixels, as shown in FIG. Figure 8 As shown in (e) in the figure, 250×250 pixels are selected as the standard size, which is suitable for neural networks with different input size requirements, such as VGG-16 (input size 299×299 pixels) and MobileNetV2 (input size 224×224 pixels). The size of 250×25 pixels is a compromise between 299×299 and 224×224, which is convenient for resizing operations.

[0116] S5. Perform a first screening on the second rice grain image dataset to remove rice grain images that do not meet morphological feature requirements, and obtain a third rice grain image dataset.

[0117] After image segmentation, a large number of rice grain mask images are generated. Manually selecting these images is time-consuming and labor-intensive. Therefore, in this embodiment, an automated selection tool, Filter-I, based on rice grain morphological characteristics is developed, significantly improving efficiency and saving resources. Specifically, step S5 processes the large amount of mask data through automated means. Using Filter-I, a preliminary screening process is performed using the morphological characteristics of rice grains, avoiding the tedious process of manually examining each mask image one by one. Furthermore, a ratio analysis of rice grain morphological parameters and image conversion into wave analysis are used to eliminate abnormal image samples, reducing manual intervention and improving overall work efficiency.

[0118] Specifically, in a specific embodiment of the present invention, the step S5 specifically includes: S501, defining the morphological feature parameters of the complete rice grain through the complete rice grain image; S502, constructing a Filter-I algorithm based on morphological quantization according to the morphological feature parameters; S503, obtaining the rice grain mask image in the second rice grain image dataset, and then inputting the rice grain mask image into the Filter-I algorithm to extract the morphological feature parameters of each rice grain in the image; S504, presetting a parameter threshold, comparing and analyzing the morphological feature parameters of the rice grain with the parameter threshold, and filtering out the rice grain mask images that do not meet the parameter threshold requirements; S505, outputting the filtered and screened rice grain mask image, and merging it to obtain a third rice grain image dataset.

[0119] Specifically, in a specific embodiment of the present invention, the morphological characteristic parameters include: rice grain area aA, rice grain contour circumference aP, area-to-circumference ratio aR, major axis length maL of the fitted ellipse, minor axis length miL of the fitted ellipse, fitted ellipse area eA, fitted ellipse circumference eP, area difference aG, aspect ratio asR and ellipse roundness rD.

[0120] Specifically, in a specific embodiment of the present invention, in step S504, the method for comparing and analyzing the morphological characteristic parameters of the rice grains with the parameter thresholds includes: setting a threshold value range according to the category of the morphological characteristic parameters, determining whether the morphological characteristic parameters of the rice grains are within the threshold value range, and screening out samples with obviously abnormal values; performing a similarity analysis based on the complete rice grain outline and the actual rice grain outline characteristics, and screening out samples that do not meet the similarity requirements, wherein the similarity analysis method steps include:

[0121] Get the actual rice grain contour point set And calculate the actual rice grain contour centroid

[0122] Based on the actual rice grain outline centroid and the fitted ellipse centroid, the center distance of the actual rice grain outline is calculated. And the normalized matrix The formula is as follows:

[0123]

[0124] Then, based on the normalized matrix, the Hu matrix of the actual rice grain profile is obtained. Then, an ellipse is fitted according to the actual rice grain contour to generate a set of fitted ellipse points and calculate the centroid of the fitted ellipse contour. The above steps are then repeated to obtain the Hu matrix of the fitted ellipse. The Hu matrix of the actual rice grain outline and the Hu matrix of the fitted ellipse are combined to perform a similarity calculation to evaluate the matching degree between the rice grain outline and the fitted ellipse outline. The formula is as follows:

[0125]

[0126] Among them, in the embodiment of the present invention, in order to better describe the complete rice contour, a "W-shaped" method is proposed. The core of this method is to convert the complete rice contour edge into a waveform diagram described by digital means.

[0127] Specifically, in a specific embodiment of the present invention, the similarity analysis method further comprises: using a W-shaped algorithm to calculate the similarity, that is, converting the contour edge of the rice grain into a digitally described waveform, and then performing wave analysis to determine the degree of similarity; specifically comprising the following steps:

[0128] Get the centroid coordinates C(x c ,y c ):

[0129]

[0130] Among them, x i ,y i is the coordinate of the i-th point on the boundary of the rice grain, m i is the weight of the i-th point, N is the total number of rice grain outline boundary points; then the distance from the rice grain outline boundary point to the center of mass is calculated according to the Euclidean distance formula || P i C||:

[0131]

[0132] Calculate the adjacent points P on the rice grain contour i With P i-1 The segment length is used to obtain the cumulative arc length L. i :

[0133] L i =L i-1 +||P i P i-1 ||;

[0134] Among them, the initial cumulative arc length L0=0, the distance between adjacent points ||P i P i-1 ||Calculated by the following formula:

[0135]

[0136] Then the distance from the boundary point of the rice grain outline to the center of mass ||P i C|| is the vertical axis, the cumulative arc length L iA coordinate system is established for the horizontal axis, and a W-shaped curve is generated for the complete rice grain contour, i.e., a complete rice grain contour waveform diagram; according to the above steps, an actual rice grain contour waveform diagram is obtained, and wave analysis is performed based on the complete rice grain contour waveform diagram and the actual rice grain contour waveform diagram to quantify the rice grain contour characteristics and evaluate the degree of similarity.

[0137] like Figure 10 As shown in the figure, the "W-shaped" method is used to convert the rice grain outline into a waveform. This conversion not only preserves the integrity of the outline but also enhances the analysis of its boundary features. This method can amplify and intuitively reveal the subtle differences between rice grain outlines by highlighting the morphological changes in the outline, making the recognition process clearer and more efficient.

[0138] S6. Using a pre-trained neural network, perform a second screening on the third rice grain image dataset to select images that meet the integrity requirement, thereby obtaining a fourth rice grain image dataset.

[0139] Among them, step S6 is the second filtering mechanism in the rice grain variety recognition mechanism of this scheme. Since after the preliminary morphological screening using Filter-I, there may still be masks with irregular or abnormal shapes, these masks need to be further refined. To address this limitation, the present method proposes a lightweight neural network classifier, named Filter-II, to achieve the second screening of the third rice grain image data set, and to perform binary classification on the masks, dividing them into complete and incomplete categories, thereby ensuring the quality of the final segmentation result. In an embodiment of the present invention, Filter-II adopts a modular design, which can be flexibly decoupled from the main architecture, and the pluggable design concept enables it to be easily replaced and customized according to specific application requirements.

[0140] Specifically, in a specific embodiment of the present invention, the step S6 is specifically: based on a pre-trained neural network, the rice grain mask image after filtering and screening is subjected to binary classification, and the image is divided into a complete rice grain mask image and an incomplete rice grain mask image, and then the complete mask image is output to obtain a fourth rice grain image data set, which specifically includes the following steps: S601, constructing a neural network classification model, and pre-training the neural network classification model; S602, inputting the rice grain mask image into the neural network classification model, and the image first passes through a 32-channel, step-size 2 convolution layer to extract shallow features, and outputs a feature map with half the resolution and expanded channel number; S603, then based on the inverted residual structure, stacking multiple groups of bottleneck modules, and gradually extracting deep features of the feature map through multiple bottleneck modules; S604, finally performing channel expansion on the feature map through 1×1 convolution, compressing the feature map size by average pooling, mapping the number of image channels to the number of classification categories k through 1×1 convolution, and outputting the image classification result.

[0141] In this embodiment of the present invention, the resolution of the rice grain mask image is 224×224, and the number of channels is 3, that is, the graphic size and channel parameters are expressed as 224×224×3; in this embodiment, the neural network classification model is specifically a MobileNetV2 model, and the step of using the MobileNetV2 model to perform a second screening on the third rice grain image dataset includes: first inputting a 224×224×3 image, passing the image through a 32-channel, stride-size 2 convolution layer, and outputting a 112×112×32 image. This step can preliminarily capture the underlying features of the image, such as edges and textures; then stacking multiple groups of bottleneck modules to gradually extract deep features of the image, specifically: Stage 1 , the first bottleneck module uses an expansion factor of t = 1 to compress 32 channels to 16 channels, and optimizes features through depth-wise separable convolution 3×3DW convolution and 1×1PW convolution, which is expressed as: 112×112×32→112×112×16(bottleneck,\(t=1,c=16,n=1,s=1\)); Phase II, using an expansion factor of t=6, increases the 16 channels to 96 channels, performs a depth-wise convolution with a stride of 2, halves the feature map size to 56×56, and then compresses it to 24 channels. This stage is repeated twice, the second time maintaining the size and introducing residual connections to enhance feature reuse, which is expressed as: 112×112×16→56×56×24(b Bottleneck, \(t=6,c=24,n=2,s=2\)); Subsequent dimensionality reduction and feature deepening: By gradually adjusting the step size s=2 and the expansion factor t=6, the feature map size is reduced to 28×28, 14×14 and 7×7 respectively, while increasing the number of channels to 320. The first module of each dimensionality reduction stage is halved in size according to the step size 2. The subsequent modules are stacked through residual connections, and the 1×1 dimensionality reduction convolution at the end of each Bottleneck uses linear activation to gradually extract high-order semantic features of the image, expressed as: 56×56×24→28×28×32 (bottleneck, \(t=6,c=32,n=3,s=2\)), 28×28×32→1 4×14×64 (bottleneck, \(t=6,c=64,n=4,s=2\)), 14×14×64→14×14×96 (bottleneck, \(t=6,c=96,n=3,s=1\)), 14×14×96→7×7×160 (bottleneck, \(t=6,c=160,n=3,s=2\)), 7×7×160→7×7×320 (bottleneck, \(t=6,c=320,n=1,s=1\)); finally, the feature map is upscaled to 1280 channels through 1×1 convolution, and then subjected to 7×7 average pooling, and 1×1 convolution is used to output k channels, that is, the number of k classification categories.By adjusting the step size s to halve the size, repeating the stacking module n times to deepen the network, and the expansion factor t to balance the channel complexity, the process of input image classification is realized through this series of processes.

[0142] Specifically, in a specific embodiment of the present invention, the neural network classification model is trained by D-FTL step-by-step transfer learning based on a preset neural network model, and its specific steps include: setting initial parameters: pre-training the preset neural network model based on the ImageNet dataset, and then obtaining the weights of the neural network model to initialize the model; clustered rice grain image dataset training: based on the clustered rice grain image dataset and data enhancement technology, the initialized model is trained, all convolutional layers and fully connected layers are trained, and the weights of the clustered rice grain model are normalized by the mean and variance of the original rice grain image dataset to obtain the weights of the clustered rice grain model, and the number of neurons in the last fully connected layer is adjusted according to the number of rice grain categories; single grain rice image dataset training: based on the weights of the clustered rice grain model, the model training of the single grain rice image dataset is initialized, and the network parameters of the shallower layers of the neural network model are frozen during training, and only the deep network and fully connected layers are trained, and the number of neurons in the last fully connected layer is kept unchanged, and the model is optimized based on the single grain rice image dataset to obtain a neural network classification model for identifying rice grains.

[0143] The pre-set neural network models include: VGG16, DenseNet, MobileNet, RegNet, ResNet15, and ResNet50. In this embodiment of the present invention, VGG16 is selected as the neural network model for pre-training the neural network classification model. The pre-training process first uses pre-trained ImageNet models as a foundation and carefully fine-tunes these models on a clustered rice grain dataset to better adapt to the diverse data characteristics of rice grains. The optimized models are then used as the basis for pre-training and further trained on the Filter-II and L-MCNN models. This method reduces model volatility and instability that can occur when transferring directly from the pre-trained ImageNet model. We call this stepwise transfer learning method D-FTL, and during training, a cosine annealing strategy is used to adjust the learning rate. Cosine annealing simulates the annealing process by gradually cooling the system to a minimum energy state, thereby adjusting the learning rate.

[0144] S7. Based on the fourth rice grain image dataset, extract original rice grain images corresponding to the fourth rice grain image dataset by tracing back the source to form a fifth rice grain image dataset including the original rice grain images.

[0145] S8. In combination with a pre-trained neural network, perform type recognition on the original rice grain images in the fifth rice grain image dataset, and output a recognition result of the rice grain variety.

[0146] Specifically, the present invention also provides a high-precision recognition system for grains in clustered images, comprising: an image acquisition module for acquiring original images of rice grains of cereal crops; an image processing module connected to the image acquisition module; the image processing module comprising: an image preprocessing unit for enhancing the original images of rice grains to obtain a clustered rice grain image data set; an image segmentation unit connected to the image preprocessing unit, the image segmentation unit being used to segment the image to achieve rice grain size segmentation; an image standardization unit connected to the image segmentation unit for adjusting the image size; an image screening module connected to the image processing module; the image screening module comprising: a first screening unit , used to perform a first screening of the rice grain image according to the morphological characteristic parameters of the rice grain; a second screening unit connected to the first screening unit, the second screening unit is used to perform a second screening of the rice grain image after the first screening according to the completeness requirement; an image tracing module connected to the image screening module, the image tracing module is used to trace the output image of the second screening unit, and obtain the original rice grain image corresponding to the output image of the second screening unit; a rice grain image recognition module connected to the image tracing module, the rice grain image recognition module is used to identify and output the category of the rice grain in the image according to the neural network classification model; a model training module is used to establish and pre-train the neural network classification model.

[0147] Among them, such as Figure 11 As shown, in the embodiment of the present invention, the high-precision recognition system for grains in the aggregated image is mainly composed of an image acquisition module, an image processing module, a screening module, an image tracing module, a rice grain image recognition module and the model pre-training model. The entire system, each module or each unit in the module generally adopts a modular design and a pluggable design, which can be individually decoupled to upgrade performance or change use, so that each module or unit can be easily replaced and customized according to specific application requirements.

[0148] In summary, the high-precision recognition method and system for grain grains in aggregated images involved in the embodiments of the present invention have direct practical value in solving the challenges of rice variety identification and optimal cooking parameter matching, and can be applied to multiple categories of cooking utensils. By providing a numerical reference for an accurate rice-water ratio, it can provide users with a high-quality cooking experience. As for the high-precision recognition method for grain grains in aggregated images disclosed in the present invention, it can significantly improve the recognition accuracy and acquisition efficiency of grain grains by adopting advanced image processing and machine learning algorithms to identify and classify rice grains of cereal crops; wherein, the high-precision recognition method for grain grains in aggregated images mainly includes eight steps: the first step is to obtain the original image of rice grains of cereal crops, which is mainly performed by high-precision image acquisition equipment; the second step is to pre-process the image after obtaining the original image of the rice grains, enhance the image features, improve the recognition efficiency of the image, and obtain a rich image of rice grains. The first step is to cluster the rice grain image dataset of the grain image; the third step is to segment the original rice grain image, and use the image segmentation model to extract the independent rice grain contour image to obtain the first rice grain image dataset, thereby realizing zero-sample segmentation of the grain image and significantly improving the efficiency of rice grain contour segmentation; since the rice grain mask image size in the first rice grain image dataset does not support the subsequent image screening algorithm, step S4 is to standardize the first rice grain image dataset according to the standard size, eliminate the data deviation caused by the difference in algorithm output, and provide a unified size input for the subsequent algorithm; the fifth and sixth steps are to use deep learning to The algorithm screens the rice grain mask image, wherein step S5 uses a neural network classification algorithm to perform a morphological feature parameter ratio analysis on the rice grain mask image to achieve the first screening of the image and remove the rice grain images that do not meet the morphological feature requirements; since after the initial screening, there will still be irregular or abnormal masks that need to be further refined, step S6 combines the integrity difference of the rice grains for a second classification, specifically, based on the third rice grain image data set after the first screening, the rice grain mask image is subjected to a second screening process, achieving two filtering processes on the rice grain mask image to ensure the final image segmentation result. Quality; Next, for step S7, the fourth rice grain image data set after screening is traced to obtain the original rice grain image corresponding to the fourth rice grain image data, and the variety identification is performed using the original rice grain image, which not only retains the complete rice grain image feature information, so that the model has both high precision and strong generalization ability, but also avoids the risk of image distortion and impact on recognition results when directly using the rice grain mask image for recognition; the last step is to identify the rice grain variety, and identify the original rice grain image after tracing through the neural network classification model, and output the rice grain variety identification result, so as to achieve accurate identification of cereal rice grains.It can be seen that the technical solution involved in the present invention, compared with the existing technology, can accurately identify the varieties of cereal rice grains, provide a numerical reference for the rice-water ratio for intelligent cooking of cereal rice grains, provide important reference value for the precise classification of rice varieties in agriculture and food industries, and provide new technical means for the intelligent development of related fields.

[0149] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A high-precision method for identifying grains in aggregated images, characterized in that: The following steps are involved: S1, obtaining the original image of rice grains of cereal crops; S2. Preprocessing the original rice grain image to obtain a clustered rice grain image dataset; S3, performing segmentation processing on the clustered rice grain image dataset to obtain a first rice grain image dataset containing rice grain images that meet a first rule; S4. Standardize the first rice grain image dataset to construct a second rice grain image dataset of standard size; S5. Perform a first screening on the second rice grain image dataset to remove rice grain images that do not meet morphological feature requirements, thereby obtaining a third rice grain image dataset; S6. Perform a second screening on the third rice grain image dataset using a pre-trained neural network to select images that meet the integrity requirement, thereby obtaining a fourth rice grain image dataset. S7. Extracting, based on the fourth rice-grain image dataset, original rice-grain images corresponding to the fourth rice-grain image dataset by tracing back to their source, to form a fifth rice-grain image dataset including the original rice-grain images; S8. In combination with a pre-trained neural network, perform type recognition on the original rice grain images in the fifth rice grain image dataset, and output a recognition result of the rice grain variety.

2. The high-precision method for identifying grains in aggregated images according to claim 1, characterized in that: The step S2 specifically includes: S201, multi-scale Retinex enhancement: normalizing the original rice grain image and processing it using multiple Gaussian filters of different scales to generate corresponding filtered images; Based on the difference between the original rice grain image and each filtered image, a multi-scale Retinex enhancement result is calculated and normalized and outputted; S202, color space correction: converting the enhanced image to LAB color space, performing offset correction on the mean of the color channels, and then converting back to RGB space; S203, global white balance and CLAHE enhancement: white balance gain adjustment is performed based on the global mean of the RGB channels, and block adaptive histogram equalization processing is performed on each channel to generate the final enhanced image.

3. The high-precision method for identifying grains in aggregated images according to claim 1, characterized in that: Step S3 specifically includes: S301, constructing a RICESAM model, inputting the clustered rice grain image dataset into the RICESAM model, and obtaining image embedding through the model's image encoder; S302, determining segmentation hint information of the image, extracting its spatial features through a convolutional layer, and then encoding the spatial features into a hint embedding aligned with the image embedding based on a model hint encoder; S303, according to the mask decoder of the RICESAM model, interactively combining the image embedding and the hint embedding to generate a segmentation mask of the image; S304 : Perform morphological screening on the segmentation mask to obtain a final mask output of the rice grains, thereby obtaining a rice grain mask image in which the rice grains are separated from the black background, that is, a first rice grain image dataset.

4. The high-precision method for identifying grains in aggregated images according to claim 3, characterized in that: The step S4 specifically includes: S401, obtaining the numerical size of the rice grain mask image and the standard size of the standard image; S402, determining the geometric center position of the rice grain outline in the rice grain mask image, and aligning the geometric center with the center coordinates of the rice grain mask image; S403 , obtaining a scaling ratio, scaling the rice grain outline to a black background of a standard size, obtaining a single rice grain image, and then outputting the single rice grain image dataset, i.e., a second rice grain image dataset.

5. The high-precision method for identifying grains in aggregated images according to claim 4, characterized in that: The step S5 specifically includes: S501. Defining morphological characteristic parameters of a complete rice grain based on a complete rice grain image, wherein the morphological characteristic parameters include: rice grain area aA, rice grain outline perimeter aP, area-to-perimeter ratio aR, major axis length maL of the fitted ellipse, minor axis length miL of the fitted ellipse, fitted ellipse area eA, fitted ellipse perimeter eP, area difference aG, aspect ratio asR, and ellipse circularity rD. S502, constructing a Filter-I algorithm based on morphological quantification according to the morphological feature parameters; S503: Acquire the rice grain mask image from the second rice grain image dataset, and then input the rice grain mask image into the Filter-I algorithm to extract morphological feature parameters of each rice grain in the image; S504: Preset a parameter threshold, compare and analyze the morphological characteristic parameters of the rice grains with the parameter threshold, and filter out the rice grain mask images that do not meet the parameter threshold requirement; S505: Output the filtered rice grain mask image and merge it to obtain a third rice grain image dataset.

6. The high-precision method for identifying grains in aggregated images according to claim 5, characterized in that: In step S504, the method of comparing and analyzing the morphological characteristic parameters of the rice grains with the parameter thresholds includes: According to the category of the morphological characteristic parameter, a threshold value range is set to determine whether the morphological characteristic parameter of the rice grain is within the threshold value range, and samples with obviously abnormal values ​​are screened out; A similarity analysis is performed based on the complete rice grain profile and the actual rice grain profile characteristics to screen out samples that do not meet the similarity requirements, wherein the similarity analysis method comprises the following steps: Get the actual rice grain contour point set And calculate the actual rice grain contour centroid Based on the actual rice grain outline centroid and the fitted ellipse centroid, the center distance of the actual rice grain outline is calculated. And the normalized matrix The formula is as follows: Then, based on the normalized matrix, the Hu matrix of the actual rice grain profile is obtained. Fit an ellipse according to the actual rice grain outline to generate a set of fitted ellipse points and calculate the centroid of the fitted ellipse outline. Repeat the above steps to obtain the Hu matrix of the fitted ellipse. The Hu matrix of the actual rice grain outline and the Hu matrix of the fitted ellipse are combined to perform a similarity calculation to evaluate the matching degree between the rice grain outline and the fitted ellipse outline. The formula is as follows:

7. The high-precision method for identifying grains in aggregated images according to claim 6, characterized in that: The similarity analysis method further comprises the following steps: calculating the similarity using a W-shaped algorithm, that is, converting the rice grain outline edge into a digitally described waveform, and then performing wave analysis to determine the degree of similarity; specifically, the following steps: Get the centroid coordinates C(x c ,y c ): Among them, x i ,y i is the coordinate of the i-th point on the boundary of the rice grain, m i is the weight of the i-th point, N is the total number of rice grain contour boundary points; Then the distance from the boundary point of the rice grain contour to the center of mass is calculated according to the Euclidean distance formula || P i C||: Calculate the adjacent points P on the rice grain contour i With P i-1 The segment length is used to obtain the cumulative arc length L. i : L i =L i-1 +||P i P i-1 ||; Among them, the initial cumulative arc length L0=0, the distance between adjacent points ||P i P i-1 ||Calculated by the following formula: Then the distance from the boundary point of the rice grain outline to the center of mass ||P i C|| is the vertical axis, the cumulative arc length L i A coordinate system is established for the horizontal axis, and a W-shaped curve is generated for the complete rice grain outline, i.e., a complete rice grain outline waveform diagram; According to the above steps, an actual rice grain contour waveform is obtained, and wave analysis is performed based on the complete rice grain contour waveform and the actual rice grain contour waveform to quantify rice grain contour features and evaluate the degree of similarity.

8. The high-precision method for identifying grains in aggregated images according to claim 5, characterized in that: The step S6 is specifically as follows: Based on a pre-trained neural network, the filtered rice grain mask image is subjected to binary classification to divide the image into a complete rice grain mask image and an incomplete rice grain mask image, and then the complete mask image is output to obtain a fourth rice grain image dataset, which specifically includes the following steps: S601, constructing a neural network classification model, and pre-training the neural network classification model; S602: Inputting a rice grain mask image into the neural network classification model, first passing the image through a 32-channel, stride-2 convolutional layer to extract shallow features, and outputting a feature map with half the resolution and an expanded number of channels; S603: Based on the inverted residual structure, stack multiple groups of bottleneck modules, and gradually extract deep features of the feature map through the multiple bottleneck modules; S604: Then, the feature map is expanded through 1×1 convolution, and the feature map size is compressed by average pooling. Then, the number of image channels is mapped to the number of classification categories k through 1×1 convolution, and the image classification result is output.

9. The high-precision method for identifying grains in aggregated images according to claim 8, characterized in that: The neural network classification model is trained by D-FTL step-by-step transfer learning based on a preset neural network model, and the specific steps include: Set initial parameters: Pre-train the neural network model based on the ImageNet dataset, and then obtain the neural network model weights to initialize the model; Training on the clustered rice grain image dataset: Based on the clustered rice grain image dataset and data augmentation techniques, the initialization model is trained. All convolutional and fully connected layers are trained. The weights of the clustered rice grain model are normalized using the mean and variance of the original rice grain image dataset. The number of neurons in the last fully connected layer is adjusted based on the number of rice grain categories. Single-grain rice image dataset training: Based on the weights of the clustered rice grain model, model training for the single-grain rice grain image dataset is initialized. During training, the network parameters of the shallower layers of the neural network model are frozen, and only the deep network and fully connected layers are trained. The number of neurons in the last fully connected layer is kept unchanged. The model is optimized based on the single-grain rice grain image dataset to obtain a neural network classification model for identifying rice grains.

10. A high-precision method for identifying grains in aggregated images, characterized in that: include: An image acquisition module, used for acquiring original images of rice grains of cereal crops; an image processing module connected to the image acquisition module; The image processing module includes: an image preprocessing unit for enhancing the original rice grain image to obtain a clustered rice grain image dataset; an image segmentation unit connected to the image preprocessing unit, for segmenting the image to achieve rice grain size segmentation; and an image standardization unit connected to the image segmentation unit for adjusting the image size. an image screening module connected to the image processing module; The image screening module includes: a first screening unit for performing a first screening on the rice grain image according to the rice grain morphological characteristic parameters; a second screening unit connected to the first screening unit, and the second screening unit is used to perform a second screening on the rice grain image after the first screening according to the integrity requirement; an image tracing module connected to the image screening module, the image tracing module being configured to perform tracing processing on the image output by the second screening unit to obtain an original image of rice grains corresponding to the image output by the second screening unit; a rice grain image recognition module connected to the image tracing module, the rice grain image recognition module being configured to recognize and output the category of rice grains in the image based on a neural network classification model; The model training module is used to establish and pre-train the neural network classification model.