Rice grading method, device, equipment and storage medium

By performing hyperspectral image processing and application of density prediction network model on rice, the problems of low efficiency and low accuracy of manual grading are solved, and efficient and accurate results of rice grading are achieved.

CN114387226BActive Publication Date: 2025-02-14CHINA UNITED NETWORK COMM GRP CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111593155.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-23
Publication Date
2025-02-14
Estimated Expiration
2041-12-23

AI Technical Summary

Technical Problem

The existing rice grading mainly relies on manual observations, with low efficiency and inaccurate results.

Method used

By acquiring the initial hyperspectral image of rice, pre-processing, the image is input to the trained rice density prediction network model, the rice density information is output, and the rice level is determined based on the density information.

Benefits of technology

It improves the efficiency and accuracy of rice grading, reduces manual intervention, and achieves more unified and reliable grading results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114387226B_ABST
    Figure CN114387226B_ABST
Patent Text Reader

Abstract

The present application provides a rice grade classification method, device, equipment and storage medium. The method comprises: pre-processing the initial hyperspectral image of rice to obtain the hyperspectral image of rice to be detected; inputting the hyperspectral image of rice to be detected into the trained rice density prediction network model, and outputting the rice density information corresponding to the hyperspectral image of rice; determining the weight of each type of rice corresponding to the hyperspectral image of rice according to the rice density information corresponding to the hyperspectral image of rice; and determining the rice grade corresponding to the hyperspectral image of rice according to the weight of each type of rice corresponding to the hyperspectral image of rice. The method of the present application adopts the pre-trained rice density prediction network model, can obtain relatively accurate rice density information, further determine the weight of each type of rice according to the density information, and thus determine the rice grade according to the weight of each type of rice, without the need for workers to manually classify, which not only improves the classification efficiency, but also effectively improves the classification accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of rice quality detection, and in particular to a rice grading method, device, equipment and storage medium. Background Art

[0002] Rice is rich in nutrients, mainly containing water, carbohydrates, proteins, lipids, minerals and vitamins, etc. During the processing of rice, it needs to go through the following processes: raw grain collection, raw grain cleaning, ridge-grain separation, rice-rough separation, rice milling, white rice grading, color sorting, polishing, white rice grading, finished rice packaging, storage and transportation.

[0003] During the rice production process, rice needs to be graded. The rice quality grade is based on small broken rice, imperfect grains, etc. Rice is usually divided into four grades: grade one, grade two, grade three and grade four. The existing rice grading is mainly based on manual grading. The graders observe the appearance of the rice with the naked eye to grade the rice.

[0004] Although the manual grading method is simple and low-cost, it mainly depends on the subjectivity of each grader, and the grading results obtained are not uniform and accurate enough, and the efficiency of manual grading is low. Summary of the invention

[0005] The present application provides a rice grading method, device, equipment and storage medium, which are used to solve the problem that the existing method of manually grading rice is low in efficiency and the grading results are not accurate enough.

[0006] In a first aspect, the present application provides a rice grading method, comprising:

[0007] Acquire an initial hyperspectral image of rice, and preprocess the initial hyperspectral image of rice to obtain a hyperspectral image of rice to be detected;

[0008] Inputting the rice hyperspectral image to be detected into the trained rice density prediction network model, and outputting the rice density information corresponding to the rice hyperspectral image;

[0009] Determine the weight of various types of rice corresponding to the rice hyperspectral image according to the rice density information corresponding to the rice hyperspectral image;

[0010] The rice grade corresponding to the rice hyperspectral image is determined according to the weight of each type of rice corresponding to the rice hyperspectral image.

[0011] Optionally, the preprocessing of the initial rice hyperspectral image to obtain the rice hyperspectral image to be detected comprises:

[0012] Obtaining a rice all-white calibration image and a rice all-black calibration image, and obtaining a calibrated rice hyperspectral image according to the rice all-white calibration image, the rice all-black calibration image and the rice initial hyperspectral image;

[0013] The corrected rice hyperspectral image is processed with data redundancy elimination and filtering to obtain the rice hyperspectral image to be detected.

[0014] Optionally, determining the weight of each type of rice corresponding to the rice hyperspectral image according to the rice density information corresponding to the rice hyperspectral image includes:

[0015] Determine various rice profile information corresponding to the rice hyperspectral image;

[0016] The weights of various types of rice corresponding to the rice hyperspectral image are determined according to the rice density information corresponding to the rice hyperspectral image and the contour information of various types of rice corresponding to the rice hyperspectral image.

[0017] Optionally, determining various types of rice profile information corresponding to the rice hyperspectral image includes:

[0018] Obtain a rice RGB color mode image according to the rice hyperspectral image, input the rice RGB color mode image into a trained rice category detection network model, and output the position information of each grain of rice and the category information of each grain of rice corresponding to the rice RGB color mode image;

[0019] Perform image segmentation processing on the rice RGB color mode image to obtain the contour information of each rice grain;

[0020] According to the position information of each grain of rice, the category information of each grain of rice and the contour information of each grain of rice, the contour information of each grain of rice is obtained.

[0021] Optionally, determining the rice grade corresponding to the rice hyperspectral image according to the weights of various types of rice corresponding to the rice hyperspectral image comprises:

[0022] Determine the total weight of all rice corresponding to the rice hyperspectral image according to the weight of each type of rice corresponding to the rice hyperspectral image, and calculate the ratio of the total weight of each type of abnormal rice corresponding to the rice hyperspectral image to the total weight of all rice to obtain the proportion corresponding to each type of abnormal rice;

[0023] The corresponding proportions of each type of abnormal rice are compared with the corresponding thresholds of each type of abnormal rice, and the rice grade is determined based on the comparison results.

