A method for distinguishing and locating the center of rice seedling and weed stems in rice fields based on a two-stage segmentation model

Through the two-stage segmentation model and the attention mechanism, the accuracy problem of distinguishing and positioning the centers of seedlings and weed stems in the rice field is solved, the positioning accuracy and operation quality of the weeding machinery are improved, and the center positioning of the seedlings and weed stems in the rice field is realized. precise distinction.

CN117496353BActive Publication Date: 2024-09-27ANHUI AGRICULTURAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311516295.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-13
Publication Date
2024-09-27
Estimated Expiration
2043-11-13

AI Technical Summary

Technical Problem

In rice fields, existing technology is difficult to accurately distinguish and locate the stem centers of seedlings and weeds. Especially under different lighting conditions, the feature extraction capabilities of deep learning models are insufficient, resulting in low positioning accuracy of weeding machinery.

Method used

Using a method based on a two-stage segmentation model, through image collection, annotation, color feature extraction, segmentation model construction and instance segmentation model Mask R-CNN combined with the attention mechanism, the differentiation and positioning of weed stem centers in rice field seedlings was achieved. Specific steps include image collection, data annotation, color feature extraction, segmentation model training, data enhancement and attention mechanism introduction, and building a loss function to optimize model performance.

Benefits of technology

It improves the accurate positioning and operation quality of weeding agencies. Through the combination of multiple image color features and spatial constraints, it achieves precise distinction between the centers of seedlings and weed stems, reduces the impact of light, and enhances the sensitivity of feature extraction. .

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117496353B
    Figure CN117496353B
Patent Text Reader

Abstract

This invention discloses a method for distinguishing and locating the stem centers of rice seedlings and weeds in paddy fields based on a two-stage segmentation model. By constructing a segmentation model for rice seedlings and weeds under different lighting conditions and with various image color feature combinations and spatial constraints, the method achieves the segmentation of plants from the background in the image. Furthermore, an attention mechanism is introduced into the image feature extraction layer of the instance segmentation model Mask R-CNN to achieve a model for distinguishing and locating the stem centers of rice seedlings and weeds. Based on the attention mechanism, the method explores the design of a feature extractor with sensitive expressive capabilities, enabling the network to automatically learn the importance of each feature, focusing on features relevant to the target while suppressing features irrelevant to the target. This achieves the distinguishing and locating of the stem centers of seedlings and weeds, providing effective support for weeding machinery to remove weeds between plants. It improves the accuracy of automatic weed location by weeding mechanisms and enhances the operational quality of weeding machinery.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of deep learning and machine vision technology. Specifically, the present invention relates to a method for distinguishing and locating the center of rice seedlings and weed stems based on a two-stage segmentation model. Background Art

[0002] Rice is the main food crop in my country. During the growth of rice, weeds are the main limiting factor for rice production. Among the weeding methods, mechanical weeding is an environmentally friendly green weeding method that can effectively alleviate the harm caused by current chemical weeding. The weeding machinery is precisely controlled to remove weeds between plants according to the position of the seedlings and weeds. The distinction and positioning of rice seedlings and weeds is an extremely critical link, and the accuracy of its positioning directly affects the operation quality of the weeding mechanism.

[0003] Machine vision has the advantages of complete and rich information, non-contact measurement, and low price and cost. It has become a mainstream crop plant detection and positioning technology. In order to identify and locate crop plants, some scholars (Computers and Electronics in Agriculture, 2020, 169: 1-12) identify crops by extracting color, texture, shape and other features from crop images, and obtain the location information of target crops on this basis. Compared with traditional methods, deep learning models have been widely used in agricultural fields such as crop segmentation, plant classification, and fruit recognition due to their excellent feature learning capabilities. However, deep learning models are data-driven learning methods, and rice and various weeds coexist in paddy fields, especially the grass weeds in paddy fields are similar in morphology to rice, and the distinguishing information is only hidden in tiny details. The feature extractor of the deep learning model is required to have a more sensitive feature extraction capability, and there is a sufficiently clear large data set to train the deep learning model. Therefore, how to obtain the feature expression that is closest to the natural properties of seedlings and robust to lighting based on the characteristics of rice images, and effectively eliminate or reduce the influence of lighting and the morphological similarity of seedlings and weeds on the seedling positioning accuracy in image processing is the key technical problem faced by mechanical weeding between rice fields. Summary of the invention

