Weed image segmentation method

Through local variance calculation, nonlinear normalization, Laplace operator and adaptive threshold segmentation, the texture and edge characteristics of weed images are enhanced, and the problem of insufficient weed segmentation accuracy in traditional methods in complex environments is solved, and high-precision weed object detection is achieved.

CN120235893APending Publication Date: 2025-07-01INNER MONGOLIA UNIV OF TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510170898.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-17
Publication Date
2025-07-01

AI Technical Summary

Technical Problem

Traditional weed image segmentation methods are difficult to accurately distinguish weeds from backgrounds in complex natural environments, especially in the case of uneven light or severe changes. Traditional super-green feature extraction methods cannot effectively distinguish non-green weeds from backgrounds, resulting in high false detection rates.

Method used

The combination of local variance calculation, nonlinear normalization processing, Laplace operator enhancement edge information, adaptive threshold segmentation and morphological operation is adopted to enhance the texture and edge characteristics of weed area images, and improve segmentation accuracy and robustness.

Benefits of technology

Effectively detect non-green weeds in complex environments, reduce the false detection rate, and improve the accuracy and robustness of weed image segmentation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120235893A_ABST
    Figure CN120235893A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a weed image segmentation method, and the method comprises the steps: carrying out the region-of-interest extraction of an input image, so as to obtain a weed region image; calculating a local variance of the weed region image, and performing nonlinear normalization processing on the local variance to obtain a feature-enhanced weed region image; edge information of the weed area image after feature enhancement is enhanced by using a Laplace operator, and binarization processing is performed on local features of the weed area image after edge information enhancement by using adaptive threshold segmentation; and performing de-noising processing on the binarized weed region image by using morphological operation, and segmenting the de-noised weed region image to obtain a weed target in the weed region image. According to the method, the defects existing when a traditional ultra-green feature method is applied to weed image segmentation are overcome, higher adaptability is achieved, and the method can be widely applied to the fields of precision agriculture, intelligent monitoring and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and particularly to a method for segmenting weed images. Background Art

[0002] In weed control, weed image segmentation is a key technology for achieving precise weeding and improving control efficiency. However, traditional image segmentation methods face many challenges in practical applications, especially in complex natural environments where they show insufficient adaptability.

[0003] First, the color features of different crops and weeds are often very similar. There is a high overlap in the gray-scale distribution and color components between different types of weed backgrounds and green weeds, which makes it difficult for segmentation algorithms that rely solely on single-color or gray-scale information to accurately distinguish weeds from their backgrounds. Especially in situations with uneven or rapidly changing lighting conditions, such color-feature-dependent segmentation algorithms are easily interfered by strong light, shadows, or reflections, resulting in a decrease in the accuracy of weed segmentation.

[0004] Second, there are a wide variety of weed species, and their growth states and morphological characteristics also vary. Some weeds may have relatively obvious green features, while other weeds (such as withered grass or weeds with color changes) may exhibit non-green features such as red, yellow, or brown. Traditional detection methods relying on super-green features are ineffective for such weeds, resulting in a relatively high missed detection rate. In addition, the edges of weeds usually show irregular shapes, while the background may contain similar texture features, which increases the difficulty of the segmentation algorithm in shape and texture analysis.

[0005] Third, background complexity is also an important factor affecting the segmentation effect. In actual scenarios, the background may be mixed with non-vegetation targets such as soil, stones, and moss. These background targets may exhibit color or texture features similar to those of weeds in some cases, thus interfering with the judgment of the segmentation algorithm. In addition, there may be uneven lighting or reflection in some areas, making the boundaries of weed targets blurred, further increasing the complexity of segmentation. Summary of the Invention

[0006] The objective of the embodiments of the present invention is to provide a method for segmenting weed images to solve the technical problems existing in the above-mentioned prior art.

[0007] To achieve the above object, an embodiment of the present invention provides a weed image segmentation method, which includes: extracting a region of interest from an input image to obtain a weed region image; calculating the local variance of the weed region image, and performing non-linear normalization on the local variance to obtain the weed region image with enhanced features; using a Laplacian operator to enhance the edge information of the weed region image with enhanced features, and performing binary processing on the local features of the weed region image with enhanced edge information using an adaptive threshold segmentation; and using morphological operations to denoise the weed region image after binary processing, and segmenting the denoised weed region image to obtain weed targets in the weed region image.