[0024] Optionally, before inputting the rice hyperspectral image to be detected into a trained rice density prediction network model and outputting the rice density corresponding to the rice hyperspectral image, the method further comprises:

[0025] Selecting a rice sample hyperspectral image from a training data set, inputting the rice sample hyperspectral image into a preset rice density prediction network model, and outputting rice prediction density information corresponding to the rice sample hyperspectral image;

[0026] Determine the predicted total weight of rice corresponding to each image according to the predicted rice density information, and determine a first rice weight loss value according to the predicted total weight of rice corresponding to each image;

[0027] Determine the network loss function value according to the first rice weight loss value, and update the network weight parameter corresponding to the network loss function until the number of iterations reaches a preset number of iterations;

[0028] The preset rice density prediction network model corresponding to the network weight parameter corresponding to the minimum network loss function is determined as the optimal rice density prediction network model, and the optimal rice density prediction network model is tested to obtain a second rice weight loss value;

[0029] If the second rice weight loss value is less than or equal to the preset loss value, the optimal rice density prediction network model is determined as the trained rice density prediction network model.

[0030] Optionally, determining the predicted total weight of rice corresponding to each image according to the predicted rice density information includes:

[0031] Determine each type of rice contour information corresponding to each image, and determine the predicted total weight of rice corresponding to each image according to the predicted rice density information and the various types of rice contour information corresponding to each image.

[0032] In a second aspect, the present application provides a rice grading device, comprising:

[0033] A preprocessing unit is used to obtain an initial hyperspectral image of rice, and preprocess the initial hyperspectral image of rice to obtain a hyperspectral image of rice to be detected;

[0034] A prediction unit, used for inputting the rice hyperspectral image to be detected into a trained rice density prediction network model, and outputting rice density information corresponding to the rice hyperspectral image;

[0035] A determination unit, used to determine the weight of various types of rice corresponding to the rice hyperspectral image according to the rice density information corresponding to the rice hyperspectral image;

[0036] The determination unit is further used to determine the rice grade corresponding to the rice hyperspectral image according to the weights of various types of rice corresponding to the rice hyperspectral image.

[0037] In a third aspect, the present invention provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;

[0038] The memory stores computer-executable instructions;

[0039] The processor executes the computer-executable instructions stored in the memory to implement the method as described in the first aspect.

[0040] In a fourth aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method described in the first aspect.

[0041] The present application provides a rice grading method, device, equipment and storage medium. The method comprises the following steps: obtaining an initial hyperspectral image of rice, preprocessing the initial hyperspectral image of rice to obtain a hyperspectral image of rice to be detected; inputting the hyperspectral image of rice to be detected into a trained rice density prediction network model, and outputting rice density information corresponding to the hyperspectral image of rice; further determining the weights of various types of rice corresponding to the hyperspectral image of rice according to the rice density information corresponding to the hyperspectral image of rice; thereby determining the rice grade corresponding to the hyperspectral image of rice according to the weights of various types of rice corresponding to the hyperspectral image of rice, using a pre-trained rice density prediction network model to obtain relatively accurate rice density information, further determining the weights of various types of rice according to the density information, and thereby determining the rice grade according to the weights of various types of rice, without the need for manual classification by workers, thereby not only improving the classification efficiency, but also effectively improving the classification accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0043] Figure 1 Schematic diagram of the network architecture of the rice grade classification method provided by the present invention;

[0044] Figure 2 1 is a flow chart of a rice grade classification method provided in Embodiment 1 of the present invention;

[0045] Figure 3 is a schematic diagram of a flow chart of a rice grade classification method provided in Embodiment 2 of the present invention;

[0046] Figure 4 1 is a schematic diagram of a process for classifying rice grades provided in Embodiment 3 of the present invention;

[0047] Figure 5 is a schematic flow chart of a rice grade classification method provided in Embodiment 4 of the present invention;

[0048] Figure 6 is a schematic diagram of a flow chart of a rice grade classification method provided in Embodiment 5 of the present invention;

[0049] Figure 7 1 is a flow chart of a rice grade classification method provided in Embodiment 6 of the present invention;

[0050] Figure 8 is a schematic diagram of the structure of a rice grade classification device provided by an embodiment of the present invention;

[0051] Fig. 9 The present invention is a block diagram of an electronic device for implementing the rice grading method according to an embodiment of the present invention.

[0052] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0053] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0054] In order to clearly understand the technical solution of the present application, the solution of the prior art is first introduced in detail.

[0055] During the rice processing, it needs to go through the following processes: raw grain collection, raw grain cleaning, ridge and rice separation, rice milling, white rice grading, color sorting, polishing, white rice grading, finished rice packaging, storage and transportation. The rice quality grade is based on small broken rice, imperfect grains, etc. as grade indicators. Rice is usually divided into four grades: grade one, grade two, grade three and grade four. The existing rice grading is mainly based on manual grading. The graders observe the appearance of the rice with the naked eye to grade the rice.

[0056] The basic manual grading method is relatively simple and low-cost, but manual grading mainly depends on the subjectivity of each grader, resulting in different grading results obtained by multiple graders, making the grading results inconsistent and inaccurate, and the efficiency of manual grading is low.

[0057] Therefore, in order to solve the problem that the manual classification of rice grades in the prior art is inefficient and the grading results are not accurate enough, the inventors found in the research that the initial hyperspectral image of rice is preprocessed to obtain a hyperspectral image of rice to be detected, the hyperspectral image of rice to be detected is output to a trained rice density prediction network model, the rice density information corresponding to the hyperspectral image of rice is output, the weight of each type of rice in the hyperspectral image of rice is determined according to the rice density information, and the rice grade corresponding to the hyperspectral image of rice is determined according to each type of rice weight. By using the pre-trained rice density prediction network model, relatively accurate rice density information can be obtained, and the weight of each type of rice is further determined according to the density information, so as to determine the rice grade according to each type of rice weight, without the need for workers to manually classify, which not only improves the classification efficiency but also effectively improves the classification accuracy.