[0004] The present invention provides a method for distinguishing and locating the centers of rice seedling weed stems based on a two-stage segmentation model to solve the problems existing in the above-mentioned background technology.

[0005] In order to achieve the above object, the technical solution adopted by the present invention is: a method for distinguishing and locating the center of rice seedling weed stems based on a two-stage segmentation model, which specifically includes the following steps:

[0006] Step S1: Building an image acquisition system, including a computer and an industrial camera installed on a mobile platform, using the industrial camera to vertically downwardly acquire images of rice seedlings and weeds under different lighting conditions in the rice field, and transmitting the images to the computer for analysis and processing;

[0007] Step S2: Labeling of seedlings and weeds: Labeling is used to manually label the seedlings and weeds and background in the seedlings and weeds image dataset under different lighting conditions, and the dataset is divided into a training set and a validation set.

[0008] Step S3: Extracting color feature vectors of seedling and weed images. In the seedling and weed images, the RGB images under different lighting conditions are converted into ExG, NDI, VEG, S / V and ExCg images through the color index conversion formula. The color features corresponding to the R, G, B, H, S, V, ExG, NDI, VEG, S / V, Cg and ExCg images form a 12-dimensional feature vector, and the feature dimensionality reduction method is used to extract the key color feature parameters of the seedling and weed images.

[0009] Step S4: constructing a rice seedling, weed plant and background segmentation model. Combining the neighborhood space consistency and the binary classification model of the image, a rice seedling, weed plant and background segmentation model with a neighborhood space consistency constraint is constructed. The color feature component corresponding to the rice seedling, weed plant training set image is used as the segmentation model input. The corresponding rice seedling, weed plant label image is used as supervision to train the segmentation model. The segmentation model parameters are optimized based on the classification results of the validation set image.

[0010] Step S5: preparing a data set of stem centers of seedlings and weeds, performing data enhancement on the separately collected seedlings and weeds images, classifying the seedlings and weeds plants and background pixels in the image based on the segmentation model of step S4, obtaining a seedlings and weeds plant binary image, using it as a mask for the seedlings and weeds image, and marking the stem centers of the seedlings and weeds respectively;

[0011] Step S6: Based on the instance segmentation model Mask R-CNN and the attention mechanism, the center of the rice seedling weed stems is distinguished and located based on the rice seedling weed plant and background segmentation results;

[0012] Step S7: define the loss function of the rice field seedling weed stem center differentiation and positioning model, and divide the above-made rice field seedling weed stem center data set into a training set, a validation set and a test set according to a certain ratio, use the training set and the validation set to train the rice field seedling weed stem center differentiation and positioning model, and evaluate the model performance in combination with the test set.

[0013] Preferably, in step S3, the color feature vector of the seedling weed image is extracted, and the ExG, NDI, and VEG images are extracted in the RGB color space through the color index conversion formula, and the RGB image is converted to the HSV color space that conforms to the visual characteristics of the human eye, and the S / V image is extracted, and the RGB image is converted to the YCrCb space to extract the ExCg image, wherein the calculation formulas of ExG, NDI, VEG, and ExCg are as follows:

[0014]

[0015]

[0016] ExCg=2Cg-Cr-Cb;

[0017]

[0018] Preferably, in step S3, the color features of the rice seedling and weed image are extracted, and the correlation coefficients of the 12-dimensional feature vectors [R, G, B, H, S, V, ExG, NDI, VEG, S / V, Cg, ExCg] are calculated using the Pearson correlation analysis algorithm, and the strongly correlated feature parameters are retained, wherein the correlation coefficient calculation formula of any two features is as follows:

[0019]

[0020] Where: X k and Y k are the k-th data of features X and Y respectively; M is the total amount of data in the feature.

