Method for separating weed and crop contours in field based on adaptive threshold segmentation

CN122990466APending Publication Date: 2026-10-27CROP INST SICHUAN PROVINCE ACAD OF AGRI SCI
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202611073247.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-20
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

[0004]本发明旨在至少在一定程度上解决现有技术中的技术问题之一,通过无人机对田间的作物进行拍摄,得到农田图像,同时对农田图像进行图像预处理,得到优化图像,然后计算优化图像中每个像素点的超绿指数,根据超绿指数提取优化图像中的植物像素,再根据植物像素的分布识别优化图像中作物的种植方向线,根据种植方向线分析田间作物的主体轮廓区,再根据主体轮廓区中作物的分布分析作物的个体轮廓区,最后根据个体轮廓区对作物和杂草进行识别并分离,能够解决现有的杂草作物识别技术还存在无法对形态学相似的作物和杂草进行准确区分的问题

Benefits of technology

[0015]可见,本申请的有益效果为:根据作物在种植时的空间分布特征识别作物的主体部分,然后根据作物向外发散的茎叶确定一株作物在种植和生长期间所占用的具体的区域,即个体轮廓区,以此对田间的作物进行识别,而杂草的分布不会遵循作物的空间分布特性,因此在识别出作物后,其余的植物即可视为杂草,提高了杂草作物识别技术在对形态学相似的作物和杂草进行识别时的准确性以及有效性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122990466A_ABST
    Figure CN122990466A_ABST
Patent Text Reader

Abstract

The application discloses a field weed and crop contour separation method based on adaptive threshold segmentation, relates to the field of weed crop identification technology, and comprises the following steps: taking a crop in a field by using a UAV to obtain a farmland image, and simultaneously performing image preprocessing on the farmland image to obtain an optimized image; calculating the super green index of each pixel point in the optimized image, and extracting plant pixels in the optimized image according to the super green index; identifying a planting direction line of the crop in the optimized image according to the distribution of the plant pixels; dividing the individual contour area of the crop in the field in the optimized image in combination with the plant pixels and the planting direction line; and identifying and separating the crop and weeds according to the individual contour area. The application is used to solve the problem that the existing weed crop identification technology cannot accurately distinguish the crops and weeds with similar morphologies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of weed crop identification technology, specifically a method for separating field weeds and crop outlines based on adaptive threshold segmentation. Background Technology

[0002] Weed crop identification technology uses sensors to acquire farmland scene data and employs image processing, machine learning, or deep learning methods to automatically analyze the differences between crops and weeds in terms of morphology, color, or spatial distribution, thereby distinguishing the two and determining their respective locations.

[0003] Existing weed crop identification technologies still suffer from the problem of failing to accurately distinguish between morphologically similar crops and weeds. This is because existing weed crop identification technologies mostly rely on morphological analysis to identify and differentiate between crops and weeds. However, during the planting period of some crops, crops and weeds are extremely similar in morphology, and crops that are close together may intersect during their growth. In such cases, it is difficult to extract accurate morphological features of the crops. Because crops and weeds are similar, it is also difficult to distinguish between weeds and crops based on morphological features. For example, in the invention patent with publication number CN119516380A, a "method for identifying weeds in a crop planting area" is disclosed. This method uses a weed identification model to identify weeds in the planting area. However, during the planting period of some crops, crops and weeds are extremely similar in morphology, and in such cases, this method cannot distinguish between weeds and crops in the planting area. Summary of the Invention

[0004] This invention aims to at least partially solve one of the technical problems in the prior art. It uses drones to photograph crops in the field to obtain farmland images. Simultaneously, the farmland images are preprocessed to obtain optimized images. Then, the supergreen index of each pixel in the optimized image is calculated. Based on the supergreen index, plant pixels in the optimized image are extracted. Then, the planting direction lines of the crops in the optimized image are identified based on the distribution of plant pixels. The main outline area of ​​the crops in the field is analyzed based on the planting direction lines. Then, the individual outline areas of the crops are analyzed based on the distribution of crops in the main outline area. Finally, crops and weeds are identified and separated based on the individual outline areas. This can solve the problem that existing weed and crop identification technologies cannot accurately distinguish between morphologically similar crops and weeds.