[0058] Therefore, based on the above creative findings, the inventors have proposed a technical solution of the embodiment of the present invention. The network architecture and application scenarios of the rice grade classification method provided by the embodiment of the present invention are introduced below.

[0059] like Figure 1 As shown, the network architecture corresponding to the rice grade classification method provided by the embodiment of the present invention includes: an electronic device 1, a hyperspectral camera 2 and a detection platform 3. The electronic device 1 is connected to the hyperspectral camera 2 for communication. The rice is spread on the detection platform 3 with a black background in advance, and there is no overlap between the rice grains. The electronic device 1 sends a shooting instruction to the hyperspectral camera 2, and the hyperspectral camera 2 shoots the rice on the detection platform 3 according to the shooting instruction to obtain an initial hyperspectral image of the rice. The electronic device 1 obtains the initial hyperspectral image of the rice shot by the hyperspectral camera 2, and the electronic device 1 pre-processes the initial hyperspectral image of the rice to obtain a hyperspectral image of the rice to be detected, and further inputs the hyperspectral image of the rice to be detected into the trained rice density prediction network model, and outputs the rice density information corresponding to the rice hyperspectral image; further determines the weight of each type of rice corresponding to the rice hyperspectral image according to the rice density information corresponding to the rice hyperspectral image; and determines the rice grade corresponding to the rice hyperspectral image according to the weight of each type of rice corresponding to the rice hyperspectral image. By using a pre-trained rice density prediction network model, we can obtain more accurate rice density information, and further determine the weight of each type of rice based on the density information, thereby determining the rice grade based on the weight of each type of rice. This eliminates the need for workers to manually classify the rice, which not only improves the classification efficiency, but also effectively improves the classification accuracy.

[0060] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings.

[0061] Embodiment 1

[0062] Figure 2 : is a schematic diagram of a flow chart of a rice grade classification method provided in Embodiment 1 of the present invention, such as Figure 2 As shown, the rice grade classification method provided in this embodiment is performed by a rice grade classification device, and the rice grade classification device is located in an electronic device. The rice grade classification method provided in this embodiment includes the following steps:

[0063] Step 101, obtaining an initial hyperspectral image of rice, and preprocessing the initial hyperspectral image of rice to obtain a hyperspectral image of rice to be detected.

[0064] In this embodiment, rice is spread on a detection table with a black background without overlapping between rice grains, a hyperspectral image of the rice is captured by a hyperspectral camera to obtain an initial hyperspectral image of the rice, and the initial hyperspectral image of the rice is preprocessed, the preprocessing includes image correction, data redundancy elimination and filtering and denoising, and a hyperspectral image of the rice to be detected is obtained.

[0065] Step 102: input the rice hyperspectral image to be detected into the trained rice density prediction network model, and output rice density information corresponding to the rice hyperspectral image.

[0066] In this embodiment, the rice hyperspectral image to be detected is input into the trained rice density prediction network model, and the rice density information corresponding to the rice hyperspectral image is output, wherein the rice density information includes the rice density image and the rice density value.

[0067] Step 103: determining the weight of each type of rice corresponding to the rice hyperspectral image according to the rice density information corresponding to the rice hyperspectral image.

[0068] In this embodiment, rice categories include broken rice, chalky rice, yellow rice, diseased rice, heavy chalky rice and normal rice. The rice to be detected may include broken rice, chalky rice, yellow rice, diseased rice, heavy chalky rice and normal rice. The weight of each type of rice corresponding to the rice hyperspectral image is determined according to rice density information corresponding to the rice hyperspectral image and contour information of each type of rice corresponding to the rice hyperspectral image.

[0069] Step 104: determining the rice grade corresponding to the rice hyperspectral image according to the weights of various types of rice corresponding to the rice hyperspectral image.

[0070] In this embodiment, the total weight of rice in the rice hyperspectral image is calculated according to the weights of various types of rice corresponding to the rice hyperspectral image, the proportion of the weights of various types of rice to the total weight of rice is calculated, and the grade of rice corresponding to the rice hyperspectral image is determined according to the proportion of the weights of various types of rice to the total weight of rice. For example, the grade of rice is determined according to the proportion of broken rice, yellow grains, diseased spots, and heavy chalk.

[0071] In this embodiment, the initial hyperspectral image of rice is preprocessed to obtain a hyperspectral image of rice to be detected, the hyperspectral image of rice to be detected is output to a trained rice density prediction network model, rice density information corresponding to the rice hyperspectral image is output, the weight of each type of rice in the rice hyperspectral image is determined according to the rice density information, and the rice grade corresponding to the rice hyperspectral image is determined according to the weight of each type of rice. By using the pre-trained rice density prediction network model, relatively accurate rice density information can be obtained, and the weight of each type of rice is further determined according to the density information, so as to determine the rice grade according to the weight of each type of rice, and workers do not need to perform manual classification, which not only improves the classification efficiency but also effectively improves the classification accuracy.

[0072] Embodiment 2

[0073] Figure 3 : is a schematic diagram of a flow chart of a rice grade classification method provided in Embodiment 2 of the present invention, such as Figure 3 As shown, based on the rice grading method provided in the first embodiment of the present invention, the step 101 of preprocessing the initial hyperspectral image of rice to obtain the hyperspectral image of rice to be detected is further refined, including:

[0074] Step 1011, obtaining a rice all-white calibration image and a rice all-black calibration image, and obtaining a calibrated rice hyperspectral image according to the rice all-white calibration image, the rice all-black calibration image and the rice initial hyperspectral image.

[0075] In this embodiment, in the hyperspectral imaging system, there are problems such as dark current noise that will affect the quality of the hyperspectral image. In order to reduce the interference of other irrelevant factors, the initial hyperspectral image of rice is subjected to black and white correction. Specifically, the black and white correction refers to collecting a full white calibration image with a standard white board, then covering the lens cover, turning off the light source to collect a full black calibration image, and the black and white correction formula is as follows:

[0076]

[0077] Among them, I is the corrected rice hyperspectral image, I0 is the initial rice hyperspectral image, B is the all-black calibration image, and W is the all-white calibration image.

[0078] Step 1012, performing data redundancy elimination processing and filtering and denoising processing on the corrected rice hyperspectral image in sequence to obtain a rice hyperspectral image to be detected.

[0079] In the present embodiment, the data redundancy reduction process is carried out successively to the high-spectral image of rice after correction, and the high-spectral imaging technology is an image data technology based on numerous narrow bands, and the high-spectral image it obtains is a continuous, narrow-band image data of a high spectral resolution, for example, 470nm-960nm is divided into 150 narrow bands. Therefore, what the high-spectral camera obtains is a data cube, which not only has image information, but also expands in the spectral dimension, and as a result, not only can the spectral data of each point on the image be obtained, but also the image information of any spectral band can be obtained. Therefore, the high-spectral data has the characteristics of many bands and large data volume, and there are data collinearity problems and a large amount of redundant invalid information in these data at the same time, which will increase the workload of subsequent data processing and modeling, and the Hughes phenomenon (Hughes phenomenon refers to the phenomenon that the model accuracy increases first and then decreases in the high-spectral analysis process, as the number of bands involved in the operation increases, and the model accuracy increases first and then decreases) with low modeling efficiency and poor model performance may also occur. So before applying the high-spectral data, it is usually necessary to perform data redundancy reduction operations on it, i.e., dimensionality reduction operations. At present, there are two main methods for reducing the dimension of hyperspectral data: one is to select some bands with large information content, low noise and strong representativeness from many bands for post-processing; the other is to compress many bands through some mathematical transformations, and try to compress most of the information of the sample within a certain band interval, and discard the bands with less information. Commonly used methods include principal component analysis, competitive adaptive reweighted sampling (CARS), successive projection algorithm (SPA), uninformative variable elimination (UVE), shuffled frog leaping algorithm (SFLA), etc.

[0080] In this embodiment, the hyperspectral image after data redundancy processing is subjected to filtering and denoising, and filtering and denoising is used to remove image noise to prevent image noise from interfering with subsequent calculations. Specifically, we use opening and closing operations to denoise the spectral images of several characteristic wavelengths respectively. The image opening and closing operations are composed of two operations: expansion and erosion. The opening operation is to corrode the image first and then expand it, which is used to smooth the contour of the object, remove small particle noise, and disconnect the adhesion between objects. The closing operation is the process in which the image is sequentially expanded and eroded, which can fill small holes inside the object, connect disconnected contours, etc.

[0081] Embodiment 3

[0082] Figure 4: is a schematic diagram of a flow chart of a rice grade classification method provided in Embodiment 3 of the present invention, such as Figure 4 As shown, based on the rice grade classification method provided in the first embodiment of the present invention, step 103 is further refined, specifically including the following steps:

[0083] Step 1031, determining various types of rice profile information corresponding to the rice hyperspectral image.

[0084] In this embodiment, the contour information of each grain of rice, the position information of each grain of rice and the category information of each grain of rice in the rice hyperspectral image are obtained, and the contour information of each type of rice corresponding to the rice hyperspectral image is determined according to the contour information of each grain of rice, the position information of each grain of rice and the category information of each grain of rice.

[0085] Step 1032: determine the weight of each type of rice corresponding to the rice hyperspectral image according to the rice density information corresponding to the rice hyperspectral image and the contour information of each type of rice corresponding to the rice hyperspectral image.

[0086] In this embodiment, the rice categories include abnormal rice and normal rice, wherein the abnormal rice includes broken rice, chalky rice, yellow rice, diseased rice, and heavy chalky rice, and the normal rice refers to rice with a normal appearance and no damage. The weight of each type of rice, i.e., the weight of each type of abnormal rice and the weight of normal rice, are determined according to the rice density information corresponding to the rice hyperspectral image and the contour information of each type of rice corresponding to the rice hyperspectral image.

[0087] Embodiment 4

[0088] Figure 5 : is a schematic diagram of a flow chart of a rice grade classification method provided in Embodiment 4 of the present invention, such as Figure 5 As shown, based on the rice grade classification method provided in the third embodiment of the present invention, step 1031 is further refined, specifically including the following steps:

[0089] Step 1031a, obtaining a rice RGB color mode image according to the rice hyperspectral image, inputting the rice RGB color mode image into a trained rice category detection network model, and outputting the position information of each grain of rice and the category information of each grain of rice corresponding to the rice RGB color mode image.

[0090] In the present embodiment, the rice hyperspectral image is extracted to obtain the rice RGB color mode image, the RGB color mode image is input into the trained rice category detection network model, and the position information of each grain of rice corresponding to the rice RGB color mode image and the category information of each grain of rice are output, wherein the trained rice category detection network model is obtained by training the training image set with a deep neural network. Wherein, the rice position information includes the center point coordinates of the rice grain bounding box, the width of the bounding box and the height of the bounding box, and the bounding box is a rectangular frame closely surrounding each rice. The rice category includes broken rice, chalky rice, yellow rice, diseased rice, heavy chalky rice and normal rice.