[0021] Preferably, in step S4, the rice seedling, weed plant and background segmentation model is constructed based on the similarity of the image space neighborhood pixels and the support vector machine SVM classification model to construct a rice seedling, weed plant and background segmentation model with neighborhood space consistency constraints. For any pixel point x in the image, its n neighborhood is represented by N n (x), calculate the pixel point x and its neighborhood N n (x) Similarity of pixels S j (x,x j ), which is calculated as follows:

[0022]

[0023] Where: η c is the grayscale value of pixel x; η i is the grayscale value of the pixel in the neighborhood of x; η ij is the neighborhood N n (x) is the pixel value of the n-neighborhood pixel i of the j-th pixel; η cj is the neighborhood N n(x) is the pixel value of the n-neighborhood pixel c of the j-th pixel; N is the number of neighboring pixels;

[0024] The pixel neighborhood spatial information fusion weight is set based on the neighborhood similarity, and the pixel neighborhood spatial information is fused into the SVM classification model. The calculation formula of the SVM classification model is as follows:

[0025]

[0026] Where: α represents the Lagrange coefficient; m is the number of data sets; σ is the variance; y t is the category label corresponding to the sample image, plant and background; l is the number of categories corresponding to the sample image; F t (x) is the feature vector of pixel x with neighborhood space constraints. The feature vector of pixel x is defined as f t (x), F l (x) is the feature vector of pixel i with neighborhood space constraints, then F t (x) is calculated as follows:

[0027]

[0028] Preferably, in step S5, the stem center dataset of rice seedlings and weeds is prepared, characterized in that the collected image is subjected to brightness adjustment, contrast enhancement, and geometric transformation using a Python script, the image after data enhancement is segmented into plant pixels in the image using the plant background classification model, and the segmented rice seedlings and weeds image is marked with stem centers using the annotation tool VGG Image Annotator, the plant center is represented by a circular area to define the stem center of the plant, and the seedlings and weed individuals are marked with masks respectively, and the annotated image dataset is divided into a training set, a validation set, and a test set according to a preset ratio.

[0029] Preferably, in step S6, a rice field seedling weed stem center differentiation positioning model is constructed; an attention mechanism is introduced into the image feature extraction layer of the instance segmentation model Mask R-CNN, and a feature learning module guided by the attention mechanism is constructed, and the feature learning module is composed of an upper-layer position attention mechanism PAM and a lower-layer channel attention mechanism CAM, wherein PAM and CAM are defined as follows:

[0030]

[0031] Where: and Respectively represent the feature maps after average pooling and maximum pooling of the input feature image; in the position attention mechanism, After dimension splicing, the position attention map is generated through a 7×7 convolution layer PAM (F); In the channel attention mechanism, and Through a shared network composed of a multi-layer perceptron MLP with hidden layers, the output feature vector is fused by bitwise addition to generate a channel attention map Attention CAM (F); W0 and W1 are the weight sizes of MLP; Sig represents the Sigmoid function.

[0032] Preferably, in step S7, a loss function of the rice field seedling weed stem center differentiation positioning model is defined to construct a composite loss function, and its calculation formula is as follows:

[0033]

[0034] Where: is the class-weighted loss function; is the average intersection-over-union loss function; is the structural similarity loss function;

[0035] For each category, the proportion of the target area in the image is calculated to assign different weights to balance the imbalance between the target area and the background in the image. The calculation is as follows:

[0036]

[0037] Where: k is the category index; a is the pixel index; Y + represents the k-th target pixel set; Y - represents the set of non-k-th target pixels; k

[0038] y a is the ground truth value of pixel a in the kth class; p a k is the predicted value of pixel a in the kth category;

[0039] is to compare the similarity between the ground truth and the predicted result, which is calculated as follows:

[0040]

[0041] The beneficial effects of adopting the above technical solution are:

[0042] 1. The method for distinguishing and locating the center of the stem of rice seedlings and weeds in a rice field based on a two-stage segmentation model of the present invention is based on the different representation capabilities of different image features, the spatial connectivity of image pixels, and the relatively unchanged characteristics of the relative position relationship between each pixel. By constructing a rice seedling weed plant segmentation model with a combination of multiple image color features and spatial constraints under different lighting conditions, the segmentation of plants and backgrounds in the image is achieved. On this basis, an attention mechanism is introduced into the image feature extraction layer of the instance segmentation model Mask R-CNN to achieve a distinguishing and locating model for the center of the stem of rice seedlings and weeds in a rice field. While exploring the design of a feature extractor with sensitive expression capabilities based on the attention mechanism, the network can automatically learn the importance of each feature, pay attention to features related to the target and suppress features irrelevant to the target, thereby achieving the distinguishing and locating of the center of the seedling and the center of the weed stem, providing effective support for weeding machinery to remove weeds between plants, and improving the accuracy of automatic weed positioning of the weeding mechanism and the operation quality of the weeding mechanism. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 This is the original seedling picture;

[0044] Figure 2 The result map for the grass seedlings and background markings;

[0045] Figure 3 This is a diagram of the implementation scheme for the segmentation of seedlings and weed plants;

[0046] Figure 4 This is the result diagram of the segmentation of seedlings and weed plants;

[0047] Figure 5 The result map with the centers of the seedlings and weed stems marked;

[0048] Figure 6 A diagram showing the solution for differentiating and locating the center of the seedlings and weed stems;

[0049] Figure 7 A diagram of the implementation scheme for integrating the attention mechanism; DETAILED DESCRIPTION

[0050] The specific implementation methods of the present invention are further explained in detail below by describing the embodiments with reference to the accompanying drawings, with the aim of helping those skilled in the art to have a more complete, accurate and in-depth understanding of the concept and technical solution of the present invention and facilitating its implementation.

[0051] like Figures 1 to 7 As shown, the present invention is a method for distinguishing and locating the center of rice seedling weed stems based on a two-stage segmentation model. The specific working method is described below using a specific embodiment:

[0052] Embodiment 1:

[0053] Step S1: Building an image acquisition system, including a computer and an industrial camera installed on a mobile platform, using the industrial camera to vertically downwardly acquire images of rice seedlings and weeds under different lighting conditions in the rice field, and transmitting the images to the computer for analysis and processing;

[0054] Step S2: Labeling of seedlings and weeds. Labeling is used to manually label the seedlings, weeds and background of the seedlings and weeds image dataset under different lighting conditions. Figure 2 As shown, white pixels are seedlings and weeds, black pixels are background, and the labeled image samples are divided into training set and validation set;

[0055] Step S3: Extracting color feature vectors of seedling and weed images. In the seedling and weed images, the RGB images under different lighting conditions are converted into ExG, NDI, VEG, S / V and ExCg images through the color index conversion formula. The color features corresponding to the R, G, B, H, S, V, ExG, NDI, VEG, S / V, Cg and ExCg images form a 12-dimensional feature vector, and the feature dimensionality reduction method is used to extract the key color feature parameters of the seedling and weed images.

[0056] Step S4: Construction of the seedling weed plant and background segmentation model. Combining the neighborhood spatial consistency and the binary classification model of the image, a seedling weed plant and background segmentation model with neighborhood spatial consistency constraints is constructed. The implementation scheme is as follows: Figure 3 As shown, the color feature components corresponding to the seedling weed plant training set images are used as the segmentation model input, and the corresponding seedling weed plant label image is used as supervision to train the segmentation model, and the segmentation model parameters are optimized based on the classification results of the validation set images;

[0057] Step S5: Prepare a stem center dataset of seedling weeds, perform data enhancement on the separately collected seedling weed images, classify the seedling weed plants and background pixels in the image based on the segmentation model of step S4, and obtain a seedling weed plant binary image, such as Figure 4 As shown in , it is used as a mask for the seedling and weed image to mark the stem centers of the seedling and weed, respectively. Figure 5 As shown;