[0005] To achieve the above objectives, in a first aspect, this application provides a method for separating field weeds and crop outlines based on adaptive threshold segmentation, comprising the following steps: Further, in step S100, the crops in the field are photographed by a drone to obtain farmland images, and the farmland images are preprocessed to obtain optimized images. Step S200: Calculate the supergreen index of each pixel in the optimized image, and extract plant pixels in the optimized image based on the supergreen index; Step S300: Identify and optimize the planting direction line of crops in the image based on the distribution of plant pixels; Step S400: Combine plant pixels and planting direction lines to divide the individual contour areas of crops in the field into the optimized image; Step S500: Identify and separate crops and weeds based on individual outline regions.

[0006] Furthermore, step S100 also includes the following sub-steps: Step S101: Use a drone to take pictures of the crops in the field at a preset altitude to obtain farmland images; Step S102: Gaussian denoising and image enhancement are performed on the farmland image to obtain an optimized image.

[0007] Furthermore, to improve the recognizability of crops and weeds in the optimized image and weaken the background color, step S200 also includes the following sub-steps: Step S201: Obtain the RGB values ​​of pixels in the optimized image, where r, g, and b represent the R, G, and B color values ​​in the RGB values, respectively. Step S202: Obtain the super green index of the pixel based on the calculation formula ExG=2×grb, and calculate the super green index of each pixel; Step S203: Calculate all super-green indices using the Otsu algorithm and output a binarized threshold. In step S204, pixels with a super green index greater than the binarization threshold are called plant pixels, and the remaining pixels are called background pixels.

[0008] Furthermore, to determine the directional and spatial distribution characteristics of crops during planting, step S300 also includes the following sub-steps: Step S301: Let positive integers i and j represent the row and column in the optimized image, and denote the pixel in the i-th row and j-th column of the optimized image as OP(i,j); Step S302: Combine consecutive adjacent plant pixels in the first row into a plant group, and obtain the range of j in OP(1,j) of the plant pixels in the plant group, which is named the pixel bit range. Step S303: Take the median value of the pixel range as the direction test value, denoted as Q. Take the pixel point OP(1,Q) as the direction test point. Draw a line segment with the direction test point and OP(1,1) as the endpoints and name it the direction test line. At the same time, name the endpoint at OP(1,1) the moving point. Step S304: Move the moving point counterclockwise along the border of the optimized image. Stop moving when the moving point reaches OP(1,max(j)). Keep the direction test point unchanged. During the movement of the moving point, the direction test line changes with the movement of the moving point. Calculate the ratio of plant pixels to background pixels in the pixel points OP(i,j) that the direction test line passes through in real time. Name it as plant coverage ratio. Step S305: The direction test line with the largest plant coverage ratio is called the direction determination line. Continuous direction determination lines will form a triangle, which is named the direction determination figure. Connect the midpoint of the opposite side of the direction test point to the direction test point, and name the line segment obtained by the connection as the planting direction line.

[0009] Furthermore, to analyze and obtain the spatial distribution of the main body of the crop and the spatial distribution of individual crop plants, step S400 also includes the following sub-steps: Step S401: Analyze the main outline area of ​​the crop in the field according to the planting direction line; at this time, the main outline area is the area where the main body of the crop is located. The main outline area is usually formed by the dense area of ​​stems and leaves near the center of the crop or by the intersection of two closely spaced crops, which can determine the main planting position of the crop. Step S402: Analyze the individual contour areas of crops based on the distribution of crops in the main contour area. The main contour area can only determine the main planting location of the crop. However, in addition to the main body, a crop also has outward-radiating structures such as leaves. Compared with the main body of the crop, the distribution of plant pixels of these structures is relatively sparse, which is the key to analyzing the area where individual crops are located. Based on this, the specific location distribution of a crop in the optimized image can be analyzed.

[0010] Furthermore, step S401 also includes the following sub-steps: Step S401.1: Copy two planting direction lines and name them the left dividing line and the right dividing line respectively. Move the left dividing line horizontally to the left and the right dividing line horizontally to the right. Step S401.2: Real-time detection of the plant coverage ratio of the left dividing line and the right dividing line, collectively referred to as the boundary coverage ratio, and marking the column number j of the left dividing line and the right dividing line in the first row as CF. Step S401.3: Use a clustering algorithm to cluster the boundary coverage ratios, output the boundary clusters, and sort the boundary clusters in descending order of the average boundary coverage ratio in each cluster, using the symbol BC. n It indicates that the BC n In this context, n is the index of BC and n is a positive integer. Let BC... n In this context, n is assigned as a boundary value to either the left or right dividing line in column CF; Step S401.4: Establish a boundary analysis diagram with the column number CF as the X-axis and the boundary assignment n as the Y-axis. At the same time, enter the boundary coverage ratio of the left dividing line and the right dividing line into the boundary analysis diagram according to the CF during the movement process. Step S401.5: Connect the coordinate points in the boundary analysis diagram with a smooth curve to form a waveform curve, named the boundary feature wave. Name the points in the boundary feature wave where the curve changes from horizontal to monotonically rising and from monotonically falling to horizontal as boundary points. Step S401.6: Name the horizontal part of the boundary feature wave as the planting center line, combine the left or right dividing lines corresponding to the boundary points on both sides of each planting center line into a set of boundary lines, and name the area between the two boundary lines as the main outline area.