[0091] Step 1031b, performing image segmentation processing on the rice RGB color mode image to obtain the contour information of each rice grain.

[0092] In this embodiment, the rice RGB color mode image is subjected to image segmentation processing. Specifically, the image is converted from the RGB color space to the HSV space, the S channel image is eroded, and the maximum value of the V channel image and the eroded image is used to construct a single channel image I. vs , for image I vs Perform an opening operation to obtain image I′ vs ; Image I′ vs Binarization is performed, and then the contour of the binarized image is detected and the area within the contour is calculated. If the area is less than a preset threshold, it is considered to be noise and the contour is discarded, thereby obtaining the contour information of each grain of rice.

[0093] Step 1031c, obtaining various rice profile information according to the position information of each rice grain, the category information of each rice grain and the profile information of each rice grain.

[0094] In this embodiment, various types of rice profile information are determined based on the position information of each grain of rice, the category information of each grain of rice, and the profile information of each grain of rice. Specifically, various types of rice profile information are counted based on the category information of each grain of rice, the position information of each grain of rice, and the wheel information of each grain of rice.

[0095] Embodiment 5

[0096] Figure 6 : is a schematic diagram of a flow chart of a rice grade classification method provided in Embodiment 5 of the present invention, such as Figure 6 As shown, based on the rice grade classification method provided in the first embodiment of the present invention, step 104 is further refined, specifically including the following steps:

[0097] Step 1041, determining the total weight of all rice corresponding to the rice hyperspectral image according to the weight of each type of rice corresponding to the rice hyperspectral image, and calculating the ratio of the total weight of each type of abnormal rice corresponding to the rice hyperspectral image to the total weight of all rice, to obtain the proportion corresponding to each type of abnormal rice.

[0098] In this embodiment, the weights of various types of rice corresponding to the rice hyperspectral image are added to obtain the total weight of all rice corresponding to the rice hyperspectral image, and the ratio of each type of abnormal rice to the total weight of all rice is further calculated, and the ratio of the total weight of broken rice corresponding to the rice hyperspectral image to the total weight of all rice is calculated to obtain the corresponding proportion of broken rice. The ratio of the total weight of chalky rice corresponding to the rice hyperspectral image to the total weight of all rice is calculated to obtain the corresponding proportion of chalky rice. The ratio of the total weight of yellow rice corresponding to the rice hyperspectral image to the total weight of all rice is calculated to obtain the corresponding proportion of yellow rice. The ratio of the total weight of diseased rice corresponding to the rice hyperspectral image to the total weight of all rice is calculated to obtain the corresponding proportion of diseased rice. The ratio of the total weight of heavy chalky rice corresponding to the rice hyperspectral image to the total weight of all rice is calculated to obtain the corresponding proportion of heavy chalky rice.

[0099] Step 1042, comparing the proportions corresponding to each type of abnormal rice with the corresponding thresholds of each type of abnormal and normal rice, and determining the rice grade according to the comparison result.

[0100] In this embodiment, the proportions corresponding to various types of abnormal rice, i.e., the proportions corresponding to broken rice, the proportions corresponding to chalky rice, the proportions corresponding to yellow rice, the proportions corresponding to diseased rice, and the proportions corresponding to heavy chalky rice, are compared with the threshold values ​​corresponding to the abnormal rice, and the rice grade is determined according to the comparison results. The proportion formula is as follows:

[0101]

[0102] Among them, P j is the proportion of a certain type of abnormal rice, M j is the total weight of a certain type of abnormal rice, and M is the total weight of all rice.

[0103] Optionally, determining the rice grade according to the comparison result is further refined, specifically comprising the following steps:

[0104] In this embodiment, the proportion corresponding to broken grain rice is compared with the threshold corresponding to broken grain rice, and the proportion corresponding to chalky rice is compared with the threshold corresponding to chalky rice, and the proportion corresponding to yellow grain rice is compared with the threshold corresponding to yellow grain rice, and the proportion corresponding to diseased spot rice is compared with the threshold corresponding to diseased spot rice, and the proportion corresponding to heavy chalky rice is compared with the corresponding threshold corresponding to heavy chalky rice, and the thresholds include a first threshold, a second threshold and a third threshold, and the first threshold < the second threshold < the third threshold.

[0105] If the proportion corresponding to broken grain rice is less than the first threshold corresponding to broken grain rice, the proportion corresponding to yellow grain rice is less than the first threshold corresponding to yellow grain rice, the proportion corresponding to diseased spot rice is less than the first threshold corresponding to diseased spot rice, the proportion corresponding to chalky rice is less than the first threshold corresponding to chalky rice, and the proportion corresponding to heavy chalky rice is less than the first threshold corresponding to heavy chalky rice, then the grade of rice in the rice hyperspectral image is determined to be first-grade rice.

[0106] Among them, if the proportion corresponding to broken grain rice is less than the second threshold corresponding to broken grain rice, the proportion corresponding to yellow grain rice is less than the second threshold corresponding to yellow grain rice, the proportion corresponding to diseased rice is less than the second threshold corresponding to diseased rice, the proportion corresponding to chalky rice is less than the second threshold corresponding to chalky rice, and the proportion corresponding to heavy chalky rice is less than the second threshold corresponding to heavy chalky rice, then the grade of rice in the rice hyperspectral image is determined to be second-grade rice.