[0058] Step S6: Based on the instance segmentation model Mask R-CNN and the attention mechanism, a rice field seedling weed stem center differentiation and positioning model is constructed. The model implementation scheme is as follows: Figure 6 As shown in the figure, the attention module consists of an upper-layer position attention module PAM and a lower-layer channel attention module CAM. The PAM module is designed to extract class-based correlations from feature maps, while the CAM module improves the feature reconstruction process by weighting class channels to obtain better contextual expression. The implementation scheme of integrating the attention mechanism into the Mask-RCNN model is shown in Figure 7 As shown in the figure, the segmented plant image is fed with feature maps extracted by the backbone network ResNet and input into the PAM and CAM modules, which can make the network model pay more attention to the region of interest, so that the model focuses on the important features to be extracted, including the feature maps of position and channel context information, ignores irrelevant features, and obtains features that have the ability to discriminate the seedlings in the image;

[0059] Step S7: define the loss function of the rice field seedling weed stem center differentiation and positioning model, and divide the above-made rice field seedling weed stem center data set into a training set, a validation set and a test set according to a certain ratio, use the training set and the validation set to train the rice field seedling weed stem center differentiation and positioning model, and evaluate the model performance in combination with the test set.

[0060] The present invention is described above by way of example in conjunction with the accompanying drawings. Obviously, the specific implementation of the present invention is not limited to the above-mentioned method. As long as various non-substantial improvements are made using the method concept and technical solution of the present invention; or the above-mentioned concept and technical solution of the present invention are directly applied to other occasions without improvement, they are all within the protection scope of the present invention.

Claims

1. A method for distinguishing and locating the center of rice seedling and weed stems based on a two-stage segmentation model. Features: The specific steps include: Step S1: Building an image acquisition system, including a computer and an industrial camera installed on a mobile platform, using the industrial camera to vertically downwardly acquire images of rice seedlings and weeds under different lighting conditions in the rice field, and transmitting the images to the computer for analysis and processing; Step S2: Labeling of seedlings and weeds: Labeling is used to manually label the seedlings and weeds and background in the seedlings and weeds image dataset under different lighting conditions, and the dataset is divided into a training set and a validation set. Step S3: Extracting color feature vectors of seedling and weed images. In the seedling and weed images, the RGB images under different lighting conditions are converted into ExG, NDI, VEG, S / V and ExCg images through the color index conversion formula. The color features corresponding to the R, G, B, H, S, V, ExG, NDI, VEG, S / V, Cg and ExCg images form a 12-dimensional feature vector, and the feature dimensionality reduction method is used to extract the key color feature parameters of the seedling and weed images. Step S4: constructing a rice seedling, weed plant and background segmentation model. Combining the neighborhood space consistency and the binary classification model of the image, a rice seedling, weed plant and background segmentation model with a neighborhood space consistency constraint is constructed. The color feature component corresponding to the rice seedling, weed plant training set image is used as the segmentation model input. The corresponding rice seedling, weed plant label image is used as supervision to train the segmentation model. The segmentation model parameters are optimized based on the classification results of the validation set image. Step S5: preparing a data set of stem centers of seedlings and weeds, performing data enhancement on the separately collected seedlings and weeds images, classifying the seedlings and weeds plants and background pixels in the image based on the segmentation model of step S4, obtaining a seedlings and weeds plant binary image, using it as a mask for the seedlings and weeds image, and marking the stem centers of the seedlings and weeds respectively; Step S6: Based on the instance segmentation model Mask R-CNN and the attention mechanism, the center of the rice seedling weed stems is distinguished and located based on the rice seedling weed plant and background segmentation results; Step S7: defining a loss function of a rice field seedling weed stem center distinguishing and positioning model, and dividing the rice field seedling weed stem center data set prepared above into a training set, a validation set and a test set according to a certain ratio, using the training set and the validation set to train the rice field seedling weed stem center distinguishing and positioning model, and combining the test set to evaluate the model performance; In the step S3, the color feature vector of the seedling weed image is extracted, and the ExG, NDI, and VEG images are extracted in the RGB color space through the color index conversion formula, and the RGB image is converted to the HSV color space that conforms to the visual characteristics of the human eye, and the S / V image is extracted. The RGB image is converted to the YCrCb space and the ExCg image is extracted, wherein the calculation formulas of ExG, NDI, VEG, and ExCg are as follows: ExCg=2Cg-Cr-Cb; In step S3, the color features of the seedling and weed image are extracted, and the correlation coefficient of the 12-dimensional feature vector [R, G, B, H, S, V, ExG, NDI, VEG, S / V, Cg, ExCg] is calculated using the Pearson correlation analysis algorithm, and the feature parameters with strong correlation are retained. The correlation coefficient calculation formula of any two features is as follows: Where: X k and Y k are the kth data of feature X and Y respectively; M is the total amount of data in the feature; In step S4, the rice seedling, weed plant and background segmentation model is constructed. Based on the similarity of the pixels in the neighborhood of the image space and the support vector machine (SVM) classification model, a rice seedling, weed plant and background segmentation model with neighborhood space consistency constraints is constructed. For any pixel point x in the image, its n neighborhood is represented by N n (x), calculate the pixel point x and its neighborhood N n (x) Similarity of pixels S j (x,x j ), which is calculated as follows: Where: η c is the grayscale value of pixel x; η i is the grayscale value of the pixel in the neighborhood of x; η ij is the neighborhood N n (x) is the pixel value of the n-neighborhood pixel i of the j-th pixel; η cj is the neighborhood N n (x) is the pixel value of the n-neighborhood pixel c of the j-th pixel; N is the number of neighboring pixels; The pixel neighborhood spatial information fusion weight is set based on the neighborhood similarity, and the pixel neighborhood spatial information is fused into the SVM classification model. The calculation formula of the SVM classification model is as follows: Where: α represents the Lagrange coefficient; m is the number of data sets; σ is the variance; y t is the category label corresponding to the sample image, plant and background; l is the number of categories corresponding to the sample image; F t (x) is the feature vector of pixel x with neighborhood space constraints. The feature vector of pixel x is defined as f t (x), F l (x) is the feature vector of pixel i with neighborhood space constraints, then F t (x) is calculated as follows: In the step S6, a rice field seedling weed stem center differentiation positioning model is constructed; an attention mechanism is introduced into the image feature extraction layer of the instance segmentation model Mask R-CNN, and a feature learning module guided by the attention mechanism is constructed. The feature learning module is composed of an upper-layer position attention mechanism PAM and a lower-layer channel attention mechanism CAM, wherein PAM and CAM are defined as follows: Where: and Respectively represent the feature maps after average pooling and maximum pooling of the input feature image; in the position attention mechanism, After dimension splicing, the position attention map is generated through a 7×7 convolution layer PAM (F); In the channel attention mechanism, and Through a shared network composed of a multi-layer perceptron MLP with hidden layers, the output feature vector is fused by bitwise addition to generate a channel attention map Attention CAM (F); W 0 and W 1 is the weight size of MLP; Sig represents the Sigmoid function.

