A method and system for generating a dataset for unmanned aerial vehicle farmland boundary extraction
By combining point sampling and probe boundary detection with a sampling algorithm that minimizes overlap, a high-quality drone-generated farmland boundary dataset was generated. This solved the problems of incomplete dataset coverage and computational redundancy in traditional methods, and improved the model's boundary extraction capability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-08
- Publication Date
- 2026-03-17
AI Technical Summary
Existing technologies for generating UAV farmland boundary datasets suffer from issues such as incomplete dataset coverage, missing boundaries, noise interference, and computational redundancy. In particular, under extremely high-resolution remote sensing data, traditional methods struggle to adapt to irregular farmland plots and areas with abrupt changes in crop texture, resulting in limited model generalization performance.
By employing point sampling technology, probe boundary detection strategy, and minimum overlap rate sampling algorithm, high-quality farmland boundary datasets are generated through random seed point generation, probe boundary detection, and optimization of sample point distribution.
It achieves efficient and accurate generation of farmland boundary datasets, reduces computational costs, improves the quality and quantity of datasets, and ensures the integrity of boundaries and the generalization performance of the model.
Smart Images

Figure CN120877145B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision technology, and in particular to a dataset generation method and system for extracting farmland boundaries using unmanned aerial vehicles (UAVs). Background Technology
[0002] In the interdisciplinary field of agricultural remote sensing and computer vision, the quality and quantity of datasets are decisive factors in the model's learning ability and generalization. Sufficient and diverse datasets are also the two wings of data for the implementation of smart agriculture. However, among the methods for generating datasets for farmland boundary extraction, the most primitive manual random cropping method, although simple to implement, does not systematically cover farmland boundaries, resulting in the omission of boundary information, and the amount of data generated is also not ideal. With the introduction of the sliding window technique for generating datasets for remote sensing farmland boundary extraction, spatial full coverage is controlled by the overlap rate to achieve data augmentation. However, because it only controls the overlap rate of the sliding window, it results in a lot of invalid data and redundant data computation. In particular, the widespread use of centimeter-resolution images taken by UAVs under the economic drive of low altitude and the extensive application of ultra-high resolution remote sensing data (0.01-0.05m) have exposed the shortcomings of traditional farmland dataset generation methods.
[0003] Drone-generated farmland images exhibit the following characteristics: Spatially, their extremely high resolution allows them to capture the boundaries of small plots, leading to extreme farmland scale; geometrically, irregular farmland boundaries and increased plot fragmentation result in more complex farmland morphology. The inconsistent scale of farmland plots is a key factor affecting boundary integrity in drone-generated farmland boundary extraction dataset generation techniques, particularly regarding the adaptability of local sampling methods such as sliding windows. Existing technologies typically rely on fixed-size windows or regular step sizes to segment images. While these methods can generate local samples in batches, they often suffer from boundary fragmentation, missed small plots, or noise interference when dealing with irregular field ridges, fragmented plots, or areas of abrupt crop texture changes. This rigidity in window size and step size limits the model's ability to perceive the global structure of the farmland and hinders the generalization performance of high-precision boundary extraction models. Summary of the Invention
[0004] This invention provides a dataset generation method and system for extracting farmland boundaries using drones, which addresses the shortcomings of existing technologies and enables the acquisition of standardized datasets containing farmland boundaries.
[0005] In a first aspect, the present invention provides a dataset generation method for extracting farmland boundaries using unmanned aerial vehicles (UAVs), comprising:
[0006] Determine the dataset initialization parameter set, and obtain the UAV farmland image and the corresponding mask image based on the dataset initialization parameter set;
[0007] The number of slices to be retained and the number of random points are calculated based on the mask image. A sufficient number of points are randomly generated within the original mask region to form a random seed point set.
[0008] A probe boundary detection strategy is used to detect the boundary of a random seed point set, identify valid points, and obtain candidate sample points.
[0009] The spatial distribution of candidate sample points is optimized using a minimum overlap rate sampling algorithm to obtain the final retained sample points.
[0010] The final dataset is generated by using the retained sample points as the slice center points.
[0011] According to the present invention, a dataset generation method for extracting farmland boundaries using unmanned aerial vehicles (UAVs) includes determining a dataset initialization parameter set, and obtaining UAV farmland images and corresponding mask images based on the dataset initialization parameter set, comprising:
[0012] Determine the parameter slice size, overlap rate, dataset augmentation strength, and configuration parameters for generating high-density random seed points;
[0013] Collect drone images of farmland to be processed and manually annotated masked images.
[0014] According to the present invention, a dataset generation method for farmland boundary extraction by unmanned aerial vehicles (UAVs) is provided, which calculates the number of retained slices and the number of random points based on a mask image, and randomly generates a sufficient number of points within the original mask region to form a random seed point set, including:
[0015] Obtain all boundary pixels of the original mask image, and generate a square expansion box with each boundary pixel as the center point and the parameter slice size as the range;
[0016] Based on the square expansion box, the preset RGB values of the mask are extracted to obtain the fill value of the expansion area, thus obtaining the expansion mask image;
[0017] Obtain the area of the extended mask image, and calculate the area density of the slice in the extended mask image based on the area of the extended mask image and the slice area.
[0018] The initial number of slices, taking into account the slice overlap rate, is calculated based on the area density and overlap rate of the slices in the extended mask image.
[0019] The number of slices for generating the sample dataset is calculated based on the initial number of slices considering the slice overlap rate and the dataset augmentation strength.
[0020] The number of random points is obtained from the number of slices in the generated sample dataset and the configuration parameters for generating high-density random seed points;
[0021] Based on the random number of points, a sufficient number of points are randomly generated within the original mask area to form a random seed point set.
[0022] According to the present invention, a dataset generation method for farmland boundary extraction by unmanned aerial vehicles (UAVs) is provided, which employs a probe boundary detection strategy to detect the boundary of a random seed point set, perceive valid points, and obtain candidate sample points, including:
[0023] Traverse each candidate point in the random seed point set as a probe anchor point to generate probe segments with 8 neighborhood directions, a width of 3 pixels, and a length of L. The 3-pixel width is obtained by generating discrete pixels with a width of 3 around the line segment based on the Bresenham algorithm. The L-length probe segment is obtained by multiplying the parameter slice size by a preset ratio.
[0024] Iterate through the eight directional probe segments generated for any candidate point, and detect and count whether the color of the pixel point of the segment in each direction changes abruptly;
[0025] If any candidate point has three discontinuous directions or at least four directions where the pixels on the probe segments change color, then the candidate point is retained; otherwise, the candidate point is deleted, and candidate sample points are obtained.
[0026] According to the present invention, a dataset generation method for UAV-based farmland boundary extraction utilizes a minimum overlap rate sampling algorithm to optimize the spatial distribution of candidate sample points and obtain the final retained sample points, including:
[0027] Get a rectangle centered on all candidate sample points, with the size of the slice.
[0028] Based on the bounding boxes, calculate the overlap ratio of overlapping bounding boxes and the distance between their centers;
[0029] Starting from any candidate sample point, obtain the sample point with the smallest overlap rate with the rectangle generated by any candidate sample point;
[0030] The smallest sample point is used as the next candidate sample point, and the iterative calculation continues until the number of sample points obtained is consistent with the number of reserved slices. The reserved sample points constitute the final reserved sample points.
[0031] According to the present invention, a dataset generation method for extracting farmland boundaries using unmanned aerial vehicles (UAVs) includes calculating the overlap rate of overlapping rectangles and the distance between their centers based on bounding boxes.
[0032] Using any two candidate sample points as sample center points, calculate the Euclidean distance between the sample center points, and use it as the distance between the slice center points;
[0033] Extract the distance value between the center point of the slice and the number of pre-preset rankings in the middle, and output the corresponding sample center point;
[0034] Calculate the overlap rate of the rectangles at the center points of the corresponding samples.
[0035] Secondly, the present invention also provides a dataset generation system for extracting farmland boundaries using unmanned aerial vehicles (UAVs), comprising:
[0036] The input module is used to determine the dataset initialization parameter set and obtain the UAV farmland image and the corresponding mask image based on the dataset initialization parameter set;
[0037] The calculation module is used to calculate the number of slices to be retained and the number of random points based on the mask image, and to randomly generate a sufficient number of points within the original mask area to form a random seed point set;
[0038] The detection module is used to detect the boundary of the random seed point set using a probe boundary detection strategy, perceive valid points, and obtain candidate sample points;
[0039] The optimization module is used to optimize the spatial distribution of candidate sample points using a minimum overlap rate sampling algorithm to obtain the final retained sample points;
[0040] The generation module is used to generate the final dataset by using the final retained sample points as the slice center points of the generated dataset.
[0041] Thirdly, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the dataset generation method for UAV farmland boundary extraction as described above.
[0042] Fourthly, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the dataset generation method for UAV farmland boundary extraction as described above.
[0043] The dataset generation method and system for farmland boundary extraction provided by this invention truly achieves cost savings, reduces farmland boundary omissions, and improves dataset quality by employing point sampling to generate slices, probe boundary detection strategies, and minimum overlap sampling algorithms. Attached Figure Description
[0044] To more clearly illustrate the technical solutions in this invention 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 some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0045] Figure 1 This is a flowchart illustrating the dataset generation method for farmland boundary extraction by unmanned aerial vehicles provided by the present invention.
[0046] Figure 2 This is a schematic diagram of the UI interface for custom parameter input provided by the present invention;
[0047] Figure 3 This is a schematic diagram illustrating the specific implementation process of the extended mask diagram provided by the present invention;
[0048] Figure 4 This is a schematic diagram of the generation of 8-neighbor probe segments by the probe anchor point for probe boundary detection provided by the present invention;
[0049] Figure 5 This is a flowchart of the logical judgment of the probe boundary detection strategy provided by the present invention;
[0050] Figure 6 This is a flowchart of the minimum overlap rate sampling algorithm provided by the present invention;
[0051] Figure 7 This is a schematic diagram comparing the distribution of the original generated random seed points, the effective points of the boundary detection strategy, and the slice center points retained by the minimum overlap rate sampling algorithm provided by the present invention.
[0052] Figure 8 This is a schematic diagram of the final slice center point distribution provided by the present invention;
[0053] Figure 9 This is a schematic diagram of the data set generation system for UAV farmland boundary extraction provided by the present invention;
[0054] Figure 10 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0055] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0056] Figure 1 This is a flowchart illustrating the dataset generation method for UAV-based farmland boundary extraction provided in this embodiment of the invention. Figure 1 As shown, it includes:
[0057] Step 100: Determine the dataset initialization parameter set, and obtain the UAV farmland image and the corresponding mask image based on the dataset initialization parameter set;
[0058] Step 200: Calculate the number of slices to be retained and the number of random points based on the mask image, and randomly generate a sufficient number of points within the original mask region to form a random seed point set;
[0059] Step 300: Use a probe boundary detection strategy to detect the boundary of the random seed point set, perceive valid points, and obtain candidate sample points;
[0060] Step 400: Optimize the spatial distribution of candidate sample points using the minimum overlap rate sampling algorithm to obtain the final retained sample points;
[0061] Step 500: Use the final retained sample points as the slice center points for generating the final dataset to generate the final dataset.
[0062] This invention employs an adaptive calculation method to retain the number of slices and randomly generates a sufficient number of points within the boundary region. It uses an 8-neighborhood probe boundary detection method to traverse all random points as probe anchors to filter effective boundary perception points. It optimizes the spatial distribution of candidate sample points based on a minimum overlap rate sampling algorithm. Finally, it generates slices of a preset size from the retained sample points to obtain a standardized UAV sample dataset containing farmland boundaries.
[0063] Specifically, firstly, custom parameters are input to obtain drone images of farmland and corresponding mask images; based on the mask images, the number of retained slices and the number of random points are calculated, and a sufficient number of points are randomly generated only within the original mask area; a probe boundary detection (PDB) strategy is used to detect effective boundary-aware points; the spatial distribution of candidate sample points is optimized based on the Minimal Overlap Sampling Algorithm (MOSA); and the finally retained sample points are used as the slice center points for generating the dataset.
[0064] In one embodiment, step 100 includes:
[0065] Determine the parameter slice size, overlap rate, dataset augmentation strength, and configuration parameters for generating high-density random seed points;
[0066] Collect drone images of farmland to be processed and manually annotated masked images.
[0067] like Figure 2The schematic diagram of the UI interface shown is for implementing a dataset generation method for UAV farmland boundary extraction proposed in this embodiment. First, it is necessary to obtain the UAV farmland images to be processed and the corresponding manually annotated mask images. The specific process is as follows: Input the custom parameters slice size slice_size, overlap ratio overlap_ratio, dataset enhancement intensity k, and the configurable parameter K for generating high-density random seed points. In this embodiment, the default sizes of the parameters are used for narration, that is, slice_size = 1024, overlap_ratio = 0.25, k = 1.5, and K = 10. This embodiment does not make specific limitations, and the custom parameters are determined according to the specific implementation situation and the limited range.
[0068] Furthermore, the centimeter-level resolution UAV farmland images to be processed and the corresponding manually annotated mask images are obtained through the directory path of the dataset. The resolution of the centimeter-level UAV processed here is 0.045m.
[0069] Specifically, the custom parameter slice size slice_size (default is 1024 pixel size) is used to determine the size and slice area of the generated dataset. The calculation formula is as follows:
[0070]
[0071] The custom parameter overlap ratio overlap_ratio (0 < overlap_ratio <= 0.5, default is 0.25) is used to consider the overlap ratio between the generated slices, increase the target continuity of the dataset, and improve the continuity of the receptive field coverage of the dataset; the custom parameter k is used to control the generation scale of the retained sample points. The parameter k (1.0 <= k <= 2.0, default is 1.5) directly determines the data enhancement degree of the generated dataset; the custom parameter K (K >= 10, default is 10) is used as the key configurable item for generating random points, and its value has a positive correlation with the number of generated random points: when the value of K increases, the number of generated random points increases linearly. The larger the value of K, the higher the density of the generated random points, and it can cover various types of farmland areas more comprehensively.
[0072] In one embodiment, step 200 includes:
[0073] Obtain all the boundary pixel points of the original mask image, and take each boundary pixel point as the center point, and generate a square expansion box with the parameter slice size as the range;
[0074] Based on the square expansion box, extract the preset RGB value of the mask to obtain the filling value of the expansion area, and obtain the expanded mask image;
[0075] Obtain the area of the extended mask image, and calculate the area density of the slice in the extended mask image based on the area of the extended mask image and the slice area.
[0076] The initial number of slices, taking into account the slice overlap rate, is calculated based on the area density and overlap rate of the slices in the extended mask image.
[0077] The number of slices for generating the sample dataset is calculated based on the initial number of slices considering the slice overlap rate and the dataset augmentation strength.
[0078] The number of random points is obtained from the number of slices in the generated sample dataset and the configuration parameters for generating high-density random seed points;
[0079] Based on the random number of points, a sufficient number of points are randomly generated within the original mask area to form a random seed point set.
[0080] Specifically, such as Figure 3 As shown, the calculation of the number of retained slices based on the mask image involves generating a unique bounding box with a custom slice size centered on each boundary point of all pixels of the original mask image. The custom slice size, for example, is 1024×1024 in this instance.
[0081] Furthermore, based on the generated 1024×1024 square expanded bounding box, the RGB values of the mask are extracted to obtain the fill value of the expanded region, thereby expanding the mask image and obtaining the expanded mask map. The RGB values of the mask, for example, are (0, 128, 128) in this instance.
[0082] An expanded mask image is generated from the acquired mask image; based on the expanded mask image, the expanded mask image area (expanded_area) is obtained; considering the slice area density, and according to other custom parameters such as slice area and overlap rate, the number of retained slices M and the number of generated random points are calculated. The calculation formula is as follows:
[0083]
[0084]
[0085] (4)
[0086] In equations (2)-(4), The area represents the original mask image, expanded_area represents the area of the expanded mask image, overlap_ratio is a custom overlap ratio parameter to be considered, and k is a parameter that determines the degree of data augmentation of the generated dataset, which is set to 1.5 here; This represents the initial number of slices considering the slice overlap rate; N represents the area density of slices in the extended mask image; M represents the number of slices generated in the sample dataset.
[0087] Random seed points through The calculation is performed, where K is a configurable parameter for generating high-density random seed points, and the value is set to 10 here.
[0088] Based on the number of random points, a sufficient number of points are randomly generated only within the original mask region and on the corresponding farmland image to form a random seed point set. .
[0089] The sample dataset generation method of this invention adopts point sampling technology. Through dynamic parameter adjustment and adaptive point sampling mechanism, it generates high-quality data slices based on sampling points, which breaks through the inherent sliding window sampling method, significantly reduces the computational cost while maintaining data accuracy. Taking into account the relevant factors of quality and quantity in generating UAV farmland boundary datasets, it overcomes the pain point of static parameters and maximizes the generation of high-quality, standardized, centimeter-level sample datasets.
[0090] In one embodiment, step 300 includes:
[0091] Traverse each candidate point in the random seed point set as a probe anchor point to generate probe segments with 8 neighborhood directions, a width of 3 pixels, and a length of L. The 3-pixel width is obtained by generating discrete pixels with a width of 3 around the line segment based on the Bresenham algorithm. The L-length probe segment is obtained by multiplying the parameter slice size by a preset ratio.
[0092] Iterate through the eight directional probe segments generated for any candidate point, and detect and count whether the color of the pixel point of the segment in each direction changes abruptly;
[0093] If any candidate point has three discontinuous directions or at least four directions where the pixels on the probe segments change color, then the candidate point is retained; otherwise, the candidate point is deleted, and candidate sample points are obtained.
[0094] Specifically, such as Figure 4 and Figure 5 As shown, first, by traversing the set of random seed points... Each candidate point As probe anchor points, probe segments with an 8-neighborhood orientation, a width of 3 pixels, and a length of L are generated. Here, L is set to 75% of the slice size, i.e. Specifically, based on the Bresenham algorithm, discrete pixels with a width of 3 are generated around the line segment.
[0095] Furthermore, traversal Eight probe segments are generated for candidate points, and the color abruptness of pixels on each segment in each direction is detected and counted, i.e., whether the RGB values are consistent; the selection is then based on boundary detection logic. If with If, among the eight directions of the probe segments generated for candidate points, there are three discontinuous directions or at least four directions where the pixels on the probe segments undergo color abrupt changes, then the candidate points are retained. Otherwise, delete. Obtain candidate sample point set .
[0096] The sample dataset generation method of this invention also proposes an innovative probe boundary detection strategy. The probe boundary detection supports the generation of 8-neighborhood probe segments using sample points as probe anchor points. Compared with the traditional sliding window method, it achieves accurate pixel-level boundary positioning and adaptability to irregular boundaries, preventing the selection of redundant areas and the omission of farmland boundaries. While ensuring the accuracy and completeness of boundary recognition, it greatly improves processing efficiency, making it an efficient and accurate boundary recognition method.
[0097] In one embodiment, step 400 includes:
[0098] Get a rectangle centered on all candidate sample points, with the size of the slice.
[0099] Based on the bounding boxes, calculate the overlap ratio of overlapping bounding boxes and the distance between their centers;
[0100] Starting from any candidate sample point, obtain the sample point with the smallest overlap rate with the rectangle generated by any candidate sample point;
[0101] The smallest sample point is used as the next candidate sample point, and the iterative calculation continues until the number of sample points obtained is consistent with the number of reserved slices. The reserved sample points constitute the final reserved sample points.
[0102] Among them, based on the bounding boxes, the overlap ratio of overlapping bounding boxes and the distance between their centers are calculated, including:
[0103] Using any two candidate sample points as sample center points, calculate the Euclidean distance between the sample center points, and use it as the distance between the slice center points;
[0104] Extract the distance value between the center point of the slice and the number of pre-preset rankings in the middle, and output the corresponding sample center point;
[0105] Calculate the overlap rate of the rectangles at the center points of the corresponding samples.
[0106] Specifically, such as Figure 6The flowchart shown is for the minimum overlap rate sampling algorithm, based on the candidate sample point set retained after probe boundary detection. Obtain all candidate sample points A rectangle centered on the slice size Randomly select a candidate sample point Initially, based on The generated rectangle The overlap rate is calculated using the formula as follows: ;in, Represents a rectangle The center point of overlap is A rectangular frame; This indicates the overlap ratio of overlapping rectangles.
[0107] , Representing rectangles , The area; Represents a rectangular frame and rectangle The overlapping area; This represents the area of the rectangle, set to 1024 here. 1024.
[0108] Furthermore, obtain all related Overlapping point sets } and all with rectangles Overlapping rate ,exist Select the sample points with the lowest overlap. As the next point Continue iterating; based on the above acquisition method, until the point set is obtained. Stop when the number of slices retained is the same as the number of slices M.
[0109] Furthermore, the output of the Excel file for the top twenty maximum distances and overlap rates is as follows: Based on the aforementioned minimum overlap rate sampling algorithm, the final retained sample points are obtained as the slice center points; the Euclidean distance is calculated using the following formula:
[0110] (5)
[0111] in, and The center point of the sample and coordinates This represents the distance between the two points (unit: pixels).
[0112] Obtain the 20 slices with the largest distance between their center points and output the results;
[0113] Based on the overlap rate calculation formula, the specific formula is as follows:
[0114] (6)
[0115] in, and They are based on sample points and The area of the slice generated at the center point. Slice and slices Area of the overlapping region The area representing the preset slice size;
[0116] Obtain the overlap rate and average overlap rate between overlapping slices and save them in an Excel spreadsheet as a reference metric for the dataset.
[0117] In one embodiment, step 500 includes:
[0118] The final retained sample points are used as the center points of the slices to generate the dataset.
[0119] Specifically, using point sets The points in the data are used as the center points of the slices to generate the final dataset.
[0120] Furthermore, such as Figure 7 The provided diagram compares the distribution of the original generated random seed points, the effective points of the boundary detection strategy, and the slice center points preserved by the minimum overlap rate sampling algorithm. The data set generation process also preserves the point sampling process: after sampling by the probe boundary detection strategy and the minimum overlap rate sampling algorithm, high-density random points are obtained, resulting in sample points with relatively discrete spatial distribution, close to the real boundary, and with higher boundary information.
[0121] Here, this application embodiment also performs simulation verification on the dataset generation method for UAV farmland boundary extraction. The following is a further explanation of the effect of the simulation on the embodiment of this application:
[0122] 1. Simulation test conditions: The simulation test conditions of this application embodiment are: the server GPU is NVIDIA RTX4090D and the memory is 128GB.
[0123] The software platform for the simulation experiments in this application embodiment is: PyCharm 17.06 development tool, Python 3.10, and PyTorch-GPU 2.1.1.
[0124] 2. Simulation content and analysis of experimental results:
[0125] The simulation experiment of this application embodiment uses the embodiment of this application and a prior art (sliding window technology) to generate datasets from the input self-made farmland data image and mask image, both locally (1 image) and globally (36 images), to obtain the generated dataset results.
[0126] In the simulation experiment, the existing technology used is: The existing sliding window technology refers to technology based on the original image. and target window size First, calculate the horizontal or vertical sliding step size based on the preset overlap rate, using the following formula: Next, generate the coordinates of the top-left corner of the window in row-major order. ,in ; Number of windows Then extract each window region. Building a dataset Finally, a zero-fill strategy is used for windows with incomplete boundaries. When, fill with zeros on the right side. Zero-padding is applied at the bottom to ensure that all output windows are the same size. This method achieves dense sampling by precisely controlling the overlap rate while maintaining spatial continuity, and is widely used in computer vision tasks such as image classification and object detection.
[0127] The input images used in the simulation experiment of this application are self-made farmland data images and mask images (36 images in total), which are taken by two high-precision multi-rotor drones, DJI Mavic 3E and DJI Phantom 4 RTK.
[0128] Simulation Experiment 1 involves conducting an experiment using the method described in the embodiments of this application under the above simulation conditions to obtain a dataset.
[0129] Simulation Experiment 2 uses the sliding window technique from the existing technology to conduct an experiment under the above simulation conditions to obtain a dataset.
[0130] Table 1 Comparison of Simulation Experiment Results
[0131]
[0132] Combining Table 1 and Figure 8 As can be seen, compared with the existing sliding window technique for generating datasets, the present application embodiment generates a higher number of data; the data slices generated in the present application embodiment also contain richer boundary information near the boundary, proving that the present application embodiment can obtain a larger number of datasets with better quality.
[0133] The sample dataset generation method of this invention also proposes an innovative sampling algorithm that minimizes overlap rate. By iteratively optimizing and selecting candidate points that minimize overlap, it directly controls the utilization of slice space to ensure the rationality of the dataset's spatial distribution and effectively controls the quality of slice distribution. This avoids the uneven distribution and large blank areas inherent in traditional random sampling; while the FPS method generates sampling points with uniform distances but uncontrollable overlap rates between slices, resulting in severely overlapping data slices. The method of this invention ensures uniform spatial coverage and low overlap of sampling points, improving dataset quality and providing an innovative solution for generating high-quality sample datasets.
[0134] The following describes the dataset generation system for UAV farmland boundary extraction provided by this invention. The dataset generation system for UAV farmland boundary extraction described below can be referred to in correspondence with the dataset generation method for UAV farmland boundary extraction described above.
[0135] Figure 9 This is a schematic diagram of the data set generation system for UAV farmland boundary extraction provided in an embodiment of the present invention, as shown below. Figure 9 As shown, it includes: an input module 91, a calculation module 92, a detection module 93, an optimization module 94, and a generation module 95, wherein:
[0136] Input module 91 is used to determine the dataset initialization parameter set, and obtain UAV farmland images and corresponding mask images based on the dataset initialization parameter set; calculation module 92 is used to calculate the number of retained slices and the number of random points based on the mask image, and randomly generate a sufficient number of points within the original mask area to form a random seed point set; detection module 93 is used to detect the boundary of the random seed point set using a probe boundary detection strategy, perceive valid points, and obtain candidate sample points; optimization module 94 is used to optimize the spatial distribution of candidate sample points using a minimum overlap rate sampling algorithm to obtain the final retained sample points; generation module 95 is used to generate the final dataset by using the final retained sample points as the slice center points of the generated dataset.
[0137] Figure 10 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 10As shown, the electronic device may include a processor 1010, a communication interface 1020, a memory 1030, and a communication bus 1040, wherein the processor 1010, the communication interface 1020, and the memory 1030 communicate with each other through the communication bus 1040. The processor 1010 can call logical instructions in the memory 1030 to execute a dataset generation method for UAV farmland boundary extraction. This method includes: determining a dataset initialization parameter set; acquiring a UAV farmland image and a corresponding mask image based on the dataset initialization parameter set; calculating the number of retained slices and the number of random points based on the mask image; randomly generating a sufficient number of points within the original mask region to form a random seed point set; using a probe boundary detection strategy to detect the boundary of the random seed point set, sensing effective points, and obtaining candidate sample points; optimizing the spatial distribution of candidate sample points using a minimum overlap rate sampling algorithm to obtain the final retained sample points; and using the final retained sample points as the slice center points for generating the dataset to generate the final dataset.
[0138] Furthermore, the logical instructions in the aforementioned memory 1030 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0139] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the dataset generation method for UAV farmland boundary extraction provided by the above methods. The method includes: determining a dataset initialization parameter set; obtaining a UAV farmland image and a corresponding mask image based on the dataset initialization parameter set; calculating the number of retained slices and the number of random points based on the mask image; randomly generating a sufficient number of points within the original mask region to form a random seed point set; using a probe boundary detection strategy to detect the boundary of the random seed point set, perceiving effective points, and obtaining candidate sample points; optimizing the spatial distribution of candidate sample points using a minimum overlap rate sampling algorithm to obtain the final retained sample points; and using the final retained sample points as the slice center points for generating the dataset to generate the final dataset.
[0140] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements a dataset generation method for UAV farmland boundary extraction provided by the above methods. The method includes: determining a dataset initialization parameter set; obtaining a UAV farmland image and a corresponding mask image based on the dataset initialization parameter set; calculating the number of retained slices and the number of random points based on the mask image; randomly generating a sufficient number of points within the original mask region to form a random seed point set; using a probe boundary detection strategy to detect the boundary of the random seed point set, sensing effective points, and obtaining candidate sample points; optimizing the spatial distribution of candidate sample points using a minimum overlap rate sampling algorithm to obtain the final retained sample points; and using the final retained sample points as the slice center points for generating the dataset to generate the final dataset.
[0141] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0142] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0143] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for generating a dataset for unmanned aerial vehicle (UAV) farmland boundary extraction, comprising: The method comprises the following steps: determining a data set initialization parameter set, and obtaining a UAV farmland image and a corresponding mask image according to the data set initialization parameter set; calculating a reserved slice number and a random point number based on the mask image, and generating a sufficient number of points in the original mask region to form a random seed point set; detecting the boundary of the random seed point set by using a probe boundary detection strategy, perceiving effective points, and obtaining candidate sample points; optimizing the spatial distribution of the candidate sample points by using a minimum overlap rate sampling algorithm to obtain final reserved sample points; generating a final data set by taking the final reserved sample points as the center points of the slices of the data set.
2. The method of claim 1, wherein, determining a data set initialization parameter set, and obtaining a UAV farmland image and a corresponding mask image according to the data set initialization parameter set, comprising: determining parameter slice size, overlap rate, data set enhancement intensity and high-density random seed point configuration parameters; collecting a UAV farmland image to be processed and a mask image labeled by a human being. 3.The method of claim 2, wherein, calculating a reserved slice number and a random point number based on the mask image, and generating a sufficient number of points in the original mask region to form a random seed point set, comprising: obtaining all boundary pixel points of the original mask image, taking each boundary pixel point as a center point, and generating a square expansion box with the parameter slice size as the range; based on the square expansion box, extracting the preset RGB value of the mask to obtain the filling value of the expansion region, and obtaining an expansion mask image; obtaining the area of the expansion mask image, and calculating the area density of the slice in the expansion mask image according to the area of the expansion mask image and the slice area; according to the area density of the slice in the expansion mask image and the overlap rate, the initial slice number considering the slice overlap rate is calculated; according to the initial slice number considering the slice overlap rate and the data set enhancement intensity, the slice number of the generated sample data set is calculated; from the slice number of the generated sample data set and the high-density random seed point configuration parameters, the random point number is obtained; based on the random point number, a sufficient number of points are randomly generated in the original mask region to form a random seed point set.
4. The method of claim 2, wherein, detecting the boundary of the random seed point set by using a probe boundary detection strategy, perceiving effective points, and obtaining candidate sample points, comprising: traversing each candidate point in the random seed point set as a probe anchor point, generating an 8-neighbor direction, a 3-pixel size width and an L-length probe line segment, wherein the 3-pixel size width is obtained based on the Bresenham algorithm, and the L-length probe line segment is obtained by multiplying the parameter slice size by a preset proportion; traversing the eight-direction probe line segments generated by any candidate point, detecting and counting whether the color of the line segment pixel points in each direction is changed; if the eight-direction probe line segments of any candidate point satisfy that there are three discontinuous directions or at least four directions of the probe line segments on which the pixel points are color changed, the any candidate point is reserved, otherwise the any candidate point is deleted, and the candidate sample points are obtained.
5. The method of claim 1, wherein, optimizing the spatial distribution of the candidate sample points by using a minimum overlap rate sampling algorithm to obtain final reserved sample points, comprising: obtaining a rectangular box with a slice size as the center of all candidate sample points; Based on the rectangular frame, the rectangular frame overlap rate and the distance between the centers of the mutually overlapping rectangular frames are calculated. Randomly starting from any candidate sample point, a sample point with the minimum rectangular frame overlap rate generated by any candidate sample point is obtained. The minimum sample point is taken as the next any candidate sample point, and iterative calculation is continued until the obtained sample points are consistent with the number of retained slices, and the retained sample points are used to form the final retained sample points.
6. The method of claim 5, wherein, Based on the rectangular frame, the rectangular frame overlap rate and the distance between the centers of the mutually overlapping rectangular frames are calculated, including: Taking any two candidate sample points as sample center points, the Euclidean distance of the sample center points is calculated as the slice center point distance. The distance values in the slice center point distance are extracted, and the corresponding sample center points are outputted. The rectangular frame overlap rate of the corresponding sample center points is calculated. 7.A data set generation system for unmanned aerial vehicle (UAV) farmland boundary extraction, characterized in that, It includes: An input module is configured to determine a data set initialization parameter set, and obtain a UAV farmland image and a corresponding mask image according to the data set initialization parameter set; A calculation module is configured to calculate a retained slice number and a random point number based on the mask image, generate a sufficient number of points inside the original mask area to form a random seed point set; A detection module is configured to detect the boundary of the random seed point set by using a probe boundary detection strategy, sense effective points, and obtain candidate sample points; An optimization module is configured to optimize the spatial distribution of the candidate sample points by using a minimum overlap rate sampling algorithm to obtain final retained sample points; A generation module is configured to take the final retained sample points as slice center points of a generated data set to generate a final data set.
8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the data set generation method for UAV farmland boundary extraction according to any one of claims 1 to 6 when executing the program. 9.A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program implements the data set generation method for UAV farmland boundary extraction according to any one of claims 1 to 6 when executed by the processor.
10. A computer program product comprising a computer program, characterized in that, The computer program implements the data set generation method for UAV farmland boundary extraction according to any one of claims 1 to 6 when executed by the processor.