[0107] Among them, if the proportion corresponding to broken grain rice is less than the third threshold corresponding to broken grain rice, the proportion corresponding to yellow grain rice is less than the third threshold corresponding to yellow grain rice, the proportion corresponding to diseased rice is less than the third threshold corresponding to diseased rice, the proportion corresponding to chalky rice is less than the third threshold corresponding to chalky rice, and the proportion corresponding to heavy chalky rice is less than the third threshold corresponding to heavy chalky rice, then the grade of rice in the rice hyperspectral image is determined to be third-grade rice.

[0108] In this embodiment, a pre-trained rice density prediction network model is used to obtain relatively accurate rice density information, and the weight of each type of rice is further determined based on the density information, thereby determining the rice grade based on the weight of each type of rice. There is no need for workers to manually classify the rice, which not only improves the classification efficiency but also effectively improves the classification accuracy.

[0109] Embodiment 6

[0110] Figure 7 : is a schematic diagram of a flow chart of a rice grade classification method provided in Embodiment 6 of the present invention, such as Figure 7 As shown, based on the rice grade classification method provided in the first embodiment of the present invention, before step 102, the following steps are also included:

[0111] Step 1021, select a rice sample hyperspectral image from the training data set, input the rice sample hyperspectral image into a preset rice density prediction network model, and output rice prediction density information corresponding to the rice sample hyperspectral image.

[0112] In this embodiment, a rice sample hyperspectral image is extracted from a preset database as a training data set, and the rice in each rice sample hyperspectral image is weighed to obtain the actual total weight of rice corresponding to each rice sample hyperspectral image, and the actual total weight of rice corresponding to each rice sample hyperspectral image is obtained. A rice sample hyperspectral image is selected from the training data set, and the rice sample hyperspectral image is input into a preset rice density prediction network model to obtain the rice prediction density information corresponding to the rice sample hyperspectral image, wherein the rice prediction density information includes rice prediction density image information and rice prediction density value.

[0113] Step 1022: Determine the predicted total weight of rice corresponding to each image according to the predicted rice density information, and determine a first rice weight loss value according to the predicted total weight of rice corresponding to each image.

[0114] In this embodiment, the predicted total weight of rice corresponding to each image is determined according to the predicted rice density information and various types of rice contour information corresponding to each image. The first rice weight loss value is determined according to the predicted total weight of rice corresponding to each image and the actual total weight of rice corresponding to each image, and the predicted total weight of rice corresponding to each image and the actual total weight of rice corresponding to each image are substituted into formula (3) to obtain the first rice weight loss value:

[0115]

[0116] Among them, L M is the first rice weight loss value, M' k is the actual total weight of rice corresponding to image K, M k Predict the total weight of rice corresponding to image K.

[0117] Step 1023, determining the network loss function value according to the first rice weight loss value, and updating the network weight parameter corresponding to the network loss function until the number of iterations reaches a preset number of iterations.

[0118] In this embodiment, the network loss function value is determined according to the first rice weight loss value. Specifically, the network loss function value is calculated according to formula (4), and formula (4) is as follows:

[0119] Loss = L M +αL1+βL2 formula (4)

[0120] Among them, the first rice weight loss value, L1 and L2 are regularization terms, α and β are the weights corresponding to the two regularization terms. L1 and L2 are used to limit the network weight parameters.

[0121] Optionally, the calculation formula of L1 is as follows:

[0122]

[0123] Optionally, the calculation formula of L2 is as follows:

[0124]

[0125] Among them, ω i The weight coefficient of the preset rice density prediction network model.

[0126] In this embodiment, a preset algorithm is used to update the network weight parameters corresponding to the network loss function until the number of iterations reaches a preset number of iterations, and the Adam optimization algorithm is used to backpropagate the network to update the network weight parameters corresponding to the network loss function.

[0127] Step 1024, determining the preset rice density prediction network model corresponding to the network weight parameter corresponding to the minimum network loss function as the optimal rice density prediction network model, testing the optimal rice density prediction network model, and obtaining a second rice weight loss value.

[0128] In this embodiment, the preset rice density prediction network model corresponding to the network weight parameter corresponding to the minimum network loss function is determined as the optimal rice density prediction network model, and the optimal rice density prediction network model is tested using a test data set to obtain the corresponding second rice weight loss value.

[0129] Optionally, a test data set is established in advance, and test sample hyperspectral images are extracted from a preset database as the test data set. The rice in each test sample hyperspectral image is weighed to obtain the actual total weight of the rice corresponding to each test sample hyperspectral image.

[0130] Among them, the second rice weight loss value is obtained based on the predicted total weight of rice corresponding to the hyperspectral images of each test sample and the actual total weight of rice corresponding to the hyperspectral images of each test sample. The difference between the actual total weight of rice corresponding to the hyperspectral image of the test sample and the predicted total weight of rice corresponding to the hyperspectral image of the test sample is calculated, and the difference is the second rice weight loss value.

[0131] Step 1025: If the second rice weight loss value is less than or equal to the preset loss value, the optimal rice density prediction network model is determined as the trained rice density prediction network model.

[0132] In this embodiment, if the second rice weight loss value is less than or equal to the preset loss value, it means that the actual total weight of the rice is close to the predicted total weight, the network training is completed, and the optimal rice density prediction network model is determined as the trained rice density prediction network model.

[0133] Among them, if the second rice weight loss value is greater than the preset loss value, the network can be retrained or the trained network model can be fine-tuned by adjusting the learning rate, batchsize value, or increasing training data, enhancing training data, increasing the number of training iterations, etc.

[0134] Embodiment 7

[0135] Based on the rice grading method provided in the sixth embodiment of the present invention, the step 1022 of determining the predicted total weight of rice corresponding to each image according to the predicted rice density information is further refined, and specifically includes the following steps:

[0136] Step 1022a, determining various types of rice contour information corresponding to each image, and determining the predicted total weight of rice corresponding to each image according to the predicted rice density information and the various types of rice contour information corresponding to each image.