2. The method for distinguishing and locating the center of rice seedlings and weed stems based on a two-stage segmentation model according to claim 1, Features: In the step S5, the stem center dataset of rice seedlings and weeds is prepared, which is characterized in that the collected image is brightness adjusted, contrast enhanced, and geometrically transformed by using Python scripts, the image after data enhancement is segmented into plant pixels in the image by the above-mentioned plant background classification model, and the segmented rice seedlings and weeds image is marked with stem centers by using the annotation tool VGG Image Annotator, the plant center is represented by a circular area to define the stem center of the plant, and the seedlings and weeds are marked with masks respectively, and the annotated image dataset is divided into a training set, a validation set, and a test set according to a preset ratio.

3. The method for distinguishing and locating the center of rice seedlings and weed stems based on a two-stage segmentation model according to claim 1, Features: In step S7, a loss function of the rice field seedling weed stem center differentiation positioning model is defined, and a composite loss function is constructed, and its calculation formula is as follows: Where: is the class-weighted loss function; is the average intersection-over-union loss function; is the structural similarity loss function; For each category, the proportion of the target area in the image is calculated to assign different weights to balance the imbalance between the target area and the background in the image. The calculation is as follows: Where: k is the category index; a is the pixel index; Y + represents the k-th target pixel set; Y - represents the set of non-k-th target pixels; y a k is the ground truth value of pixel a in the kth class; p a k is the predicted value of pixel a in the kth class; is to compare the similarity between the ground truth and the predicted result, which is calculated as follows: