Rice chalkiness identification method and device
Through the rice image acquisition system and cascade detection and segmentation strategy, the problems of image acquisition and matching in rice chalkiness detection are solved, and high-precision and low-cost chalkiness calculation is achieved.
Patent Information
- Application Number
- CN202510901606.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-01
- Publication Date
- 2025-10-17
Smart Images

Figure CN120808336A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of agricultural detection, and particularly relates to a rice chalky white identification method and device. BACKGROUND
[0002] Rice is an important food source for human beings, and rice is the seed of mature rice, which can provide human body with rich carbohydrates, proteins and other nutrients. The detection of rice chalky white has important application value in rice variety breeding and rice quality evaluation. The core index of chalky white detection is chalky white area, which can directly reflect the degree of chalky white and is an important basis for measuring the appearance quality of rice.
[0003] Traditional manual detection methods have problems of high cost, low efficiency, easy fatigue and the like, and cannot obtain the rice chalky white rate; computer vision technology can realize automatic batch detection through image enhancement and threshold segmentation, and gradually becomes a mainstream method in the industry. For example, the patent literature CN114689527A discloses a rice chalky white detection method based on image processing and deep convolutional neural network, which can segment the boundary of rice grains through erosion operation and automatically identify chalky rice grains by using deep learning, and finally calculate the chalky white rate. However, the method can only count the total number of chalky grains, and cannot calculate the chalky white area. The patent literature CN112070741B proposes a machine vision scheme based on saliency detection, which can quantify the rice chalky degree through dark box shooting, image preprocessing and threshold segmentation. However, the rice image under single visual angle cannot fully reflect the actual chalky white area. Therefore, how to effectively collect the front and back images of rice under backlight conditions, accurately match the front and back images of rice, and comprehensively detect the rice chalky white is still challenging. SUMMARY
[0004] The purpose of the present application is to provide a rice chalky white identification method and device to solve the problems in the prior art, which can effectively collect the front and back images of rice under backlight conditions, accurately match the front and back images of rice, accurately calculate the chalky degree of chalky rice, and construct a unified rice chalky white detection model by using multi-channel rice images, and has the advantages of low cost, high speed, high precision, simplicity and the like.
[0005] One embodiment of the present application provides a rice chalky white identification method, which comprises the following steps:
[0006] A pre-constructed rice image acquisition system is used to collect the front and back images of rice under backlight conditions, respectively;
[0007] According to the front and back images of the rice, a multi-channel rice image is obtained through perspective transformation and image fusion;
[0008] The multi-channel rice image is input into a pre-trained rice chalkiness recognition model, a cascade detection and segmentation strategy is adopted, and a recognition result of each rice grain is output.
[0009] Optionally, the rice image acquisition system comprises a fixed support, a transparent acrylic plate, a color camera and a white ring-shaped light source.
[0010] The acrylic plate is installed in the middle of the fixed support and is used to place the rice to be tested. Four circular marker points of different colors are respectively attached to the four corners of the acrylic plate. The color camera is respectively installed on the upper and lower parts of the fixed support. A ring-shaped light source is respectively installed in front of the lens of the color camera.
[0011] Optionally, the multi-channel rice image is obtained through perspective transformation and image fusion according to the front and back images of the rice, comprising:
[0012] The circular marker points of the front and back images are respectively detected, and a perspective transformation matrix of the front and back images is calculated according to the detection results of the circular marker points;
[0013] The perspective transformation matrix is used to perform perspective transformation on the front and back images respectively, and the resolution of the perspective-transformed front and back images is kept consistent, and both are three-channel color images;
[0014] The perspective-transformed front and back images are fused to obtain a six-channel rice image.
[0015] Optionally, the rice chalkiness recognition model is trained based on a YOLOv8 network and a UNet network. The rice chalkiness detection model adopts a cascade detection and segmentation strategy to realize high-precision recognition of the rice chalkiness area. The strategy comprises the following steps:
[0016] In the preliminary detection stage, the multi-channel rice image is input into the trained YOLOv8 network to obtain the position information of each rice grain and whether it has chalkiness;
[0017] In the precise segmentation stage, for the target area identified as chalky rice, ROI cropping is performed based on the detection frame coordinates, and scale normalization is performed. Then, the cropped image is input into the trained UNet network to output the corresponding chalkiness area mask;
[0018] In the spatial mapping stage, the original position and scaling parameters in the cropping process are recorded, and the segmentation result is restored to the original image coordinates through a spatial mapping algorithm to realize accurate positioning and visual labeling of the chalkiness area on the detection image.
[0019] Optionally, in the primary detection stage, rectangular boxes are annotated based on the collected backlit rice images, and each grain of rice is labeled as chalky rice or non-chalky rice. A detection training dataset is constructed and input into the YOLOv8 network for training.
[0020] In the precision segmentation phase, the training data comes from the chalky rice candidate regions output by the YOLOv8 network. After ROI cropping and scaling the regions, the chalky regions in the cropped images are finely annotated using polygons to construct a segmentation dataset and train the UNet network.
[0021] In the inference stage, the chalky mask output by UNet is combined with the cropping position information recorded in the detection stage, and a spatial inverse mapping operation is used to accurately restore the mask to the corresponding position in the original image, thereby achieving accurate identification of the chalky area of each grain of rice.
[0022] Another embodiment of the present application provides a device for identifying chalky rice, the device comprising:
[0023] An acquisition module is used to respectively acquire a front image and a back image of rice under backlight conditions using a pre-built rice image acquisition system;
[0024] An acquisition module is used to obtain a multi-channel rice image through perspective transformation and image fusion according to the front image and the back image of the rice;
[0025] The recognition module is used to input the multi-channel rice image into a pre-trained rice chalkiness recognition model, adopt a cascade detection and segmentation strategy, and output the recognition result of each rice grain.
[0026] Yet another embodiment of the present application provides a storage medium, wherein the storage medium stores a computer program, wherein the computer program is configured to execute any of the above methods when run.
[0027] Yet another embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute any of the above methods.
[0028] Compared with the prior art, the rice white identification method provided by the application can effectively collect the front and back images of rice, accurately match the front and back images of rice, accurately calculate the whiteness of rice with white rice, and can utilize the multi-channel rice image to construct a unified rice white identification model, and has the advantages of low cost, high speed, high precision, simplicity and the like. BRIEF DESCRIPTION OF DRAWINGS
[0029] Figure 1 The hardware structure block diagram of the computer terminal of the rice white identification method provided by the embodiment of the application is provided.
[0030] Figure 2 The flowchart of the rice white identification method provided by the embodiment of the application is provided.
[0031] Figure 3 The structural schematic diagram of the rice image acquisition system provided by the embodiment of the application is provided.
[0032] Figure 4 The flowchart of the cascade detection and segmentation strategy provided by the embodiment of the application is provided.
[0033] Figure 5 The identification schematic diagram of the cascade detection and segmentation strategy provided by the embodiment of the application is provided.
[0034] Figure 6 The design schematic diagram of the acrylic plate provided by the embodiment of the application is provided.
[0035] Figure 7 The structural schematic diagram of the rice white detection device provided by the embodiment of the application is provided. DETAILED DESCRIPTION
[0036] The embodiments described below with reference to the drawings are exemplary and are only used to explain the application, and cannot be explained as a limitation of the application.
[0037] In the process of rice white detection, the traditional segmentation network often has problems of a large number of false detection, missed detection and repeated detection, and has low detection precision and limited practicability, and it is difficult to provide effective support for rice quality evaluation and related automatic processing systems.
[0038] The embodiment of the present application first provides a rice white core identification method, which can be applied to an electronic device, such as a computer terminal, specifically, a general computer and the like.
[0039] The rice white core identification method will be described in detail below by taking a computer terminal as an example. Figure 1 A hardware structure block diagram of a computer terminal of the rice white core identification method provided by the embodiment of the present application is shown in FIG. 1. Figure 1 As shown in FIG. 1, the computer terminal can include one or more (only one is shown in the figure) processors 102 (the processor 102 can include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Figure 1 Optionally, the computer terminal can further include a transmission device 106 for communication function and an input and output device 108. Figure 1 It can be understood by those skilled in the art that the structure shown in the figure is only schematic, and it does not limit the structure of the computer terminal. For example, the computer terminal can include more or fewer components than those shown in the figure, or have a different configuration from that shown in the figure. Figure 1 For example, the computer terminal can include more or fewer components than those shown in the figure, or have a different configuration from that shown in the figure. Figure 1 For example, the computer terminal can include more or fewer components than those shown in the figure, or have a different configuration from that shown in the figure.
[0040] The memory 104 can be used to store software programs and modules of application software, such as program instructions / modules corresponding to the rice white core identification method in the embodiment of the present application. The processor 102 executes various function applications and data processing by running the software programs and modules stored in the memory 104, that is, implements the method described above. The memory 104 can include a high-speed random access memory, and can further include a non-volatile memory, such as one or more magnetic storage devices, a flash memory, or other non-volatile solid-state memories. In some examples, the memory 104 can further include a memory remotely arranged with respect to the processor 102, and these remote memories can be connected to the computer terminal through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0041] The transmission device 106 is used to receive or send data via a network. Specific examples of the network can include a wireless network provided by a communication provider of the computer terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet in a wireless manner.
[0042] Referring to Figures 2-6Embodiments of the present application provide a rice white spot identification method, which can include the following steps:
[0043] S201, using a pre-constructed rice image acquisition system, respectively acquiring front and back images of rice under backlight conditions;
[0044] Specifically, the rice image acquisition system can include a fixed support, a transparent acrylic plate, a color video camera, and a white ring-shaped light source.
[0045] The acrylic plate is installed in the middle of the fixed support and is used to place the rice to be tested. Four different colored circular marker points are attached to the four corners of the acrylic plate. The color video camera is installed on the upper and lower parts of the fixed support, respectively. A ring-shaped light source is installed in front of the lens of the color video camera.
[0046] S202, according to the front and back images of the rice, a multi-channel rice image is obtained through perspective transformation and image fusion;
[0047] Specifically, the circular marker points of the front and back images can be detected respectively. The perspective transformation matrix of the front and back images is calculated according to the detection results of the circular marker points.
[0048] The perspective transformation matrix is used to perform perspective transformation on the front and back images, respectively. The resolution of the perspective-transformed front and back images is kept consistent, and both are three-channel color images.
[0049] The perspective-transformed front and back images are fused to obtain a six-channel rice image.
[0050] S203, the multi-channel rice image is input into a pre-trained rice white spot identification model. A cascaded detection and segmentation strategy is adopted to output the identification result of each grain of rice. The rice white spot identification model is trained based on the YOLOv8 network and the Unet network, and adopts the cascaded detection and segmentation strategy.
[0051] In practical applications, the detailed steps of the technical solution of the present application can be as follows:
[0052] Step S1: build a rice image acquisition system, as shown in Figure 3 The system mainly includes a fixed support, a transparent acrylic plate with high light transmittance, two color video cameras, and two white ring-shaped light sources. The acrylic plate is installed in the middle of the fixed support and is used to place the rice to be tested. Four different colored circular marker points are attached to the four corners of the acrylic plate, as shown in Figure 6The two cameras are respectively installed on the upper and lower parts of the fixed support, and each is provided with a ring-shaped light source in front of the lens for providing backlight conditions, wherein the upper camera is used for shooting the front image of the rice, and the lower camera is used for shooting the back image of the rice;
[0053] Step S2: a batch of single variety of rice is prepared, a plurality of rice samples are selected each time, and are uniformly placed on the acrylic plate, the two cameras and the corresponding ring-shaped light sources are turned on in sequence to collect the front and back images of the rice; the circular mark points of the front and back images are detected respectively, the perspective transformation matrix of the front and back images is calculated according to the detection results of the circular mark points, then the perspective transformation is performed on the front and back images respectively, and the resolution of the front and back images after the perspective transformation is kept consistent;
[0054] Step S3: since the front and back images of the rice are both three-channel color images and the resolutions of the two images after the perspective transformation are the same, the front and back images of the rice are directly fused to form a six-channel rice chalky image; the Labelme software is used to label the six-channel rice image in combination with the front and back image information of the rice, each rice in the image is labeled with a rectangular frame and is given a label category; the identified chalky rice in the six-channel rice image is ROI cropped to obtain a single rice image, and the Labelme software is used to polygonally label the chalky part in the image and is given a label category chalky.
[0055] Step S4: the six-channel rice image contains the front and back image information of the rice, and can more comprehensively reflect the chalky condition of the rice. The rice data set is divided into a training set and a test set according to a certain proportion, the training set is used to construct a rice chalky recognition model, and the test set is used to evaluate the performance of the constructed rice chalky recognition model.
[0056] Step S5: the rice to be tested is placed on the acrylic plate, the front and back images of the rice under the backlight condition are collected by using the two cameras located at the upper and lower parts respectively, the six-channel rice image is obtained through perspective transformation and image fusion, is input into the constructed rice chalky recognition model, and a cascaded detection and segmentation strategy is adopted, so that the recognition result of each rice can be output, and the recognition result includes the chalky rate of the rice and the chalkiness of each rice.
[0057] Further, in the step S1, the acrylic plate is installed horizontally, the optical axes of the two cameras are both perpendicular to the acrylic plate, and the distances from the optical centers of the two cameras to the acrylic plate are equal; the light source is used in cooperation with the camera to provide backlighting conditions for the rice; the four circular markers are different in color, for example, black, red, green and blue; the centers of the four circular markers can successively form a standard rectangle, assuming that the aspect ratio of the rectangle is equal to K; the two cameras are equipped with the same type of optical lens, and the field of view of the optical lens can just cover the rectangular area formed by the four circular markers. By designing different color circular markers, the order of the markers can be clearly marked, facilitating matching and identification; the detection accuracy is improved, and the same color markers are avoided from being mistaken for the same marker during detection; the perspective transformation matrix calculation is facilitated, and the accurate positions of the four markers in the image and their corresponding relationship on the target plane need to be determined when calculating the perspective transformation matrix.
[0058] Further, in the step S2, when collecting the front image of the rice, only the upper camera and the upper ring-shaped light source are turned on; when collecting the back image of the rice, only the lower camera and the lower ring-shaped light source are turned on; the four circular markers are detected by the Hough transformation algorithm, and the order of the circular markers is determined according to the color of the circular markers; the perspective transformation matrix can be solved by combining the order and the center position of the four circular markers; the front and back images of the rice are both subjected to perspective transformation, only the image information within the rectangle formed by the four circular markers is retained, and the resolutions of the front and back images after perspective transformation are unified to KN×N×3 pixels, so that the front and back images of the rice can be strictly corresponded. Among them, KN represents the width (unit: pixel) of the image, and since the aspect ratio of the rectangle is equal to K, the width here is obtained by multiplying the height N by the aspect ratio K; N represents the height (unit: pixel) of the image. In this resolution representation method, KN and N together define the size (width and height) of the image.
[0059] When calculating the perspective transformation matrix, the center positions of the detected circular markers can be first arranged according to the pre-defined color order (for example, red, green, blue and black), and these center positions will be used as the source points (src_points). Then, the target points (dst_points) are defined as the standard positions in the image. By calling the cv2.getPerspectiveTransform(src_points, dst_points) function, the perspective transformation matrix M is calculated, and then the cv2.warpPerspective(image, M, (KN, N)) function is used to apply this transformation matrix to perform perspective transformation on the image. In this way, the correspondence between the source points and the target points and the pre-defined order together ensure the accuracy of the perspective transformation.
[0060] Further, in step S3, the six-channel rice image obtained by fusing the front and back images of the rice has a resolution of KNxNx6 pixels; to meet the requirement of accurate identification of rice chalkiness, the rectangular frame label category can be set according to actual detection needs, and is divided into chalky rice and non-chalky rice; the polygon label is chalky.
[0061] Further, in step S4, the training process and detailed usage of the YOLOv8 network and the Unet network can refer to the prior art, which will not be described here.
[0062] Further, in step S5, the chalkiness rate of the rice is calculated according to the number of chalky rice and non-chalky rice identified by the YOLOv8 network in the primary detection stage, and the chalkiness rate is calculated by a proportional relationship; the chalkiness degree of the chalky rice is segmented by the UNet network, and the total number of pixels in the whole rice region and the chalky region is calculated to realize accurate quantification of the chalkiness degree.
[0063] Specifically, the rice chalkiness detection model adopts a cascade detection and segmentation strategy to realize high-precision identification of the rice chalkiness region, which includes the following steps:
[0064] In the primary detection stage, the multi-channel rice image is input into the trained YOLOv8 network to obtain the position information (detection frame) of each rice and whether it has chalkiness;
[0065] In the precise segmentation stage, for the target region identified as chalky rice, ROI cropping is performed based on the detection frame coordinates, and scale normalization (such as unified to 256*256) is performed, and then the cropped image is input into the trained UNet network to output the corresponding chalky region mask;
[0066] In the spatial mapping stage, the original position and scaling parameters in the cropping process are recorded, and the segmentation result is restored to the original image coordinates by a spatial mapping algorithm to realize accurate positioning and visual labeling of the chalky region on the detection image.
[0067] In the primary detection stage, rectangular frame labeling is performed based on the collected backlit rice image, each rice is assigned a chalky rice or non-chalky rice label, a detection training data set is constructed, and is input into the YOLOv8 network for training;
[0068] In the precise segmentation stage, the training data comes from the chalky rice candidate region output by the YOLOv8 network, after ROI cropping and scale normalization of the region, the chalky region in the cropped image is finely labeled in a polygon manner, a segmentation data set is constructed, and the UNet network is trained;
[0069] In the reasoning stage, by combining the chalky mask output by the UNet with the cutting position information recorded in the detection stage, a spatial reflection mapping operation is adopted to accurately restore the mask to the corresponding position of the original image, thereby realizing accurate identification of the chalky area of each grain of rice.
[0070] The cascading detection and segmentation strategy effectively combines target detection and semantic segmentation to realize fine segmentation of the chalky area of rice.
[0071] In the preliminary detection stage, as shown in (a) of Figure 5 , the YOLOv8 network realizes classification of each grain of rice, and the output detection image contains the number information of chalky rice and non-chalky rice, and provides the detection frame coordinates of each grain of rice, providing a basis for subsequent processing.
[0072] In the precise segmentation stage, as shown in (b) of Figure 5 , according to the detection frame obtained in the detection stage, ROI cutting is performed on the area identified as chalky rice, and scale normalization (i.e., uniform scaling to a preset size, such as 256x256 pixels) is performed, and the cropped image is input into the trained Unet network to extract the chalky area mask, realizing fine segmentation of the chalky distribution.
[0073] In the spatial mapping stage, as shown in (c) of Figure 5 , the chalky mask output by the Unet is spatially reflected back to the original image coordinate system using the aforementioned recorded cutting position and scaling parameters, realizing accurate restoration and visual annotation of the chalky area.
[0074] As can be seen, by using a pre-constructed rice image acquisition system, front and back images of rice under backlight conditions are respectively acquired; according to the front and back images of the rice, a multi-channel rice image is obtained through perspective transformation and image fusion; the multi-channel rice image is input into a pre-trained rice chalky identification model, a cascading detection and segmentation strategy is adopted, and the identification result of each grain of rice is output, thereby effectively acquiring front and back images of rice, accurately matching front and back images of rice, accurately calculating the chalkiness of chalky rice, and being able to construct a unified rice chalky identification model using a multi-channel rice image, having the advantages of low cost, fast speed, high precision, simplicity, etc.
[0075] Another embodiment of the present application provides a rice chalky identification device, as shown in Figure 7 , the device can include:
[0076] The acquisition module 701 is configured to use a pre-constructed rice image acquisition system to respectively acquire front and back images of rice under backlight conditions.
[0077] The obtaining module 702 is configured to obtain a multi-channel rice image by perspective transformation and image fusion according to the front image and the back image of the rice.
[0078] The identifying module 703 is configured to input the multi-channel rice image into a pre-trained rice chalkiness identification model, adopt a cascaded detection and segmentation strategy, and output an identification result of each rice grain.
[0079] It can be seen that by using a pre-constructed rice image acquisition system, the front image and the back image of the rice under backlight conditions are respectively acquired; a multi-channel rice image is obtained by perspective transformation and image fusion according to the front image and the back image of the rice; the multi-channel rice image is input into a pre-trained rice chalkiness identification model, and a cascaded detection and segmentation strategy is adopted to output an identification result of each rice grain, so that the front and back images of the rice can be effectively acquired and accurately matched, the chalkiness degree of the chalky rice can be accurately calculated, and a unified rice chalkiness identification model can be constructed by using the multi-channel rice image, which has the advantages of low cost, high speed, high precision, simplicity and the like.
[0080] The embodiment of the present application also provides a storage medium, and the storage medium stores a computer program, wherein the computer program is set to execute the steps in any one of the method embodiments.
[0081] Specifically, in the embodiment, the storage medium can be set to store a computer program for executing the following steps:
[0082] S201, using a pre-constructed rice image acquisition system, respectively acquiring a front image and a back image of rice under backlight conditions;
[0083] S202, obtaining a multi-channel rice image by perspective transformation and image fusion according to the front image and the back image of the rice;
[0084] S203, inputting the multi-channel rice image into a pre-trained rice chalkiness identification model, adopting a cascaded detection and segmentation strategy, and outputting an identification result of each rice grain.
[0085] Specifically, in the embodiment, the storage medium can include but is not limited to a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store a computer program.
[0086] It can be seen that by using a pre-constructed rice image acquisition system, a front image and a back image of rice under backlight conditions are respectively acquired; according to the front image and the back image of the rice, a multi-channel rice image is obtained through perspective transformation and image fusion; the multi-channel rice image is input into a pre-trained rice chalkiness recognition model, a cascaded detection and segmentation strategy is adopted, and the recognition result of each grain of rice is output, so that the front and back images of rice can be effectively acquired and accurately matched, the chalkiness degree of chalky rice can be accurately calculated, and a unified rice chalkiness recognition model can be constructed by using the multi-channel rice image, and the method has the advantages of low cost, high speed, high precision, simplicity and the like.
[0087] The embodiment of the present application also provides an electronic device, comprising a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any of the above method embodiments.
[0088] Specifically, the above electronic device can further include a transmission device and an input-output device, wherein the transmission device is connected with the processor, and the input-output device is connected with the processor.
[0089] Specifically, in the embodiment, the processor can be configured to execute the following steps through the computer program:
[0090] S201, using a pre-constructed rice image acquisition system, a front image and a back image of rice under backlight conditions are respectively acquired;
[0091] S202, according to the front image and the back image of the rice, a multi-channel rice image is obtained through perspective transformation and image fusion;
[0092] S203, the multi-channel rice image is input into a pre-trained rice chalkiness recognition model, a cascaded detection and segmentation strategy is adopted, and the recognition result of each grain of rice is output.
[0093] Specifically, the specific examples in the embodiment can refer to the examples described in the above embodiments and optional implementation manners, and the embodiment will not be described here.
[0094] It can be seen that by using a pre-constructed rice image acquisition system, a front image and a back image of rice under backlight conditions are respectively acquired; according to the front image and the back image of the rice, a multi-channel rice image is obtained through perspective transformation and image fusion; the multi-channel rice image is input into a pre-trained rice chalkiness recognition model, and through a cascade detection and segmentation strategy, the recognition result of each grain of rice is output, so that the front and back images of rice can be effectively acquired and accurately matched, the chalkiness of chalky rice can be accurately calculated, and a unified rice chalkiness recognition model can be constructed by using the multi-channel rice image, which has the advantages of low cost, high speed, high precision, simplicity and the like.
[0095] The above describes the structure, features and effects of the present application in detail according to the embodiments shown in the drawings. The above description is only the preferred embodiments of the present application, but the present application is not limited to the embodiments shown in the drawings. Any changes or modifications made according to the concept of the present application, or equivalent embodiments with equivalent changes, are still within the scope of the present application.
Claims
1. A method for identifying rice chalkiness, characterized in that: The method comprises: Using a pre-built rice chalkiness image acquisition system, we collected front and back images of rice under backlight conditions. Obtaining a multi-channel rice image through perspective transformation and image fusion according to the front image and the back image of the rice; The multi-channel rice image is input into a pre-trained rice chalkiness recognition model, and a cascade detection and segmentation strategy is adopted to output the recognition result of each rice grain.
2. The method according to claim 1, characterized in that The rice chalkiness image acquisition system comprises: a fixed bracket, a transparent acrylic plate, a color camera and a white ring light source; The acrylic plate is installed in the middle of the fixed bracket for placing the rice to be tested. Four circular marking points of different colors are respectively affixed to the four corners of the acrylic plate. The color cameras are respectively installed at the upper and lower parts of the fixed bracket, and a ring light source is installed in front of each lens of the color camera.
3. The method according to claim 2, characterized in that According to the front image and the back image of the rice, a multi-channel rice image is obtained by perspective transformation and image fusion, including: Detecting circular marker points of the front image and the back image respectively, and calculating the perspective transformation matrix of the front image and the back image according to the detection results of the circular marker points; Using the perspective transformation matrix, perspective transformation is performed on the front image and the back image respectively, and the resolution of the front image and the back image after perspective transformation is made consistent, and both are three-channel color images; The perspective-transformed front image and back image are fused to obtain a six-channel rice image.
4. The method according to claim 3, characterized in that The rice chalkiness recognition model is obtained based on training of the YOLOv8 network and the Unet network. The rice chalkiness detection model adopts a cascade detection and segmentation strategy to achieve high-precision recognition of rice chalkiness areas. The strategy includes the following steps: In the primary detection phase, a multi-channel rice image is fed into the trained YOLOv8 network to obtain the location information of each rice grain and whether it is chalky. In the precise segmentation stage, for target areas identified as chalky rice, ROI cropping is performed based on the detection frame coordinates and scale normalization is performed. The cropped image is then input into the trained UNet network, which outputs the corresponding chalky area mask. In the spatial mapping stage, the original position and scaling parameters during the cropping process are recorded, and the segmentation results are restored to the original image coordinates through the spatial mapping algorithm, achieving accurate positioning and visual annotation of the chalky area on the detection image.
5. The method according to claim 4, characterized in that In the primary detection stage, rectangular boxes are annotated based on the backlit rice images. Each grain of rice is labeled as chalky or non-chalky. A detection training dataset is constructed and fed into the YOLOv8 network for training. In the precision segmentation phase, the training data comes from the chalky rice candidate regions output by the YOLOv8 network. After ROI cropping and scaling the regions, the chalky regions in the cropped images are finely annotated using polygons to construct a segmentation dataset and train the UNet network. In the inference stage, the chalky mask output by UNet is combined with the cropping position information recorded in the detection stage, and a spatial inverse mapping operation is used to accurately restore the mask to the corresponding position in the original image, thereby achieving accurate identification of the chalky area of each grain of rice.
6. A rice chalkiness identification device, characterized in that: The device comprises: An acquisition module is used to respectively acquire a front image and a back image of rice under backlight conditions using a pre-built rice chalky image acquisition system; An acquisition module is used to obtain a multi-channel rice image through perspective transformation and image fusion according to the front image and the back image of the rice; The recognition module is used to input the multi-channel rice image into a pre-trained rice chalkiness detection model, adopt a cascade detection and segmentation strategy, and output the recognition result of each rice grain.
7. The device according to claim 6, characterized in that The rice chalkiness image acquisition system comprises: a fixed bracket, a transparent acrylic plate, a color camera and a white ring light source; The acrylic plate is installed in the middle of the fixed bracket for placing the rice to be tested. Four circular marking points of different colors are respectively affixed to the four corners of the acrylic plate. The color cameras are respectively installed at the upper and lower parts of the fixed bracket, and a ring light source is installed in front of each lens of the color camera.
8. The device according to claim 7, characterized in that The obtaining module is specifically used for: Detecting circular marker points of the front image and the back image respectively, and calculating the perspective transformation matrix of the front image and the back image according to the detection results of the circular marker points; Using the perspective transformation matrix, perspective transformation is performed on the front image and the back image respectively, and the resolution of the front image and the back image after perspective transformation is made consistent, and both are three-channel color images; The perspective-transformed front image and back image are fused to obtain a six-channel rice image.
9. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 5 when executed.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
A rice chalkiness detection system based on image salient region extraction method
CN112070741B
Rice chalkiness detection method and system
CN114689527A