[0137] In this embodiment, various types of rice profile information corresponding to each image are determined, and the predicted total weight of rice corresponding to each image is determined according to the predicted rice density information and various types of rice profile information. Specifically, the placeholder function corresponding to the rice profile information is determined according to the rice profile information, and the predicted total weight of rice corresponding to each image is determined according to the placeholder function corresponding to the rice profile information and the predicted rice density information. The predicted total weight of rice corresponding to the image is calculated according to formula (7), and formula (7) is expressed as:

[0138]

[0139] Among them, M' is the predicted total weight of rice, w is the image I d The width of image I d The height of image I d The density value corresponding to the pixel at (x, y), c(x, y) is the occupancy function corresponding to the rice contour information.

[0140] Among them, the occupancy function corresponding to the rice profile information is determined by the rice profile information, see formula (8):.

[0141]

[0142] Among them, if the pixel at (x, y) is located within the rice outline, then c(x, y) = 1; if the pixel at (x, y) is not located within the rice outline, then c(x, y) = 0.

[0143] Figure 8 FIG. 1 is a schematic diagram of the structure of a rice grade classification device provided by an embodiment of the present invention. Figure 8 As shown, the rice grading device 200 provided in this embodiment includes a preprocessing unit 201, a prediction unit 202, and a determination unit 203.

[0144] Among them, the preprocessing unit 201 is used to obtain the initial hyperspectral image of rice, and preprocess the initial hyperspectral image of rice to obtain the hyperspectral image of rice to be detected. The prediction unit 202 is used to input the hyperspectral image of rice to be detected into the trained rice density prediction network model, and output the rice density information corresponding to the hyperspectral image of rice. The determination unit 203 is used to determine the weight of each type of rice corresponding to the hyperspectral image of rice according to the rice density information corresponding to the hyperspectral image of rice. The determination unit 203 is also used to determine the rice grade corresponding to the hyperspectral image of rice according to the weight of each type of rice corresponding to the hyperspectral image of rice.

[0145] Optionally, the preprocessing unit is further used to obtain a rice all-white calibration image and a rice all-black calibration image, and obtain a corrected rice hyperspectral image according to the rice all-white calibration image, the rice all-black calibration image and the rice initial hyperspectral image; and sequentially perform data redundancy elimination processing and filtering and denoising processing on the corrected rice hyperspectral image to obtain a rice hyperspectral image to be detected.

[0146] Optionally, the determination unit is further used to determine various types of rice profile information corresponding to the rice hyperspectral image; and determine various types of rice weights corresponding to the rice hyperspectral image according to the rice density information corresponding to the rice hyperspectral image and the various types of rice profile information corresponding to the rice hyperspectral image.

[0147] Optionally, the determination unit is further used to obtain a rice RGB color mode image according to the rice hyperspectral image, input the rice RGB color mode image into a trained rice category detection network model, and output the position information of each grain of rice and the category information of each grain of rice corresponding to the rice RGB color mode image; perform image segmentation processing on the rice RGB color mode image to obtain the contour information of each grain of rice; and obtain various types of rice contour information according to the position information of each grain of rice, the category information of each grain of rice and the contour information of each grain of rice.

[0148] Optionally, the determination unit is further used to determine the total weight of all rice corresponding to the rice hyperspectral image according to the weight of each type of rice corresponding to the rice hyperspectral image, and calculate the ratio of the total weight of each type of abnormal rice corresponding to the rice hyperspectral image to the total weight of all rice to obtain the proportion corresponding to each type of abnormal rice; compare the proportion corresponding to each type of abnormal rice with the corresponding threshold value of each type of abnormal rice, and determine the rice grade according to the comparison result.

[0149] Optionally, the rice grading device further includes: a training unit.

[0150] The training unit is used to select a rice sample hyperspectral image from a training data set, input the rice sample hyperspectral image into a preset rice density prediction network model, and output rice prediction density information corresponding to the rice sample hyperspectral image; determine the predicted total weight of rice corresponding to each image according to the rice prediction density information, and determine a first rice weight loss value according to the predicted total weight of rice corresponding to each image; determine a network loss function value according to the first rice weight loss value, and update a network weight parameter corresponding to the network loss function until the number of iterations reaches a preset number of iterations; determine a preset rice density prediction network model corresponding to a network weight parameter corresponding to a minimum network loss function as an optimal rice density prediction network model, test the optimal rice density prediction network model, and obtain a second rice weight loss value; if the second rice weight loss value is less than or equal to the preset loss value, determine the optimal rice density prediction network model as the trained rice density prediction network model.

[0151] Optionally, the training unit is further used to determine various types of rice contour information corresponding to each image, and determine the predicted total weight of rice corresponding to each image according to the predicted rice density information and the various types of rice contour information corresponding to each image.

[0152] Fig. 9 is a block diagram of an electronic device for implementing the rice grade classification method according to an embodiment of the present invention, such as Fig. 9 As shown, the electronic device 300 includes: a processor 301 and a memory 302 communicatively connected to the processor 301 .

[0153] Memory 302 stores computer executable instructions;

[0154] The processor 31 executes the computer-executable instructions stored in the memory 302, so that the processor executes the method provided by any one of the above embodiments.

[0155] In an exemplary embodiment, a computer-readable storage medium is further provided, in which computer-executable instructions are stored. The computer-executable instructions are executed by a processor to execute the method in any one of the above embodiments.

[0156] In an exemplary embodiment, a computer program product is also provided, including a computer program, and the computer program is executed by a processor to execute the method in any one of the above embodiments.

[0157] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed by the present invention. The description and examples are to be considered exemplary only, and the true scope and spirit of the present invention is indicated by the following claims.