[0008] Optionally, the extracting a region of interest from the input image includes: calculating the super green index of the input image, and obtaining a binary image according to the super green index using the OTSU algorithm; performing an AND operation on the input image and the binary image to obtain the weed region image.

[0009] Optionally, the calculating the local variance of the weed region image includes: selecting a pixel point with coordinates (x, y) in the weed region image, taking this pixel point as the center, and selecting a square window with a size of 3×3 as the calculation domain of the local variance; calculating the gray value of this pixel point and the gray mean value of 9 pixel points within the square window, and calculating the local variance of this pixel point according to the formula. The calculation formula is:

[0010]

[0011] where ν(x,y) is the local variance of this pixel point, and f(x-i,y-i) is the gray value of the pixel point with coordinates (x-i,y-i) centered on this pixel point (x,y), is the gray mean value of 9 pixel points within the square window.

[0012] Optionally, the performing non-linear normalization on the local variance to obtain the weed region image with enhanced features includes: performing non-linear normalization on the local variance to obtain a non-linear normalized variance. The calculation formula is:

[0013]

[0014] where V(x,y) is the non-linear normalized variance, a and b are non-linear normalization coefficients, and ν(x,y) is the local variance of the pixel point;

[0015] The calculation formula of the weed region image with enhanced features is:

[0016]

[0017] Among them, f ExG (x, y) is the image of the weed area, and V ExG (x, y) is the image after calculating the non-linear normalized local variance of the weed area image. k and m are optimization coefficients, satisfying k > 0 and 0 < m < 1.

[0018] Optionally, enhancing the edge information of the weed area image after the feature enhancement using the Laplace operator includes: calculating the second-order derivative of each pixel point of the weed area image after the feature enhancement using the Laplace operator to obtain the edge information of the image. The expression of the Laplace operator is:

[0019]

[0020] Among them, ΔI(x, y) is the Laplace operator, and I(x, y) represents the pixel value at the position (x, y) in the image. and respectively represent the second-order derivatives of this point in the x and y directions.

[0021] Optionally, using adaptive threshold segmentation to binarize the local features of the weed area image after the enhanced edge information includes: dividing the weed area image after the enhanced edge information into multiple windows, calculating the average pixel value within each window, and determining the local threshold of the pixel point according to the average pixel value. The calculation formula of the local threshold is:

[0022] T(x, y) = Mean(x, y) - C

[0023] Among them, T(x, y) is the local threshold of the pixel point (x, y), Mean(x, y) is the average pixel value of the window centered on the pixel point (x, y), and C is a constant used to adjust the threshold;

[0024] When the local pixel value of the image is greater than the local threshold, the pixel is set to 255, otherwise it is set to 0.

[0025] Optionally, using morphological operations to denoise the binarized weed area image includes: performing an erosion operation on the binarized weed area image and calculating the intersection of the structural element and the local area of the image. The calculation formula is:

[0026]

[0027] Among them, I represents the binarized weed area image, (x, y) represents the pixel point in the weed image, and S is the structural element. The erosion operation is represented, min(I(x′, y′)) represents the minimum value of the pixel points in the weed image within the coverage of the structural element, and forall(x′, y′) represents all the pixel points in the weed image within the coverage of the structural element;

[0028] Perform a dilation operation on the image after the erosion operation, and calculate the union of the structural element and the image after the erosion operation. Its calculation formula is:

[0029] Dilation(I) = (I ⊕ S)(x, y) = max(I(x′, y′)) forall(x′, y′) ∈ S

[0030] Wherein, ⊕ represents the dilation operation, and max(I(x′, y′)) represents the maximum value of the pixel points in the weed image within the coverage of the structural element.

[0031] Optionally, after obtaining the weed area image, the method further includes: obtaining the G - component histogram of the weed area image, and analyzing the number of weeds in the weed area image according to the maximum peak in the G - component histogram.

[0032] On the other hand, the present invention provides a machine - readable storage medium, on which instructions are stored, and these instructions are used to cause a machine to execute any one of the above - mentioned weed image segmentation methods of the present application.

[0033] On the other hand, the present invention provides a processor for running a program, wherein when the program is run, it is used to execute: the weed image segmentation method according to any one of claims 1 - 8.

[0034] Through the above - mentioned technical solutions, the present invention first performs an operation on the input image to obtain the region of interest, so as to extract the weed area image, thereby avoiding the deviation of the segmentation region caused by the influence of other crops in the input image. By calculating the local variance of the weed area image, the detailed changes in the image can be accurately captured, thereby enhancing the distinction between the weed target and the background. Especially in a complex environment, the occurrence of false detection is avoided. Through non - linear normalization and Laplacian operator enhancement, the texture and edge features of the image are further improved, ensuring that even when the weeds present non - green features, the target can still be effectively detected. By combining adaptive threshold segmentation and morphological operations, the accuracy and robustness of weed image segmentation are improved.

[0035] Other features and advantages of the embodiments of the present invention will be described in detail in the subsequent specific implementation part. Description of the Drawings

[0036] The accompanying drawings are used to provide a further understanding of the embodiments of the present invention and form a part of the specification. Together with the following detailed description, they are used to explain the embodiments of the present invention, but do not constitute a limitation on the embodiments of the present invention. In the accompanying drawings:

[0037] Figure 1 It is a schematic flowchart of a weed image segmentation method provided by an embodiment of the present invention;

[0038] Figure 2 It is a visualization result diagram of extracting a region of interest from an input image provided by an embodiment of the present invention. Figure 2 Part (a) in it is the input color image. Figure 2 Part (b) in it is the image obtained by extracting the green component from the input image. Figure 2 Part (c) in it is the binary image obtained by using the Otsu algorithm. Figure 2 Part (d) in it is the weed region image.

[0039] Figure 3 It is the grayscale image of the G component of the weed region image provided by an embodiment of the present invention and the corresponding G component histogram.

[0040] Figure 4 It is a visualization result diagram of not using the weed image segmentation method provided by the embodiments of the present disclosure to segment weed targets provided by an embodiment of the present invention.

[0041] Figure 5 It is a visualization result diagram of using the weed image segmentation method provided by the embodiments of the present disclosure to segment weed targets provided by an embodiment of the present invention. Detailed Description

[0042] Intelligent weeding robots combine advanced technologies such as machine vision, artificial intelligence, and automatic control. With their high efficiency, precision, and environmental friendliness, they have shown great application potential in agricultural production. The robot is equipped with high-precision cameras and sensors to collect real-time image data of the field, and uses image processing algorithms to identify and distinguish weeds from crops. In this process, the image processing system uses technologies such as deep learning, pattern recognition, and image segmentation to analyze the images. Through deep learning of the morphological, color, and texture features of plants, it can effectively distinguish weeds from crops, accurately identify the weeds that need to be removed, and plan the optimal path for the robot to avoid crops and accurately weed. Existing technologies have carried out extensive research on weed recognition methods based on machine vision and have achieved rich research results in both traditional machine learning algorithms and deep learning algorithms. However, the current research on lawn weed recognition methods mainly focuses on broad-leaved weeds or single-variety narrow-leaved weeds with a large difference from the weed background, and the versatility of the recognition algorithm needs to be improved. In the natural environment, the color of weeds is similar to that of the weed background, and it is difficult to segment and identify the target. There is still room for improvement in the segmentation and recognition accuracy of the current image segmentation algorithms.

[0043] Most existing technologies use the super-green feature to extract weed targets in images. However, traditional super-green feature extraction methods cannot distinguish similar green targets because in actual scenarios, different types of weeds, green crops, or some reflective green objects may exhibit green components similar to those of weeds, resulting in false detection problems. This is because the super-green feature only relies on single green component information and does not combine shape, texture, or context features, resulting in insufficient discrimination ability in complex environments. In addition, since many weeds will exhibit non-green features such as red, yellow, and brown at different growth stages or in different environments, especially withered weeds, due to insufficient moisture or aging, their green component is low or even close to the background, and it is difficult for the super-green feature extraction method to achieve accurate detection.

[0044] Based on this, the embodiments of the present invention aim to solve two main deficiencies of existing super-green features in weed target extraction. First, the super-green feature only depends on the green component (G channel). This single information source makes it impossible to effectively distinguish other targets with similar green features in the actual scene, such as green crops, reflective green objects, etc., resulting in misdetection problems. To overcome this defect, the method provided by the embodiments of the present invention introduces a local variance calculation method, which can capture the changes in image details and textures. This not only enhances the detail expressiveness but also improves the distinguishability between green targets and the background, especially in complex environments. Second, the super-green feature is ineffective for withered grass or weeds at different growth stages. The embodiments of the present invention further strengthen the texture and edge features of the image by introducing non-linear normalization processing and Laplacian operator enhancement technology, so that even weeds with color changes or withered yellow can be detected. To further improve the detection accuracy, the embodiments of the present invention also combine adaptive threshold segmentation and morphological operations to eliminate the noise in the image and optimize the contour and details of the target.

[0045] The following will describe in detail the specific implementation manners of the embodiments of the present invention with reference to the accompanying drawings. It should be understood that the specific implementation manners described herein are only used to illustrate and explain the embodiments of the present invention, and are not used to limit the embodiments of the present invention.

[0046] It should be noted that the acquisition, transmission, storage, use, processing, etc. of data in the technical solution of this application all comply with the relevant regulations of national laws and regulations. In the embodiments of this application, some industry-existing solutions such as certain software, components, models, etc. may be mentioned. They should be regarded as exemplary, and their purpose is only to illustrate the feasibility in the implementation of the technical solution of this application, but it does not mean that the applicant has already or necessarily used this solution.

[0047] Figure 1 is a schematic flowchart of a weed image segmentation method provided by the embodiments of the present invention. As Figure 1 shown, the weed image segmentation method provided by the embodiments of the present invention includes:

[0048] Step S1: Extract the region of interest from the input image to obtain a weed region image;

[0049] Step S2: Calculate the local variance of the weed region image, and perform non-linear normalization processing on the local variance to obtain the weed region image with enhanced features;

[0050] Step S3: Use the Laplacian operator to enhance the edge information of the weed region image with enhanced features, and perform binary processing on the local features of the weed region image with enhanced edge information using adaptive threshold segmentation;

[0051] Step S4: Use morphological operations to denoise the binarized weed area image;

[0052] Step S5: Segment the denoised weed area image to obtain weed targets in the weed area image.

[0053] Specifically, in this method, the region of interest of the input image is extracted to obtain the weed area image. This is because the main targets in the input image of the actual scene captured by the intelligent weeding robot trolley are crops and weeds. However, in the natural environment, objects such as withered grass and bare soil that are not directly related to weed detection may still randomly appear in the camera's field of view. Therefore, the captured image should undergo some preprocessing procedures to extract the region of interest in the input image. Otherwise, due to the large difference in distinguishability between targets such as fallen leaves, withered grass, and crops and weed targets, the segmentation region will deviate, and it is impossible to segment out weed targets with color characteristics similar to those of crops.

[0054] In some embodiments, the extraction of the region of interest from the input image includes: calculating the excess green index of the input image, and obtaining a binarized image according to this excess green index using the OTSU algorithm; performing an AND operation on the input image and the binarized image to obtain the weed area image. Specifically, the formula for calculating the excess green index is:

[0055]

[0056] where ExG is the excess green index, and R, G, and B are the gray values of the corresponding components of the input image in the RGB color space, respectively. Figure 2 is the visualization result diagram of the extraction of the region of interest from the input image provided by the embodiments of the present invention. Figure 2 Part (a) in Figure 2 is the input color image. By calculating the excess green index of the input image, an image of the green component extracted from the input image is obtained, as shown in part (b).

[0057] Figure 2 According to the calculated excess green index, the maximum inter-class variance (OTSU) algorithm is used on the image of the extracted green component to obtain a binarized image, as shown in Figure 2 part (c). Finally, an AND operation is performed on the input color image and the binarized image to obtain the weed area image, that is, the region of interest image, as shown in

[0058] Among them, the OTSU algorithm with the maximum between-class variance divides the pixels in the image to be segmented into two categories: foreground pixels and background pixels. Assume that the segmentation threshold is T. The proportion of foreground pixels with gray values greater than T in the image is ω1, and their average gray value is u1; the proportion of background pixels with gray values less than T is ω2, and their average gray value is u2. Then, the expression for the average gray value U of the entire image is:

[0059] U = ω1u1 + ω2u2, s.t. ω1 + ω2 = 1

[0060] At this time, the expression for the between-class variance of the two categories of foreground and background pixels is:

[0061] σ 2 = ω1(u1 - U) 2 + ω2(u2 - U) 2

[0062] For the weed image, the optimal segmentation threshold can be expressed as Equation

[0063] T = argmax[ω1(u1 - U) 2 + ω2(u2 - U) 2

[0064] In the above formula, T is the optimal binarization threshold of the calculated image, and the argmax function represents the value of T when the maximum value is obtained at σ 2 .

[0065] In some embodiments, after obtaining the weed area image, the method further includes: obtaining the G-component histogram of the weed area image, and analyzing the number of weeds in the weed area image according to the maximum peak in the G-component histogram.

[0066] Specifically, by observing the obtained weed area image, as shown in part (d) of Figure 2 , it can be found that the image is mainly composed of green areas. In this case, the green component (G-component) of the image can significantly reflect the differences between weeds and different crops, where Figure 3 part (a) of Figure 3 is the G-component gray-scale image of the weed area image. On the histogram, this difference is manifested as a bimodal distribution, specifically as shown in part (b) of . This characteristic can provide a reliable basis for subsequent weed detection and treatment. That is to say, if there is only one type of weed in the weed area image, then there will be only one maximum peak corresponding to the G-component histogram; while in the natural environment, there are color differences among different weeds and crops in most cases. In contrast, if there are other weeds and crops in addition to the weeds in the weed area image, at this time, in the G-component histogram, in addition to one maximum peak representing the weed area, another maximum peak will appear.

[0067] Since the leaves of common weeds are relatively wide and sparse, in an image containing weeds, the weeds are the foreground and other plants are the background, with a large grayscale variation. The leaves of the weeds are wide and the grayscale variation is uniform. Since both the weeds and other plants are green, using the G component to further process the image can maintain the integrity of the image information as much as possible. Using local variance to process the image can be used to measure the severity of grayscale variation within a region. In some embodiments, calculating the local variance of the weed region image includes: selecting a pixel point with coordinates (x, y) in the weed region image, taking this pixel point as the center, and selecting a square window with a size of 3×3 as the calculation domain for the local variance;

[0068] Calculating the grayscale value of this pixel point and the grayscale mean value of the 9 pixel points within the square window, and calculating the local variance of this pixel point according to the formula. The calculation formula is:

[0069]

[0070] where ν(x,y) is the local variance of this pixel point, and f(x - i, y - i) is the grayscale value of the pixel point with coordinates (x - i, y - i) centered on this pixel point (x,y); is the grayscale mean value of the 9 pixel points within the square window.

[0071] However, when calculating the local variance using the above formula, the differences between pixels are compressed, resulting in insufficiently obvious data differences. Therefore, it is necessary to normalize the calculated variance. The embodiments of the present invention adopt non - linear normalization processing to achieve a better suppression effect on the plants in the image background (relative to the foreground) and retain the preliminary enhancement effect on the weed target. Therefore, in some embodiments, non - linearly normalizing the local variance to obtain the weed region image after feature enhancement includes: non - linearly normalizing the local variance to obtain a non - linear normalization variance. The calculation formula is:

[0072]

[0073] where V(x,y) is the non - linear normalization variance, a and b are non - linear normalization coefficients. In the embodiments of the present invention, a = 6 and b = 5, and ν(x,y) is the local variance of the pixel point;

[0074] The calculation formula for the weed region image after feature enhancement is:

[0075]

[0076] where f ExG(x, y) is the image of the weed area, and for the image of the weed area f ExG (x, y), the non-linear normalized local variance is calculated using the above formula to obtain V ExG (x, y), which is the image after calculating the non-linear normalized local variance of the weed area image. And through the above formula and the optimization coefficients k and m, the image of the weed area after feature enhancement is calculated. Among them, the optimization coefficients satisfy k > 0, 0 < m < 1. And the larger k is, the more obvious the gray suppression effect on the areas with smaller local variance in the preprocessed image is. m is used to adjust the gain effect at the small variance areas. In the embodiments of the present invention, k = 50 and m = 30 are selected. Of course, the specific values set here are only for illustrative purposes and are not limited. Those skilled in the art can set different values according to actual needs and different usage scenarios.

[0077] It should be noted that in image processing, the Laplacian operator is a second-order differential operator used for edge detection. It strengthens the edge parts in the image by calculating the second-order derivatives of pixel points. When dealing with the weed target segmentation task, edge detection technology can help extract the features in the image, so as to distinguish the weed target from other plants. By enhancing the edge information of the weed target in the image, the Laplacian operator provides clearer visual features for the recognition of the weed target and improves the accuracy of image segmentation. The Laplacian operator is an operator based on the second-order derivative, and its role is to highlight the edge parts in the image. Mathematically, the Laplacian operator is defined as the sum of the second-order derivatives of each point in the image, and it is a scalar value. Therefore, in some embodiments, enhancing the edge information of the image of the weed area after feature enhancement using the Laplacian operator includes: using the Laplacian operator to calculate the second-order derivative of each pixel point of the image of the weed area after feature enhancement to obtain the edge information of the image. The expression of the Laplacian operator is:

[0078]

[0079] where ΔI(x, y) is the Laplacian operator, and I(x, y) represents the pixel value of the point at position (x, y) in the image, and respectively represent the second-order derivatives of this point in the x and y directions.

[0080] The commonly used Laplacian operator kernel (mask) is a 3x3 or 5x5 convolution kernel. The expression of the 3x3 Laplacian operator used in the embodiments of the present invention is:

[0081] Weeds usually exhibit relatively small and intricate morphological characteristics. This Laplacian operator kernel can be used to detect changes in the weed area image, especially the edge parts where the pixel values change drastically. The Laplacian operator can highlight the edge information by calculating the second derivative of the pixels in the image. In the weed image segmentation task, weeds usually have different shape and structural characteristics from the surrounding plants. By enhancing these edge information, the Laplacian operator helps to distinguish the difference between weeds and the background.

[0082] Thresholding is a method for binarizing an image based on pixel values. Its basic idea is to divide the pixel values of the image into two categories by setting a fixed threshold: one category is the pixels greater than the threshold, and the other category is the pixels less than the threshold. The classic global thresholding method works well for uniform images, but for images with different lighting and local characteristics, the effect is often poor. In weed image segmentation, there are usually complex lighting changes and texture differences between weeds, crops, and the background. It is difficult to adapt to the weed image segmentation task using the classic thresholding method. Therefore, the embodiments of the present disclosure can effectively handle these changes and extract the local characteristics of weeds through adaptive thresholding. Adaptive thresholding can perform binarization according to the local regions of the image, thereby reducing the interference of uneven lighting and background complexity on the recognition effect.

[0083] Adaptive thresholding, on the other hand, sets different thresholds for each small region (window) of the image, enabling more precise segmentation within the local region. In some embodiments, the use of adaptive thresholding to binarize the local characteristics of the weed area image after enhancing the edge information includes: dividing the weed area image after enhancing the edge information into multiple windows, setting the window size to w×w, calculating the pixel average value within each window, and determining the local threshold of the pixel point according to the pixel average value. The calculation formula for the local threshold is:

[0084] T(x,y) = Mean(x,y) - C

[0085] where T(x,y) is the local threshold of the pixel point (x,y), Mean(x,y) is the pixel average value of the window centered on the pixel point (x,y), and C is a constant used to adjust the threshold; when the local pixel value of the image is greater than the local threshold, the pixel is set to 255, otherwise it is set to 0. In this way, the influence of uneven lighting on the weed target segmentation effect is avoided.

[0086] It can be understood that, in order to further reduce the noise in the weed image, the embodiments of the present disclosure use morphological operations, especially the opening operation, which plays an important role in removing noise. Since the weed image may contain some small noises or artifacts, the opening operation can effectively remove these irrelevant details and ensure that the main weed part in the image remains intact. In morphological operations, both dilation and erosion rely on a morphological structuring element (usually a small matrix) for performing a sliding window operation on the image.

[0087] In some embodiments, the use of morphological operations to denoise the binary-processed weed area image includes: performing an erosion operation on the binary-processed weed area image, calculating the intersection of the structuring element and the local area of the image, and its calculation formula is:

[0088]

[0089] where I represents the binary-processed weed area image, (x, y) represents the pixel points in the weed image, S is the structuring element, represents the erosion operation, min(I(x′, y′)) represents the minimum value of the pixel points in the weed image based on the range covered by the structuring element, and forall(x′, y′) represents all pixel points in the weed image based on the range covered by the structuring element;

[0090] Performing a dilation operation on the image after the erosion operation, calculating the union of the structuring element and the image after the erosion operation, and its calculation formula is:

[0091] Dilation(I) = (I ⊕ S)(x, y) = max(I(x′, y′)) forall(x′, y′) ∈ S

[0092] where ⊕ represents the dilation operation, and max(I(x′, y′)) represents the maximum value of the pixel points in the weed image based on the range covered by the structuring element.

[0093] It should be noted that the opening operation is to perform the erosion operation first and then the dilation operation, and its expression is:

[0094] Opening(I) = Dilation(Erosion(I))

[0095] where Opening(I) represents the opening operation, Erosion(I) represents performing an erosion operation on the image, and Dilation(·) represents performing a dilation operation on the image.

[0096] In summary, after denoising the weed area image using the above steps, the OTSU algorithm is used again on this image for binarization processing to achieve the segmentation of the foreground and background of the image, and the weed targets in the weed area image are obtained. Figure 4 It is a visualization result diagram of the weed target not segmented by the weed image segmentation method provided by the embodiment of the present invention using the method provided by the embodiment of the present disclosure. Figure 4 Part (a) in it is the input color image. Figure 4 Part (b) in it is the green component image obtained after super-green feature extraction. Figure 4 Part (c) in it is the binary image obtained by directly applying the OTSU algorithm to the green component image obtained by super-green feature extraction. It can be seen that the background interference is relatively obvious, while Figure 5 It is a visualization result diagram of the weed target segmented by the weed image segmentation method provided by the embodiment of the present invention using the method provided by the embodiment of the present disclosure. Figure 5 Part (a) in it is the input color image. Figure 5 Part (b) in it is the green component image obtained after super-green feature extraction. Figure 5 Part (c) in it is the image after adaptive threshold segmentation of the green component image obtained by super-green feature extraction and Figure 5 Part (d) in it is the image after binarization segmentation of the segmented image using the OTSU algorithm. It can be seen that after processing using the method proposed in the embodiment of the present disclosure, the OTSU algorithm can better segment the weed targets in a complex environment where the weeds and nearby plants are green and similar, reflecting the superiority of the method in the embodiment of the present invention.

[0097] It should be noted that for the extraction of image features using the methods of calculating local variance and non-linear normalization provided in the embodiments of the present invention, those skilled in the art can also use texture feature extraction based on wavelet transform or apply convolutional neural network (CNN) for deep learning feature extraction to achieve the purpose of feature extraction. These alternative solutions can automatically learn the details and texture information in the image through the network, thereby improving the distinguishability between the weed targets and the background. In terms of image enhancement technology, other image enhancement methods such as histogram equalization or adaptive filtering technology can be considered to improve the edge features of the weed targets and make them more prominent in the complex background. In addition, for the segmentation of weeds and the background, in addition to using adaptive threshold segmentation and morphological operations, segmentation algorithms based on region growing or image clustering can also be adopted to further improve the segmentation accuracy through clustering algorithms. Although these alternative solutions may have certain effects in different scenarios, compared with the method provided in the embodiments of the present invention, their advantages lie in more accurate processing, especially in terms of robustness and accuracy in complex environments, and can effectively overcome the problems existing in the prior art.

[0098] In a second aspect, an embodiment of the present invention provides a storage medium, on which a program is stored, and when the program is executed by a processor, the weed image segmentation method is implemented.

[0099] In a third aspect, an embodiment of the present invention provides a processor, which is used to run a program, and when the program runs, the weed image segmentation method is executed.

[0100] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0101] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, and the combination of processes and / or blocks in the flowchart and / or block diagram, can be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for realizing the specified function in one process Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.

[0102] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device realizes the specified function in one process Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.

[0103] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for realizing the specified function in one process Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.

[0104] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.

[0105] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0106] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transitory media that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.

[0107] It should also be noted that the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but also other elements not expressly listed, or elements that are inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that comprises the element.

[0108] The above are only embodiments of the present application and are not used to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.

Claims

1. A weed image segmentation method, characterized in that: The method comprises: Extracting the region of interest from the input image to obtain a weed area image; Calculating the local variance of the weed region image, and performing nonlinear normalization processing on the local variance to obtain the weed region image after feature enhancement; Using a Laplace operator to enhance edge information of the feature-enhanced weed region image, and using adaptive threshold segmentation to perform binarization processing on local features of the edge-information-enhanced weed region image; and The weed region image after the binarization process is subjected to denoising by using morphological operations, and the weed region image after the denoising process is segmented to obtain weed targets in the weed region image.

2. The weed image segmentation method according to claim 1, characterized in that: The extracting of the region of interest from the input image comprises: Calculating the super green index of the input image, and obtaining a binary image using the OTSU algorithm according to the super green index; An AND operation is performed on the input image and the binarized image to obtain the weed area image.

3. The weed image segmentation method according to claim 1, characterized in that: The calculating the local variance of the weed region image comprises: A pixel point with coordinates (x, y) in the weed area image is selected, and a square window with a size of 3×3 is selected with the pixel point as the center as the calculation area of ​​the local variance; Calculate the gray value of the pixel and the gray mean of the 9 pixels in the square window, and calculate the local variance of the pixel according to the formula: Among them, ν(x,y) is the local variance of the pixel, f(xi,yi) is the gray value of the pixel with coordinates (xi,yi) centered at the pixel (x,y), is the grayscale mean of the 9 pixels in the square window.

4. The weed image segmentation method according to claim 1, characterized in that: The performing nonlinear normalization processing on the local variance to obtain the feature-enhanced weed region image includes: The local variance is subjected to nonlinear normalization processing to obtain a nonlinear normalized variance, the calculation formula of which is: Among them, V(x,y) is the nonlinear normalized variance, a and b are nonlinear normalization coefficients, and ν(x,y) is the local variance of the pixel; The calculation formula of the weed area image after the feature enhancement is: Among them, f ExG (x, y) is the weed area image, V ExG (x, y) is the image after calculating the nonlinear normalized local variance of the weed area image, k and m are optimization coefficients, and k>0, 0 <m<1。 5. The weed image segmentation method according to claim 1, characterized in that: The step of enhancing edge information of the feature-enhanced weed region image by using the Laplace operator includes: The Laplace operator is used to calculate the second-order derivative of each pixel of the feature-enhanced weed region image to obtain edge information of the image. The expression of the Laplace operator is: Wherein, ΔI(x,y) is the Laplace operator, I(x,y) represents the pixel value of the point at position (x,y) in the image, and Represent the second-order derivatives of the point in the x and y directions respectively.

6. The weed image segmentation method according to claim 1, characterized in that: The method of using adaptive threshold segmentation to perform binarization processing on the local features of the weed region image after enhancing the edge information comprises: The weed area image after enhancing edge information is divided into multiple windows, the average pixel value in each window is calculated, and the local threshold of the pixel point is determined according to the pixel average value. The calculation formula of the local threshold is: T(x,y)=Mean(x,y)-C Where T(x,y) is the local threshold of pixel (x,y), Mean(x,y) is the pixel average of the window centered at pixel (x,y), and C is a constant used to adjust the threshold. When the local pixel value of the image is greater than the local threshold, the pixel is set to 255, otherwise it is set to 0.

7. The weed image segmentation method according to claim 1, characterized in that: The step of using morphological operation to perform denoising on the weed region image after binarization processing comprises: The weed region image after the binary processing is subjected to corrosion operation, and the intersection of the structural element and the local region of the image is calculated, and the calculation formula is: Erosion(I)=(IοS)(x,y)=min(I(x′,y′))forall(x′,y′)∈S Wherein, I represents the weed area image after binarization, (x, y) represents the pixel points in the weed image, S is the structure element, ° represents the erosion operation, min(I(x′, y′)) represents the minimum value of the pixel points in the weed image within the coverage range of the structure element, and forall(x′, y′) represents all the pixel points in the weed image within the coverage range of the structure element; The image after the erosion operation is expanded, and the union of the structure element and the image after the erosion operation is calculated. The calculation formula is: in, represents a dilation operation, and max(I(x′,y′)) represents the maximum value of the pixel points in the weed image within the coverage range of the structure element.

8. The weed image segmentation method according to claim 1, characterized in that: After obtaining the weed area image, the method further includes: A G component histogram of the weed region image is obtained, and the amount of weeds in the weed region image is analyzed according to a maximum peak in the G component histogram.

9. A machine-readable storage medium having instructions stored thereon, the instructions being used to enable a machine to execute any of the weed image segmentation methods described above in the present application.

10. A processor, characterized in that: Used to run a program, wherein the program, when run, is used to execute: the weed image segmentation method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Cutting path generation system based on visual positioning, cutting equipment and cutting method

    CN120765752A