[0011] Furthermore, step S402 also includes the following sub-steps: Step S402.1: Name the two boundary lines with the closest interval between two adjacent main body contour areas as main body column interval lines. At this time, the main body column interval lines together with the upper and lower edges in the optimized image form a rectangle, which is named the main body interval graphic. Step S402.2: Take the central axis of the main body interval graphic and name it the plant partition line. Draw the plant partition line between every two adjacent main body outline areas. Draw a horizontal auxiliary line to connect two adjacent plant partition lines and name it the individual interval analysis line. Step S402.3: Count the number of plant pixels that intersect with the individual interval analysis line and name them as the individual span reference number. Move the individual interval analysis line from top to bottom and update the individual span reference number in real time. Name the largest individual span reference number as the span parameter. Name the individual interval analysis line corresponding to the span parameter as the individual span line. Name the midpoint of the individual span line in the main outline area as the individual center point. Draw a circle with the individual center point as the center and the two plant pixels that are farthest apart on the individual span line as the diameter. Name it as the individual outline area. Step S402.4: Reduce the diameter of the individual contour area by a preset factor, name it the existing individual area, remove the individual interval analysis lines that intersect with the existing individual area, reanalyze the individual contour area based on the remaining individual interval analysis lines, and repeat the process until all individual interval analysis lines are removed.

[0012] Furthermore, step S500 also includes the following sub-steps: The area in the main interval graphic, excluding the individual outline area, is named the weed area; When a user selects to visualize a crop, the plant pixels within the individual outline area are displayed to the user. When a user selects to visualize weeds, the system displays plant pixels within the weed area. Crops in the optimized image are identified by their spatial distribution characteristics during planting and their individual outlines. If non-crop plants appear within the planting area, they are usually weeds, thus enabling the identification and separation of weeds and crops in the field.

[0013] In a second aspect, this application provides an electronic device, including a memory for storing computer programs; A processor for executing the computer program to perform the steps in the method described above.

[0014] Thirdly, this application provides a storage medium storing a computer program thereon, characterized in that when the computer program is executed by a processor, it performs the steps of the method described above.

[0015] It is evident that the beneficial effects of this application are as follows: the main body of the crop is identified based on the spatial distribution characteristics of the crop during planting, and then the specific area occupied by a crop during planting and growth, i.e., the individual outline area, is determined based on the outward-spreading stems and leaves of the crop. This allows for the identification of crops in the field. Since the distribution of weeds does not follow the spatial distribution characteristics of crops, after identifying the crops, the remaining plants can be regarded as weeds, thus improving the accuracy and effectiveness of weed crop identification technology in identifying morphologically similar crops and weeds. Attached Figure Description

[0016] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0017] Figure 1 This is a flowchart of the steps of the method of the present invention; Figure 2 This is a schematic diagram of the optimized image of the present invention; Figure 3 This is a schematic diagram of the direction test line of the present invention; Figure 4 This is a schematic diagram of the direction-determining line of the present invention; Figure 5 This is a schematic diagram of the planting direction line of the present invention; Figure 6 This is a schematic diagram of the boundary analysis diagram of the present invention; Figure 7 This is a schematic diagram of the planting center line of the present invention; Figure 8This is a schematic diagram of the main outline area of ​​the present invention; Figure 9 This is a schematic diagram of the main body spacing pattern of the present invention; Figure 10 This is a schematic diagram of the individual interval analysis line of the present invention; Figure 11 This is a schematic diagram of the individual contour area of ​​the present invention. Detailed Implementation

[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.

[0019] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0020] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0021] During the cultivation of some crops, crops and weeds are morphologically very similar. For example, in the early stages of rice cultivation, some weeds in the field are very similar to rice seedlings. Furthermore, adjacent rice plants may intersect during their growth, significantly increasing the difficulty of extracting morphological features. In such cases, it is difficult to distinguish between crops and weeds in the field. To address this problem, this application discloses a method for separating field weed and crop contours based on adaptive threshold segmentation. Please refer to... Figure 1 As shown, this method includes the following steps: Step S100 involves using a drone to photograph crops in the field, obtaining farmland images, and simultaneously performing image preprocessing on the farmland images to obtain optimized images; Step S100 also includes the following sub-steps: Step S101: Use a drone to take pictures of the crops in the field at a preset altitude to obtain farmland images; Please see Figure 2 As shown, in step S102, Gaussian denoising and image enhancement are performed on the farmland image to obtain an optimized image; In practice, the preset altitude is set by the user, requiring only that the drone stay close to the ground to ensure clear images of the farmland. During filming, the drone must be controlled to move along the planting direction of the crops. This is because users who require machine vision to identify crops and weeds are typically large-scale growers or agricultural companies with well-planned planting strategies. These users usually plant crops at certain intervals and in certain directions, visually distributing them along a specific direction to form different planting rows. The drone's movement direction must be the same as this direction. After capturing the farmland images, noise reduction and enhancement are performed to make the images clearer, resulting in optimized images. Figure 2 As shown, Figure 2 This is an optimized image that has been converted to grayscale.

[0022] Step S200: Calculate the supergreen index of each pixel in the optimized image, and extract plant pixels from the optimized image based on the supergreen index; Step S200 also includes the following sub-steps: Step S201: Obtain the RGB values ​​of pixels in the optimized image, where r, g, and b represent the R, G, and B color values ​​in the RGB values, respectively. Step S202: Obtain the super green index of the pixel based on the calculation formula ExG=2×grb, and calculate the super green index of each pixel; Step S203: Calculate all super-green indices using the Otsu algorithm and output a binarized threshold. Step S204: Pixels with a super green index greater than the binarization threshold are called plant pixels, and the remaining pixels are called background pixels. In the specific implementation process, for example, the RGB value of a certain pixel in the image is optimized to be (140, 194, 92), which corresponds to the R, G, and B color values ​​from left to right, i.e., r=140, g=194, b=92. The super green index ExG of this pixel is finally calculated to be 156. This is because most crops are green, and the super green index can enhance the greenish pixels in the image, thereby enhancing and optimizing the pixels corresponding to crops and weeds in the image, and weakening the background pixels such as soil and water. Then, the Otsu algorithm is used to calculate all super green indices to obtain the binarization threshold. The Otsu algorithm is a classic method that automatically determines the image binarization threshold by maximizing the inter-class variance. It is an existing technical means, and it has not been modified in this embodiment. Therefore, the calculation process is not described in detail in this embodiment. Only the Otsu algorithm model is introduced to output the binarization threshold. The final binarization threshold is 122. Pixels with a super green index greater than 122 are called plant pixels, and the remaining pixels are called background pixels.

[0023] Step S300: Identify and optimize the planting direction line of the crop in the image based on the distribution of plant pixels; Step S300 also includes the following sub-steps: Step S301: Let positive integers i and j represent the row and column in the optimized image, and denote the pixel in the i-th row and j-th column of the optimized image as OP(i,j); Step S302: Combine consecutive adjacent plant pixels in the first row into a plant group, and obtain the range of j in OP(1,j) of the plant pixels in the plant group, which is named the pixel bit range. Please see Figure 3 As shown, in step S303, the median value of the pixel range is taken as the direction test value, denoted as Q. The pixel point OP(1,Q) is taken as the direction test point. A line segment is drawn with the direction test point and OP(1,1) as the endpoints and named as the direction test line. At the same time, the endpoint at OP(1,1) is named as the moving point. In the specific implementation process, the plants have dense stems and leaves near the main body, and there are no gaps in the optimized image. Since the drone moves along the planting direction of the crops, there must be consecutive adjacent plant pixels in the first row, i.e., plant groups. The plant pixels in the plant group usually belong to the same planting column. Taking their midpoints will allow us to get close to the main body of the crops, i.e., close to the central axis of a row of planting columns. For example, in this embodiment, the 65 pixels between OP(1,150) and OP(1,214) are all plant pixels. Therefore, OP(1,150) to OP(1,214) is a plant group, with the pixel range being [150,214]. The obtained direction test value Q is 182. Taking OP(1,182) as the direction test point, the direction test line is drawn as follows. Figure 3 As shown, Figure 3 The black line in the diagram is the direction test line. The left endpoint of the black line is the movement point, and the right endpoint is the direction test point.

[0024] Step S304: Move the moving point counterclockwise along the border of the optimized image. Stop moving when the moving point reaches OP(1,max(j)). Keep the direction test point unchanged. During the movement of the moving point, the direction test line changes with the movement of the moving point. Calculate the ratio of plant pixels to background pixels in the pixel points OP(i,j) that the direction test line passes through in real time. Name it as plant coverage ratio. Please see Figures 4 to 5 As shown, in step S305, the direction test line with the largest plant coverage ratio is called the direction determination line. Continuous direction determination lines will form a triangle, which is named the direction determination figure. The midpoint of the opposite side of the direction test point is connected to the direction test point, and the line segment obtained by the connection is named the planting direction line. In the specific implementation process, the optimized image is a rectangle. The line moves counter-clockwise along the rectangular border of the optimized image. Movement stops when the direction test line becomes horizontal again. During the movement, the plant coverage ratio is calculated in real time. For example, in a certain detection, the direction test line passes through 326 plant pixels and 118 background pixels. If the background pixel count is 0, it is considered 1. Therefore, the plant coverage ratio is 326 / 118 = 163 / 59. Since the green coverage rate in the main crop area of ​​a planting column usually reaches over 90%, the plant coverage ratio is at its maximum. However, because the direction test line has a certain angle with the pixels, the total number of plant pixels passed by the direction test line is not equal. Therefore, when determining the plant coverage ratio, a clustering algorithm is needed. The direction test line corresponding to the data cluster with the largest mean plant coverage ratio is taken as the direction determination line. Since multiple continuous lines can form a surface, the final direction determination line is as follows: Figure 4 As shown, Figure 4 The white lines in the diagram are the direction-defining lines, and the triangular area between the two white lines is the direction-defining graphic. Connecting these lines yields the planting direction line as shown below. Figure 5 As shown, Figure 5 The black straight line in the diagram represents the planting direction line.

[0025] Step S400 involves combining plant pixels and planting direction lines to define the individual contour regions of crops in the optimized image; Step S400 also includes the following sub-steps: Step S401: Analyze the main outline area of ​​the field crops based on the planting direction line; Step S401 also includes the following sub-steps: Step S401.1: Copy two planting direction lines and name them the left dividing line and the right dividing line respectively. Move the left dividing line horizontally to the left and the right dividing line horizontally to the right. Step S401.2: Real-time detection of the plant coverage ratio of the left dividing line and the right dividing line, collectively referred to as the boundary coverage ratio, and marking the column number j of the left dividing line and the right dividing line in the first row as CF. Step S401.3: Use a clustering algorithm to cluster the boundary coverage ratios, output the boundary clusters, and sort the boundary clusters in descending order of the average boundary coverage ratio in each cluster, using the symbol BC. n It is stated that BC n In this context, n is the index of BC and n is a positive integer. Let BC... n In this context, n is assigned as a boundary value to either the left or right dividing line in column CF; Please see Figure 6As shown, in step S401.4, a boundary analysis diagram is established with the column number CF as the X-axis and the boundary assignment value n as the Y-axis. At the same time, the boundary coverage ratio of the left dividing line and the right dividing line is entered into the boundary analysis diagram according to the CF during the movement process. Please see Figure 7 As shown, in step S401.5, a smooth curve is used to connect the coordinate points in the boundary analysis diagram to form a waveform curve, which is named the boundary feature wave. The points in the boundary feature wave where the curve changes from horizontal to monotonically rising and from monotonically falling to horizontal are named boundary points. Please see Figure 8 As shown, in step S401.6, the horizontal part in the boundary feature wave is named the planting center line, the left dividing line or right dividing line corresponding to the boundary point on both sides of each planting center line is combined into a set of boundary lines, and the area between the two boundary lines is named the main outline area. In the specific implementation process, for example, after copying the left dividing line, the left dividing line is moved horizontally to the left. During the movement, the endpoint of the top of the left dividing line always intersects with OP(1,j). When it moves to OP(1,141), the CF of the left dividing line is 141. At the same time, the plant cover ratio of the left dividing line at this time is extracted, and the boundary cover ratio is found to be 314 / 29. The same applies to the right dividing line. The boundary cover ratio of the left and right dividing lines at each OP(1,j) is analyzed. Through clustering algorithm, 12 boundary clusters are obtained. According to the average boundary cover ratio of the boundary clusters in descending order, they correspond to BC1 to BC2. 12 The corresponding boundary values ​​are assigned sequentially from 1 to 12, and the boundary analysis diagram is then constructed as follows. Figure 6 As shown, Figure 6 The curve in the diagram represents the boundary feature wave. A larger boundary coverage ratio indicates that the left or right dividing line is closer to the main rootstock of the crop. Therefore, BC1 represents the boundary coverage ratio extracted from the main rootstock portion. At this point, consecutive BC1 lines will form a horizontal straight line. After passing the main rootstock portion, the boundary coverage ratio will decrease, and the boundary value will increase, meaning the curve changes from horizontal to monotonically increasing. When reaching another planting column, the left or right dividing line will approach the main rootstock of that column, causing the boundary coverage ratio to increase, and the corresponding boundary replication will decrease, meaning the curve changes from monotonically decreasing to horizontal. It's important to note that only the horizontal portion with a boundary replication of 1 is considered; the remaining horizontal portions do not belong to the planting centerline and are marked accordingly. Figure 6 The planting center line in the middle is as follows Figure 7 As shown, Figure 7 The endpoints on both sides of the planting centerline are the boundary points, which correspond to the division of the main outline area as follows: Figure 8 As shown, Figure 8 The gray parallelogram in the image represents the main outline area.

[0026] Step S402: Analyze the individual crop outline areas based on the distribution of crops in the main outline area; Step S402 also includes the following sub-steps: Please see Figure 9 As shown, in step S402.1, the two boundary lines with the closest interval between two adjacent main body contour areas are named main body column interval lines. At this time, the main body column interval lines, together with the upper and lower edges in the optimized image, form a rectangle, which is named the main body interval graphic. Please see Figure 10 As shown, in step S402.2, take the central axis of the main body interval graphic and name it the plant partition line, draw the plant partition line between every two adjacent main body outline areas, draw a horizontal auxiliary line to connect two adjacent plant partition lines, and name it the individual interval analysis line. In the specific implementation process, the main spacing graphic is extracted as follows: Figure 9 As shown, Figure 9 The black parallelogram in the image represents the main dividing pattern, and the white line segment in the middle of the main dividing pattern represents the plant dividing line. It should be noted that... Figure 9 In the leftmost main outline area, only the right side has an adjacent main outline area, while the left side does not. Therefore, the main outline area on the right is directly moved to its left to divide the plant partition lines on both sides of the main outline area. Then, individual interval analysis lines are drawn as follows. Figure 10 As shown, Figure 10 The white horizontal line segment in the diagram represents the individual interval analysis line.

[0027] Please see Figure 11 As shown in step S402.3, count the number of plant pixels that intersect with the individual interval analysis line and name them as the individual span reference number. Move the individual interval analysis line from top to bottom and update the individual span reference number in real time. Name the largest individual span reference number as the span parameter. Name the individual interval analysis line corresponding to the span parameter as the individual span line. Name the midpoint of the individual span line in the main outline area as the individual center point. Draw a circle with the individual center point as the center and the two plant pixels that are farthest apart on the individual span line as the diameter. Name it as the individual outline area. Step S402.4: Reduce the diameter of the individual contour area by a preset factor, name it the existing individual area, remove the individual interval analysis lines that intersect with the existing individual area, reanalyze the individual contour area based on the remaining individual interval analysis lines, and repeat the process until all individual interval analysis lines are removed. In practice, since the stems and leaves of crops spread outwards during growth, if the individual interval analysis line is located at the main root of the crop, its two sides will usually align with the spreading direction of the crop's stems and leaves. At this point, the individual interval analysis line has the most plant pixels, meaning the individual span reference line is at its maximum. The individual interval analysis line will definitely intersect with the crop's root. Since the crop spreads outwards during growth, it can be approximated as growing within a circular area. Therefore, the midpoint of the individual span line within the main outline area is named the individual center point. A circle is drawn with the individual center point as the center and the two furthest plant pixels on the individual span line as the diameter, thus obtaining the individual outline area. Figure 11 As shown, to facilitate viewing the selection effect of the individual outline area, Figure 11 The fill color of the main spacing graphic is erased, but according to... Figure 10 It is still possible to determine the positional relationship between the main outline area, the main spacing pattern, and the plant dividing lines. Figure 11 The black circle in the diagram represents the individual outline area. Since adjacent crops may intersect during growth, meaning the stems and leaves of one crop along the planting row may be affected by other crops, resulting in a shorter spread of stems and leaves compared to the sides, removing the original individual outline area to analyze the next might lead to the removal of the stems and leaves of adjacent crops. Therefore, the original individual outline area needs to be reduced to prevent the removal of the root and stem parts of adjacent crops. The reduction factor is set by the tester based on the crop being tested. In this embodiment, the preset factor is set to 1, reducing the diameter of the individual outline area by half, i.e., to 1 / 2 of the original diameter, and then removing it. At this point, the individual outline areas of the remaining crops can be analyzed. This process is repeated to obtain the individual outline area of ​​each crop.

[0028] Step S500 involves identifying and separating crops and weeds based on their individual outline regions; step S500 further includes the following sub-step: identifying crops and weeds based on the differences between different individual outline regions. The area in the main interval graphic, excluding the individual outline area, is named the weed area; When a user selects to visualize a crop, the plant pixels within the individual outline area are displayed to the user. When a user chooses to visualize weeds, the system displays the plant pixels within the weed area to the user. In the specific implementation process, after analyzing and obtaining the individual outline area of ​​each crop, the remaining plants are weeds. The pixels of crops and weeds can be separated by visualization technology.

[0029] Furthermore, this application also provides an electronic device. This electronic device can also be a server.

[0030] The aforementioned electronic device or server may specifically include: at least one processor, at least one memory, a power supply, a communication interface, an input / output interface, and a communication bus. The memory stores a computer program, which is loaded and executed by the processor to implement the relevant steps in the methods disclosed in the foregoing embodiments.

[0031] In this embodiment, the power supply is used to provide operating voltage for each hardware device on the server; the communication interface can create a data transmission channel between the server and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0032] In addition, the memory, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored on it include operating system, computer programs and data, etc., and the storage method can be temporary storage or permanent storage.

[0033] The operating system is used to manage and control the various hardware devices and computer programs on the server, so as to enable the processor to perform operations and processing on the data in the memory. It can be Windows Server, Netware, Unix, Linux, etc.

[0034] In addition to including computer programs capable of performing the data processing methods disclosed in any of the foregoing embodiments, the computer program may further include computer programs capable of performing other specific tasks. The data may include, in addition to data such as application update information, data such as application developer information.

[0035] A storage medium is provided for storing a computer program, wherein the computer program, when executed by a processor, implements the method disclosed in the foregoing embodiments. The storage medium is a computer-readable storage medium that serves as a carrier for resource storage and may be a read-only memory, random access memory, disk, or optical disk, etc. The resources stored thereon include an operating system, computer programs, and data, and the storage method may be temporary or permanent storage.

[0036] A computer program product includes a computer program / instructions that, when executed by a processor, implement the steps of the aforementioned disclosed method.

[0037] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0038] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly using hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, etc. In ROM, or any other form of storage medium known in the art.

[0039] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only intended to help understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for separating field weeds and crop outlines based on adaptive threshold segmentation, characterized in that, include: Step S100: Take pictures of crops in the field using a drone to obtain farmland images, and perform image preprocessing on the farmland images to obtain optimized images; Step S200: Calculate the supergreen index of each pixel in the optimized image, and extract plant pixels in the optimized image based on the supergreen index; Step S300: Identify and optimize the planting direction line of crops in the image based on the distribution of plant pixels; Step S400: Combine plant pixels and planting direction lines to divide the individual contour areas of crops in the field into the optimized image; Step S500: Identify and separate crops and weeds based on individual outline regions.

2. The method according to claim 1, characterized in that, Step S100 also includes the following sub-steps: Step S101: Use a drone to take pictures of the crops in the field at a preset altitude to obtain farmland images; Step S102: Gaussian denoising and image enhancement are performed on the farmland image to obtain an optimized image.

3. The method according to claim 2, characterized in that, Step S200 also includes the following sub-steps: Step S201: Obtain the RGB values ​​of pixels in the optimized image, where r, g, and b represent the R, G, and B color values ​​in the RGB values, respectively. Step S202: Obtain the super green index of the pixel based on the calculation formula ExG=2×grb, and calculate the super green index of each pixel; Step S203: Calculate all super-green indices using the Otsu algorithm and output a binarized threshold. In step S204, pixels with a super green index greater than the binarization threshold are called plant pixels, and the remaining pixels are called background pixels.

4. The method according to claim 3, characterized in that, Step S300 also includes the following sub-steps: Step S301: Let positive integers i and j represent the row and column in the optimized image, and denote the pixel in the i-th row and j-th column of the optimized image as OP(i,j); Step S302: Combine consecutive adjacent plant pixels in the first row into a plant group, and obtain the range of j in OP(1,j) of the plant pixels in the plant group, which is named the pixel bit range. Step S303: Take the median value of the pixel range as the direction test value, denoted as Q. Take the pixel point OP(1,Q) as the direction test point. Draw a line segment with the direction test point and OP(1,1) as the endpoints and name it the direction test line. At the same time, name the endpoint at OP(1,1) the moving point. Step S304: Move the moving point counterclockwise along the border of the optimized image. Stop moving when the moving point reaches OP(1,max(j)). Keep the direction test point unchanged. During the movement of the moving point, the direction test line changes with the movement of the moving point. Calculate the ratio of plant pixels to background pixels in the pixel points OP(i,j) that the direction test line passes through in real time. Name it as plant coverage ratio. Step S305: The direction test line with the largest plant coverage ratio is called the direction determination line. Continuous direction determination lines will form a triangle, which is named the direction determination figure. Connect the midpoint of the opposite side of the direction test point to the direction test point, and name the line segment obtained by the connection as the planting direction line.

5. The method according to claim 4, characterized in that, Step S400 also includes the following sub-steps: Step S401: Analyze the main outline area of ​​the field crops based on the planting direction line; Step S402: Analyze the individual contour areas of crops based on the distribution of crops in the main contour area.

6. The method according to claim 5, characterized in that, Step S401 also includes the following sub-steps: Step S401.1: Copy two planting direction lines and name them the left dividing line and the right dividing line respectively. Move the left dividing line horizontally to the left and the right dividing line horizontally to the right. Step S401.2: Real-time detection of the plant coverage ratio of the left dividing line and the right dividing line, collectively referred to as the boundary coverage ratio, and marking the column number j of the left dividing line and the right dividing line in the first row as CF. Step S401.3: Use a clustering algorithm to cluster the boundary coverage ratios, output the boundary clusters, and sort the boundary clusters in descending order of the average boundary coverage ratio in each cluster, using the symbol BC. n It indicates that the BC n In this context, n is the index of BC and n is a positive integer. Let BC... n In this context, n is assigned as a boundary value to either the left or right dividing line in column CF; Step S401.4: Establish a boundary analysis diagram with the column number CF as the X-axis and the boundary assignment n as the Y-axis. At the same time, enter the boundary coverage ratio of the left dividing line and the right dividing line into the boundary analysis diagram according to the CF during the movement process. Step S401.5: Connect the coordinate points in the boundary analysis diagram with a smooth curve to form a waveform curve, named the boundary feature wave. Name the points in the boundary feature wave where the curve changes from horizontal to monotonically rising and from monotonically falling to horizontal as boundary points. Step S401.6: Name the horizontal part of the boundary feature wave as the planting center line, combine the left or right dividing lines corresponding to the boundary points on both sides of each planting center line into a set of boundary lines, and name the area between the two boundary lines as the main outline area.

7. The method according to claim 6, characterized in that, Step S402 also includes the following sub-steps: Step S402.1: Name the two boundary lines with the closest interval between two adjacent main body contour areas as main body column interval lines. At this time, the main body column interval lines, together with the upper and lower edges in the optimized image, form a rectangle, which is named the main body interval graphic. Step S402.2: Take the central axis of the main body interval graphic and name it the plant partition line. Draw the plant partition line between every two adjacent main body outline areas. Draw a horizontal auxiliary line to connect two adjacent plant partition lines and name it the individual interval analysis line. Step S402.3: Count the number of plant pixels that intersect with the individual interval analysis line and name them as the individual span reference number. Move the individual interval analysis line from top to bottom and update the individual span reference number in real time. Name the largest individual span reference number as the span parameter. Name the individual interval analysis line corresponding to the span parameter as the individual span line. Name the midpoint of the individual span line in the main outline area as the individual center point. Draw a circle with the individual center point as the center and the two plant pixels that are farthest apart on the individual span line as the diameter. Name it as the individual outline area. Step S402.4: Reduce the diameter of the individual contour area by a preset factor, name it the existing individual area, remove the individual interval analysis lines that intersect with the existing individual area, and re-analyze the individual contour area based on the remaining individual interval analysis lines. Repeat this process until all individual interval analysis lines are removed.

8. The method according to claim 7, characterized in that, Step S500 also includes the following sub-steps: The area in the main interval graphic, excluding the individual outline area, is named the weed area; When a user selects to visualize a crop, the plant pixels within the individual outline area are displayed to the user. When a user selects to visualize weeds, the system displays the plant pixels within the weed area to the user.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the method as claimed in any one of claims 1 to 7.

10. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it performs the steps of the method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Method for identifying weeds in crop planting area

    CN119516380A