[0158] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

Claims

1. A rice grading method, characterized in that: The method comprises: Acquire an initial hyperspectral image of rice, and preprocess the initial hyperspectral image of rice to obtain a hyperspectral image of rice to be detected; Inputting the rice hyperspectral image to be detected into the trained rice density prediction network model, and outputting the rice density information corresponding to the rice hyperspectral image; Determine various rice profile information corresponding to the rice hyperspectral image; Determining the weight of various types of rice corresponding to the rice hyperspectral image according to rice density information corresponding to the rice hyperspectral image and various types of rice contour information corresponding to the rice hyperspectral image, wherein the rice density information includes a rice density image and a rice density value, and the rice density value is used to indicate the density value of a pixel in the rice density image; Determine the rice grade corresponding to the rice hyperspectral image according to the weights of various types of rice corresponding to the rice hyperspectral image; The method further comprises: inputting the rice hyperspectral image to be detected into the trained rice density prediction network model, and outputting the rice density corresponding to the rice hyperspectral image, before: Selecting a rice sample hyperspectral image from a training data set, inputting the rice sample hyperspectral image into a preset rice density prediction network model, and outputting rice prediction density information corresponding to the rice sample hyperspectral image; Determine the predicted total weight of rice corresponding to each image according to the predicted rice density information, and determine a first rice weight loss value according to the predicted total weight of rice corresponding to each image; Determine the network loss function value according to the first rice weight loss value, and update the network weight parameter corresponding to the network loss function until the number of iterations reaches a preset number of iterations; The preset rice density prediction network model corresponding to the network weight parameter corresponding to the minimum network loss function is determined as the optimal rice density prediction network model, and the optimal rice density prediction network model is tested to obtain a second rice weight loss value; If the second rice weight loss value is less than or equal to the preset loss value, the optimal rice density prediction network model is determined as the trained rice density prediction network model.

2. The method according to claim 1, characterized in that The method of preprocessing the initial rice hyperspectral image to obtain the rice hyperspectral image to be detected comprises: Obtaining a rice all-white calibration image and a rice all-black calibration image, and obtaining a calibrated rice hyperspectral image according to the rice all-white calibration image, the rice all-black calibration image and the rice initial hyperspectral image; The corrected rice hyperspectral image is processed with data redundancy elimination and filtering to obtain the rice hyperspectral image to be detected.

3. The method according to claim 1, characterized in that The method of determining various types of rice profile information corresponding to the rice hyperspectral image includes: Obtain a rice RGB color mode image according to the rice hyperspectral image, input the rice RGB color mode image into a trained rice category detection network model, and output the position information of each grain of rice and the category information of each grain of rice corresponding to the rice RGB color mode image; Perform image segmentation processing on the rice RGB color mode image to obtain the contour information of each rice grain; According to the position information of each grain of rice, the category information of each grain of rice and the contour information of each grain of rice, the contour information of each grain of rice is obtained.

4. The method according to claim 1, characterized in that: Determining the rice grade corresponding to the rice hyperspectral image according to the weights of various types of rice corresponding to the rice hyperspectral image includes: Determine the total weight of all rice corresponding to the rice hyperspectral image according to the weight of each type of rice corresponding to the rice hyperspectral image, and calculate the ratio of the total weight of each type of abnormal rice corresponding to the rice hyperspectral image to the total weight of all rice to obtain the proportion corresponding to each type of abnormal rice; The corresponding proportions of each type of abnormal rice are compared with the corresponding thresholds of each type of abnormal rice, and the rice grade is determined based on the comparison results.

5. The method according to claim 1, characterized in that Determining the predicted total weight of rice corresponding to each image according to the predicted rice density information includes: Determine each type of rice contour information corresponding to each image, and determine the predicted total weight of rice corresponding to each image according to the predicted rice density information and the various types of rice contour information corresponding to each image.

6. A rice grading device, characterized in that: The device comprises: A preprocessing unit is used to obtain an initial hyperspectral image of rice, and preprocess the initial hyperspectral image of rice to obtain a hyperspectral image of rice to be detected; A prediction unit, used for inputting the rice hyperspectral image to be detected into a trained rice density prediction network model, and outputting rice density information corresponding to the rice hyperspectral image; A determination unit, used to determine various types of rice profile information corresponding to the rice hyperspectral image; The determination unit is further used to determine the weight of various types of rice corresponding to the rice hyperspectral image according to the rice density information corresponding to the rice hyperspectral image and the various types of rice contour information corresponding to the rice hyperspectral image, wherein the rice density information includes a rice density image and a rice density value, and the rice density value is used to indicate the density value of a pixel in the rice density image; The determination unit is further used to determine the rice grade corresponding to the rice hyperspectral image according to the weights of various types of rice corresponding to the rice hyperspectral image; The training unit is used to select a rice sample hyperspectral image from a training data set, input the rice sample hyperspectral image into a preset rice density prediction network model, and output rice prediction density information corresponding to the rice sample hyperspectral image; determine the predicted total weight of rice corresponding to each image according to the rice prediction density information, and determine a first rice weight loss value according to the predicted total weight of rice corresponding to each image; determine a network loss function value according to the first rice weight loss value, and update a network weight parameter corresponding to the network loss function until the number of iterations reaches a preset number of iterations; determine a preset rice density prediction network model corresponding to a network weight parameter corresponding to a minimum network loss function as an optimal rice density prediction network model, test the optimal rice density prediction network model, and obtain a second rice weight loss value; if the second rice weight loss value is less than or equal to the preset loss value, determine the optimal rice density prediction network model as the trained rice density prediction network model.

7. An electronic device comprising: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 5 when executed by a processor.