Farmland plot extraction method and system based on surface-line fusion, and medium
Through the surface and line fusion method, combined with the SAM model and line model, the area surface and boundary lines of the plots in different regions are extracted, which solves the problems of poor migration and complex operation of the plot extraction model in the existing technology, and realizes high-precision plots The boundary division provides accurate data for farmland protection.
Patent Information
- Application Number
- CN202411137449.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2044-08-19
AI Technical Summary
The existing plot extraction model is not very mobile, and it is difficult to directly segment and extract plots in different regions. The operation process of the SAM large model is complicated, making it difficult to adapt to the plot characteristics in different regions.
The method based on surface line fusion is adopted, and the SAM model is used to extract the plot area surface and the line model are used to extract the cultivated land boundary line. The cultivated land plot area with higher accuracy is obtained through surface line fusion, which is suitable for plots in different regions.
Accurate boundary division of plots in different regions is achieved, accurate data support is provided for farmland protection, and the accuracy and completeness of plot extraction is improved.
Smart Images

Figure CN119206475A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of farmland plot extraction, and specifically relates to a method, system and medium for extracting farmland plots based on surface and line fusion. Background Art
[0002] As the basic unit of cultivated land, plots are crucial to the hierarchical management of farmland and other related tasks. It is of great research significance to carry out refined extraction of cultivated land plots. However, in fact, cultivated land types are diverse, including plain dry land, hilly terraces and various paddy fields. At the same time, plots in different regions have different characteristics. The southern region will show the characteristics of large number, small area and complex structure, while the north presents regular plots, but there are obvious ridges between plots, and the dividing lines will be relatively small, making it difficult to accurately extract the boundaries. Therefore, it is crucial to extract cultivated land plots according to the differences in various regions.
[0003] The existing land parcel extraction model is not very portable and it is difficult to directly segment and extract land parcels in different regions. The only way to ensure the accuracy of land parcel extraction is to rewrite the labeled samples and train the model in various places. Although the SAM large model has good generalization ability, it requires user input prompts and the operation process is too complicated. Summary of the invention
[0004] This application proposes a method, system and medium for extracting cultivated land plots based on surface and line fusion. For plots in different regions, the SAM model is used to extract regional surfaces of plots with different characteristics, and the line model is used to extract the cultivated land boundary lines. Then, the surface and line are fused to obtain more accurate cultivated land plot areas, providing accurate data support for cultivated land protection.
[0005] A first aspect of the present application provides a method for extracting cultivated land blocks based on surface-line fusion, the method comprising:
[0006] According to the preset SAM model, the initial plot data is classified into regional surfaces and plots are extracted to obtain plot-surface data;
[0007] According to the preset line model, the ridge lines of the initial plot data are extracted and the boundaries are connected to obtain the plot-line data;
[0008] The plot-surface data and plot-line data are fused to obtain the cultivated land plot extraction results.
[0009] The above scheme uses a method combining surface and line, and uses the SAM model to perform surface extraction to obtain the regional surface of the plot; then the line model is used to extract the cultivated land boundary line inside the plot. The cultivated land boundary line can more easily segment the small boundaries in the plot, so as to achieve more accurate extraction of cultivated land plots; finally, the surface and line are fused according to the plot-surface data and the plot-line data to obtain a complete and high-precision cultivated land plot area, so as to achieve accurate boundary division for plots in different regions and provide accurate data support for cultivated land protection.
[0010] In a possible implementation method of the first aspect, according to a preset SAM model, the initial plot data is classified into regional surfaces and plots are extracted to obtain plot-surface data, specifically:
[0011] Inputting the initial plot data into the SAM model to perform shape classification calculation to obtain a shape index for each plot;
[0012] According to the shape index, each plot is annotated with a prompt by a preset image prompt generation algorithm to obtain a regional surface prompt;
[0013] According to the area and surface prompts, the initial plot data is extracted and merged to obtain plot-surface data.
[0014] The above scheme first calculates the shape index of the initial plot data and completes the classification of the plot according to the shape index; then different labeling methods are used for plots of different shape types to obtain regional surface prompts. The regional surface prompts can quickly extract features and segment plots of cultivated land plots with various shapes, and achieve accurate extraction of plot surface data regardless of whether the plot shape is regular, and complete the separation of the plot to obtain the regional surface of the plot.
[0015] In a possible implementation method of the first aspect, the shape index is specifically:
[0016]
[0017] In the formula, I s is the shape index, S is the area of the plot, and L is the total length of the plot boundary.
[0018] In a possible implementation method of the first aspect, a prompt is annotated for each plot of land according to the shape index by using a preset image prompt generation algorithm to obtain a regional surface prompt, specifically:
[0019] Determine the land shape corresponding to each land parcel according to the shape index, and generate a corresponding mask for each land parcel;
[0020] When the land parcel shape is of the first type, a clustering algorithm is used to generate a plurality of prompt boxes for the mask and a first threshold number of pixels are expanded outward based on the prompt boxes to obtain a regional surface prompt;
[0021] When the land parcel shape is of the second type, the entropy difference between each point in the mask and the center point of the mask is calculated, the points with the largest entropy difference within the second threshold are selected as feature points, and the regional surface prompt is obtained according to the feature points;
[0022] When the land parcel shape is of the third type, disturbance is added to the mask to generate a plurality of masks, and then the masks are intersected to obtain a region surface prompt.
[0023] In the above scheme, because the regional surface prompt can be used to accelerate the extraction of surface data, different prompt generation methods are used for plots of different shapes, and regional surface prompts suitable for plots of different shapes can be obtained to further improve the accuracy of plot extraction. For plots of different shapes, the regional surface prompts are obtained by using the methods of generating prompt boxes, generating feature points, and generating masks, so that surface data extraction can be applicable to cultivated land of different types and shapes.
[0024] In a possible implementation method of the first aspect, the entropy difference between each point in the mask and the center point of the mask is specifically:
[0025] The entropy calculation formula for each point in the mask is:
[0026]
[0027] In the formula, For point p i The entropy of is the entropy of point p0, C is all the points in the mask, For point p i The pixel intensity distribution in the grid centered at is, j is The intensity of all pixels in max is the point whose entropy difference with point p0 is maximized.
[0028] In a possible implementation method of the first aspect, ridge lines are extracted and boundaries are connected for initial plot data according to a preset line model to obtain plot-line data, specifically:
[0029] Inputting initial plot data into the line model to extract features and generate cultivated land boundary lines between various plots;
[0030] Based on the edge breakpoint connection method, the breakpoint detection and direction connection of the cultivated land boundary line are performed to obtain the plot-line data.
[0031] The above scheme uses line extraction to obtain the cultivated land boundary line inside the plot for the relatively small and difficult-to-segment boundary lines in the plot. First, the cultivated land boundary lines between the plots are preliminarily generated, the directions of the cultivated land boundary lines are determined and connected, and the closed cultivated land boundary lines are obtained for plot segmentation.
[0032] In a possible implementation method of the first aspect, the plot-surface data and the plot-line data are subjected to surface-line fusion processing to obtain a cultivated land plot extraction result, specifically:
[0033] Cutting and fusing the plot-surface data and the plot-line data in sequence to obtain the surface-line fused plot data;
[0034] The plot boundary optimization and vectorization processing are performed on the surface-line fused plot data to obtain the cultivated land plot extraction results.
[0035] The above scheme performs surface-line fusion on the plot-surface data and the plot-line data to obtain the cultivated land plots containing precise boundary lines.
[0036] In a possible implementation method of the first aspect, the initial plot data is specifically:
[0037] Acquire the cultivated land image to be extracted;
[0038] The cultivated land image is divided into blocks according to preset road boundary factors to obtain initial land block data.
[0039] The above scheme pre-processes the cultivated land image to be extracted before feature extraction. This is because the reasons for the division of plots are not only natural factors, but also road construction. Therefore, in order to improve the accuracy of plot extraction, the cultivated land image is first preliminarily divided based on road factors to obtain initial plot data as the basic data for subsequent plot extraction.
[0040] The second aspect of the present application provides a farmland plot extraction system based on surface-line fusion, the system comprising: a surface data extraction module, a line data extraction module and a farmland plot extraction module;
[0041] The surface data extraction module is used to classify the regional surface and extract the land parcels from the initial land parcel data according to the preset SAM model to obtain the land parcel-surface data;
[0042] The line data extraction module is used to extract the ridge lines and connect the boundaries of the initial plot data according to the preset line model to obtain the plot-line data;
[0043] The farmland plot extraction module is used to perform surface-line fusion processing on the plot-surface data and the plot-line data to obtain the farmland plot extraction result.
[0044] A third aspect of the present application provides a storage medium storing computer-readable program code, which, when executed, implements the steps of a method for extracting cultivated land plots based on surface-line fusion as described in any one of the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the implementation manner will be briefly introduced below. Obviously, the drawings described below are only some implementation manners of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0046] Figure 1 It is a specific flow chart of a method for extracting cultivated land based on surface-line fusion provided in a certain embodiment of the present application;
[0047] Figure 2 It is a flow chart of farmland plot extraction of a farmland plot extraction method based on surface-line fusion provided in a certain embodiment of the present application;
[0048] Figure 3 A structural diagram of a farmland plot extraction system based on surface-line fusion is provided in a certain embodiment of the present application. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0050] It should be understood that the step numbers used in this article are only for the convenience of description and are not intended to limit the order in which the steps are executed.
[0051] First embodiment
[0052] As the basic unit of cultivated land, plots are crucial to the hierarchical management of farmland and other related tasks. Therefore, the refined extraction of cultivated land plots can provide data support for agricultural management. However, due to the diversity of cultivated land types in my country, some cultivated lands are characterized by large quantity, small area and complex structure. Some cultivated lands have obvious ridges, and the dividing lines are relatively small, making it difficult to accurately extract the boundaries. In view of the above situation, the embodiment of the present application selects the corresponding prompt method to extract the plot area surface according to the characteristics of the plot. At the same time, in order to solve the problem of segmentation of small ridges, a line model is introduced to extract small cultivated land boundary lines. Finally, a more accurate cultivated land plot is obtained by combining the surface and line method.
[0053] like Figure 1 As shown, Figure 1 A specific flow chart of a method for extracting cultivated land based on surface-line fusion is provided for a certain embodiment of the present application. The method for extracting cultivated land based on surface-line fusion in this embodiment includes steps S1 to S3, which are described in detail as follows:
[0054] Step S1, according to the preset SAM model, the initial plot data is classified into regional surfaces and plots are extracted to obtain plot-surface data.
[0055] In the embodiment of the present application, the acquired cultivated land image is first preprocessed. Because in addition to the natural division of farmland caused by the influence of terrain and rivers, the artificially constructed road network also causes the division of farmland, and farmland often naturally forms multiple small areas with the division of blocks such as road networks. If these influencing factors are ignored and the cultivated land plots are directly extracted, it will cause great confusion, and the extraction results will span multiple blocks, greatly reducing the extraction accuracy of the cultivated land plots. Therefore, between performing face extraction and pre-extraction, the cultivated land image is first divided into blocks according to the preset plot boundary factors to obtain initial plot data.
[0056] Furthermore, the land parcel boundary factors include natural and artificial factors such as roads and rivers. Roads and rivers are extracted from the cultivated land image to generate a mask, and the cultivated land image is divided into blocks by the mask. Then, each area after the block division is used as the basic data for subsequent cultivated land parcel extraction, that is, the initial land parcel data. The mask is a template of an image filter, which is used to filter the pixels of the image to highlight the required objects or signs.
[0057] Then the initial plot data is input into the SAM model to perform shape classification calculation, hint generation and plot extraction in sequence. The SAM model is an image segmentation model that can segment any object in any image without any annotation. The model architecture mainly includes an image encoder, a hint encoder and a mask decoder.
[0058] First, because the shapes of plots vary, it is necessary to calculate the shape index of each plot to classify all plots according to their respective shapes. In the embodiment of the present application, the cultivated land plots are divided into three different types, namely, plots close to rectangles, narrow and long plots, and plots that are neither narrow nor close to rectangles.
[0059] The specific calculation formula of the shape index is:
[0060]
[0061] In the formula, I sis the shape index, S is the area of the plot, and L is the total length of the plot boundary.
[0062] After calculating the shape index of each plot, the plots are classified according to the shape index, and then the image encoder of the SAM model is used to generate a mask corresponding to each plot.
[0063] Taking into account that similar objects around plots of different shapes have different degrees of interference in plot segmentation, an image prompt generation algorithm corresponding to each type of cultivated land plot is used. The prompt encoder of the SAM model is used to generate regional surface prompts for each plot, and regional surface prompts suitable for plots of different shapes are obtained to further improve the accuracy of plot extraction.
[0064] If the plot is a nearly rectangular plot, a regional surface prompt in the form of a prompt box is generated. The specific process is: first, the pixel map generated by the clustering algorithm is used to determine the prompt box for the mask corresponding to the plot, thereby obtaining a preliminary prompt box; then, in order to minimize the loss of plot edge information, the preliminary prompt box is expanded outward by 10 pixels to obtain a regional surface prompt in the form of a prompt box. It is worth mentioning that, considering that the extraction results of the SAM model may have many holes, the opening and closing operations are used in the embodiment of the present application to generate regional surface prompts for the initial plot data.
[0065] Optionally, the embodiment of the present application uses DBSCAN clustering to generate a pixel map.
[0066] It is worth mentioning that for area face hints in the form of hint boxes, in the subsequent decoding process of the mask decoder, multiple hint boxes of an initial plot data need to be encoded together as part of the sparse embedding, which can have an important impact on the optimization of the mask decoder. Specifically, the upper left point and lower right point of each hint box are regarded as two parallel dimensions. First, the hint box is normalized and encoded, and then the hint box is processed in turn with Gaussian fuzzy encoding to obtain high-dimensional features. Finally, multiple high-dimensional features are processed into a high-dimensional feature vector, which can be used as part of the sparse embedding.
[0067] If the plot is a long and narrow plot, considering that generating a regional surface prompt in the form of an outer rectangular prompt box will increase the area of the plot of this shape and reduce the accuracy of arable land extraction, it is more appropriate to choose to generate a regional surface prompt in the form of feature points. The specific process is: find the center point of the mask corresponding to the plot, take the remaining points in the mask as candidate points, first calculate the entropy of all candidate points, and then calculate the entropy difference between each candidate point and the center point, select 9 candidate points with the largest entropy difference as feature points, and obtain the regional surface prompt in the form of feature points based on the feature points.
[0068] In the embodiment of the present application, in order to calculate the entropy of each candidate point, a 9×9 grid centered on each candidate point is used. The entropy of each candidate point is calculated based on the distribution of pixel intensities in the corresponding grid. The entropy calculation formula for each point in the mask is:
[0069]
[0070] In the formula, For point p i The entropy of is the entropy of point p0, C is all the points in the mask, For point p i The pixel intensity distribution in the grid centered at is, j is The intensity of all pixels in max is the point whose entropy difference with point p0 is maximized.
[0071] In addition, the embodiment of the present application also adds background points outside the range of the narrow and long plot, which can provide more robust prior knowledge for the feature extraction of the subsequent SAM model to effectively distinguish the types of plots with high similarity. In some embodiments, a gradient calculation method is used to select background points.
[0072] If the plot is neither long and narrow nor close to a rectangle, the optimized mask method is used. The specific process is: add disturbance to the mask corresponding to the plot to enhance the hint strength to generate several slightly different mask hints; then find the intersection of multiple different mask hints of the same area to obtain the basic area; because these different mask hints may lead to differences in segmentation results, use the Euclidean distance between pixels of the same category in the mask to determine whether it is an area outside the intersection, so as to obtain a high-precision basic area, and obtain a regional surface hint in the form of a mask based on the basic area.
[0073] Then, according to the regional surface prompt of the initial land parcel data, the mask decoder of the SAM model is used to perform land parcel extraction on the initial land parcel data to obtain extraction results, and the land parcel-surface data is obtained according to the extraction results.
[0074] Optionally, if the extraction result contains many fragmented and small plots, these small plots are merged, and after the merging, the noise of the merged result is removed according to a preset threshold to further increase the data accuracy.
[0075] Step S2, according to the preset line model, the ridge lines of the initial plot data are extracted and the boundaries are connected to obtain the plot-line data.
[0076] In the embodiment of the present application, the obtained plot-surface data can be regarded as a kind of mask data, which is a threshold-free, low-quality prediction map. Because the plots have fine ridge lines, the plot-surface data alone cannot distinguish the fine dividing lines in the cultivated land, so the line model is needed to extract the cultivated land boundary lines between the plots to further improve the accuracy of the cultivated land plots.
[0077] Exemplarily, the embodiment of the present application adopts a line model based on YOLOv8 with an added OCR mechanism.
[0078] The initial plot data is input into the line model for feature extraction. Considering that adjacent farmland plots have contextual connectivity, the module of the OCR mechanism is used to sample the initial plot data, which strengthens the context aggregation of semantic segmentation and enhances the representation of context information of the target area based on the object, thereby using the context information to improve the pixel-level classification results and realize the extraction of the cultivated land boundary lines between each plot.
[0079] At the same time, the features extracted by YOLOv8 are used to output the farmland boundary lines between each plot through the convolution layer. In order to better integrate the object-based semantic information and dense spatial context information, the line model also uses a cross-attention structure to generate weights for the soft object area containing object category information through the Softmax function to obtain the farmland boundary line represented by pixels.
[0080] After obtaining the cultivated land boundary line, it is necessary to continue edge detection of the cultivated land boundary line. Since the edges obtained by the general deep learning-based edge detection method are generated by probability mapping, the connectivity of the boundary line cannot be guaranteed. In an embodiment of the present application, in order to ensure that the boundary is connected and closed into a closed area, an edge breakpoint connection method based on directional information is used to perform breakpoint detection on the cultivated land boundary line. The specific process is: adding a deep learning extraction module for directional learning and boundary probability to perform breakpoint detection on the cultivated land boundary line, and iteratively connecting, combining the directional information at the breakpoint and the edge probability map in the neighborhood to determine the connection direction. Through the above process, completely closed plot-line data can be obtained, thereby improving the integrity of the cultivated land plot extraction results.
[0081] Furthermore, in breakpoint detection, a connection diagram containing directional information is provided at the breakpoint, and the connection diagram provides directional information to guide subsequent breakpoint connections.
[0082] Step S3, performing surface-line fusion processing on the plot-surface data and the plot-line data to obtain the cultivated land plot extraction result.
[0083] In the embodiment of the present application, the plot-surface data and the plot-line data are cut and fused in sequence to obtain the surface-line fused plot data. Then, the surface-line fused plot data is processed by plot boundary refinement and boundary extension, and finally vectorization is performed to obtain the cultivated land plot extraction result.
[0084] To further demonstrate the process of farmland plot extraction, Figure 2 The following example shows the process of a plot image going through surface extraction, line extraction and surface-line fusion. In the surface extraction process, boxes, points and masks are marked in the plot image for plots of different shapes. Finally, the image obtained by surface-line fusion clearly divides several plots of cultivated land.
[0085] Implementing the embodiments of the present application has the following beneficial effects:
[0086] The embodiment of the present application pre-processes the image data to be extracted, performs preliminary block division according to the artificial road network, and obtains initial plot data composed of various small areas; then uses the SAM model to extract the plot area surface, and uses different prompt generation methods for plots of different shapes in the process of surface extraction to obtain regional surface prompts that can assist in extracting surface data. Because the prompt generation method adopts different methods for different terrains, it can ensure that the accuracy of the plot will not be reduced in the process of generating prompts, and high-precision plot-surface data is obtained; at the same time, a line model is also used to extract the boundary line of cultivated land, and direction information is also used in the process of online extraction to make the acquired boundary line of cultivated land a complete closed state, thereby improving the integrity of the extraction result of cultivated land plots; finally, surface and line fusion is performed to obtain a more accurate cultivated land plot area. This method is not only applicable to plots with different geographical characteristics, but also ensures that these plots contain fine cultivated land boundary lines, can solve the problem of accurate extraction of fine field ridges, and provide accurate data support for cultivated land protection.
[0087] Second embodiment
[0088] Further, in order to execute the farmland plot extraction system based on surface-line fusion corresponding to the above method embodiment to achieve the corresponding functions and technical effects, Figure 3 A structural diagram of a farmland plot extraction system based on surface-line fusion is provided. For ease of description, only the parts related to this embodiment are shown. The farmland plot extraction system based on surface-line fusion provided by the embodiment of the present application includes:
[0089] The surface data extraction module 201 is used to classify the regional surfaces and extract the land parcels from the initial land parcel data according to the preset SAM model to obtain land parcel-surface data.
[0090] In the embodiment of the present application, before the regional surface classification and plot extraction are performed, the cultivated land image to be extracted is first divided into blocks according to the preset road boundary factors to obtain the initial plot data. Because in addition to the natural division of farmland caused by the terrain and river influence, the artificially constructed road network also causes the division of farmland, and farmland often naturally forms multiple small areas with the division of blocks such as road networks. If these influencing factors are ignored and the cultivated land plots are directly extracted, it will cause great confusion, and the extraction results will span multiple blocks, greatly reducing the extraction accuracy of cultivated land plots.
[0091] Exemplarily, in the embodiment of the present application, the land boundary factors include natural and man-made factors such as roads and rivers. Roads and rivers are extracted from the cultivated land image to generate a mask, the cultivated land image is divided into blocks by the mask, and then the divided areas are used as basic data for subsequent cultivated land plot extraction, that is, the initial plot data.
[0092] Then the initial plot data is input into the SAM model to perform shape classification calculation, prompt generation and plot extraction in sequence to obtain plot-surface data.
[0093] The line data extraction module 202 is used to extract ridge lines and connect boundaries of the initial plot data according to a preset line model to obtain plot-line data.
[0094] In the embodiment of the present application, because the acquired plot-surface data is only a prediction map without threshold and of low quality in the cultivated land plot containing fine field ridge lines, and cannot clearly distinguish the fine dividing lines in the cultivated land, it is also necessary to use the line model to extract the cultivated land boundary lines between the various plots to further improve the accuracy of the cultivated land plots. Therefore, the initial plot data is input into the line model for feature extraction, and the cultivated land boundary lines between the various plots are extracted to obtain completely closed plot-line data, thereby improving the integrity of the cultivated land plot extraction results.
[0095] The cultivated land parcel extraction module 203 is used to perform surface-line fusion processing on the parcel-surface data and the parcel-line data to obtain the cultivated land parcel extraction result.
[0096] In the embodiment of the present application, the plot-surface data and the plot-line data are cut and fused in sequence to obtain the surface-line fused plot data. Then, the surface-line fused plot data is processed by plot boundary refinement and boundary extension, and finally vectorization is performed to obtain the final cultivated land plot extraction result.
[0097] In some embodiments, the surface data extraction module 201 further includes:
[0098] The plot-surface data acquisition unit is used to input the initial plot data into the SAM model for shape classification calculation to obtain the shape index of each plot; based on the shape index, each plot is prompted and annotated by a preset image prompt generation algorithm to obtain a regional surface prompt; based on the regional surface prompt, the initial plot data is extracted and merged to obtain plot-surface data.
[0099] The SAM model is an image segmentation model that can segment any object in any image without any annotation. The model architecture mainly includes an image encoder, a hint encoder and a mask decoder.
[0100] The embodiment of the present application classifies all plots according to their respective shapes by calculating the shape index of each plot, mainly dividing the cultivated land plots into three different types, namely, plots close to rectangles, narrow and long plots, and plots that are neither narrow nor close to rectangles. After determining the type of each plot, the image encoder of the SAM model is used to generate a mask corresponding to each plot.
[0101] Taking into account that similar objects around plots of different shapes have different degrees of interference in plot segmentation, an image prompt generation algorithm corresponding to each type of cultivated land plot is used. The prompt encoder of the SAM model is used to generate regional surface prompts for each plot, and regional surface prompts suitable for plots of different shapes are obtained to further improve the accuracy of plot extraction.
[0102] If the plot is a nearly rectangular plot, a regional surface prompt in the form of a prompt box is generated. The specific process is: first, the pixel map generated by the clustering algorithm is used to determine the prompt box for the mask corresponding to the plot, thereby obtaining a preliminary prompt box; then, in order to minimize the loss of plot edge information, the preliminary prompt box is expanded outward by 10 pixels to obtain a regional surface prompt in the form of a prompt box. It is worth mentioning that, considering that the extraction results of the SAM model may have many holes, the opening and closing operations are used in the embodiment of the present application to generate regional surface prompts for the initial plot data.
[0103] Optionally, the embodiment of the present application uses DBSCAN clustering to generate a pixel map.
[0104] It is worth mentioning that for area face hints in the form of hint boxes, in the subsequent decoding process of the mask decoder, multiple hint boxes of an initial plot data need to be encoded together as part of the sparse embedding, which can have an important impact on the optimization of the mask decoder. Specifically, the upper left point and lower right point of each hint box are regarded as two parallel dimensions. First, the hint box is normalized and encoded, and then the hint box is processed in turn with Gaussian fuzzy encoding to obtain high-dimensional features. Finally, multiple high-dimensional features are processed into a high-dimensional feature vector, which can be used as part of the sparse embedding.
[0105] If the plot is a long and narrow plot, considering that generating a regional surface prompt in the form of an outer rectangular prompt box will increase the area of the plot of this shape and reduce the accuracy of arable land extraction, it is more appropriate to choose to generate a regional surface prompt in the form of feature points. The specific process is: find the center point of the mask corresponding to the plot, take the remaining points in the mask as candidate points, first calculate the entropy of all candidate points, and then calculate the entropy difference between each candidate point and the center point, select 9 candidate points with the largest entropy difference as feature points, and obtain the regional surface prompt in the form of feature points based on the feature points.
[0106] In addition, the embodiment of the present application also adds background points outside the range of the narrow and long plot, which can provide more robust prior knowledge for the feature extraction of the subsequent SAM model to effectively distinguish the types of plots with high similarity. In some embodiments, a gradient calculation method is used to select background points.
[0107] If the plot is neither long and narrow nor close to a rectangle, the optimized mask method is used. The specific process is: add disturbance to the mask corresponding to the plot to enhance the hint strength to generate several slightly different mask hints; then find the intersection of multiple different mask hints of the same area to obtain the basic area; because these different mask hints may lead to differences in segmentation results, use the Euclidean distance between pixels of the same category in the mask to determine whether it is an area outside the intersection, so as to obtain a high-precision basic area, and obtain a regional surface hint in the form of a mask based on the basic area.
[0108] Therefore, the embodiments of the present application respectively generate area surface prompts in the form of prompt boxes, feature points and masks for plots of different shapes. These different types of area surface prompts can minimize the impact of similar objects around the plot on the extraction of the plot boundary line, thereby improving the accuracy of plot extraction.
[0109] Then, according to the regional surface prompt of the initial land parcel data, the mask decoder of the SAM model is used to perform land parcel extraction on the initial land parcel data to obtain extraction results, and the land parcel-surface data is obtained according to the extraction results.
[0110] Optionally, if the extraction result contains many fragmented and small plots, these small plots are merged, and after the merging, the noise of the merged result is removed according to a preset threshold to further increase the data accuracy.
[0111] In some embodiments, the line data extraction module 202 further includes:
[0112] The plot-line data acquisition unit is used to input the initial plot data into the line model for feature extraction to generate the cultivated land boundary lines between the plots; based on the edge breakpoint connection method, the cultivated land boundary lines are breakpoint detected and direction connected to obtain the plot-line data.
[0113] Exemplarily, the embodiment of the present application adopts a line model based on YOLOv8 with an added OCR mechanism.
[0114] The initial plot data is first input into the line model. Considering that adjacent farmland plots have contextual connectivity, the module of the OCR mechanism is used to sample the initial plot data, thereby strengthening the context aggregation of semantic segmentation and enhancing the representation of context information of the object-based target area. The context information is then used to improve the pixel-level classification results and realize the extraction of the cultivated land boundary lines between each plot.
[0115] At the same time, the features extracted by YOLOv8 are used to output the farmland boundary lines between each plot through the convolution layer. In order to better integrate the object-based semantic information and dense spatial context information, the line model also uses a cross-attention structure to generate weights for the soft object area containing object category information through the Softmax function to obtain the farmland boundary line represented by pixels.
[0116] In fact, some of the cultivated land boundary lines obtained through the line model are not closed and lack connectivity. Therefore, it is necessary to perform edge detection on the cultivated land boundary lines to determine the connection direction of the cultivated land boundary lines and connect them to obtain completely closed plot-line data, thereby improving the integrity of the cultivated land plot extraction results.
[0117] The edges obtained by the commonly used deep learning-based edge detection method are generated by probability mapping, and therefore cannot guarantee the connectivity of the boundary line. Therefore, in an embodiment of the present application, an edge breakpoint connection method based on directional information is used to perform breakpoint detection on the cultivated land boundary line, which can ensure that the boundaries of the cultivated land plots are connected and closed into closed areas. The specific process of breakpoint detection is: adding a deep learning extraction module for directional learning and boundary probability to perform breakpoint detection on the cultivated land boundary line, and performing iterative connection, combining the directional information at the breakpoint and the edge probability map in the neighborhood to determine the connection direction.
[0118] Implementing the embodiments of the present application has the following beneficial effects:
[0119] The embodiment of the present application first performs preliminary segmentation of the cultivated land image to be extracted by artificial road network, river and other road boundary factors, and obtains the initial plot data as the basis for subsequent cultivated land plot extraction. Then, facing the combined method, regional surface extraction and cultivated land boundary line extraction are performed on the initial plot data at the same time. First, regional surface extraction uses the SAM model to adopt different regional surface prompt generation methods for plots of different shapes, and then extracts and merges the initial plot data according to the regional surface prompt to obtain plot-surface data, which can preliminarily display the shape and boundary of each plot; at the same time, cultivated land boundary line extraction uses the line model to extract the small cultivated land boundary lines in the initial plot data, and connects the cultivated land boundary lines in the direction to improve the integrity and accuracy of the cultivated land plot; finally, the plot-surface data and the plot-line data are subjected to surface-line fusion processing, so as to realize the accurate extraction of cultivated land plots of any type and shape, even if they contain many small and difficult-to-segment cultivated land ridge lines, and obtain more accurate cultivated land plots, providing effective data support for agricultural management.
[0120] An embodiment of the present application also provides a storage medium, which stores computer-readable program codes. When the computer-readable program codes are executed, the steps of the above-mentioned method for extracting cultivated land plots based on surface-line fusion are implemented.
[0121] The specific embodiments described above further describe the purpose, technical solutions and beneficial effects of the present application in detail. It should be understood that the above description is only a specific embodiment of the present application and is not intended to limit the scope of protection of the present application. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of protection of the present application.
Claims
1. A method for extracting cultivated land based on surface-line fusion, characterized in that: include: According to the preset SAM model, the initial plot data is classified into regional surfaces and plots are extracted to obtain plot-surface data; According to the preset line model, the ridge lines of the initial plot data are extracted and the boundaries are connected to obtain the plot-line data; The plot-surface data and plot-line data are fused to obtain the cultivated land plot extraction results.
2. The method for extracting cultivated land based on surface-line fusion according to claim 1, characterized in that: According to the preset SAM model, the initial plot data is classified into regional surfaces and plots are extracted to obtain plot-surface data, specifically: Inputting the initial plot data into the SAM model to perform shape classification calculation to obtain a shape index for each plot; According to the shape index, each plot is annotated with a prompt by a preset image prompt generation algorithm to obtain a regional surface prompt; According to the area and surface prompts, the initial plot data is extracted and merged to obtain plot-surface data.
3. The method for extracting cultivated land based on surface-line fusion according to claim 2, characterized in that: The shape index is specifically: In the formula, I s is the shape index, S is the area of the plot, and L is the total length of the plot boundary.
4. The method for extracting cultivated land based on surface-line fusion according to claim 2, characterized in that: According to the shape index, each plot is annotated with a prompt through a preset image prompt generation algorithm to obtain a regional surface prompt, specifically: Determine the land parcel shape corresponding to each land parcel according to the shape index, and generate a corresponding mask for each land parcel; When the land parcel shape is of the first type, a clustering algorithm is used to generate a plurality of prompt boxes for the mask and a first threshold number of pixels are expanded outward based on the prompt boxes to obtain a regional surface prompt; When the land parcel shape is of the second type, the entropy difference between each point in the mask and the center point of the mask is calculated, the points with the largest entropy difference within the second threshold are selected as feature points, and the regional surface prompt is obtained according to the feature points; When the land parcel shape is of the third type, disturbance is added to the mask to generate a plurality of masks, and then the masks are intersected to obtain a region surface prompt.
5. The method for extracting cultivated land based on surface-line fusion according to claim 4, characterized in that: The entropy difference between each point in the mask and the center point of the mask is specifically: The entropy calculation formula for each point in the mask is: In the formula, For point p i The entropy of is the entropy of point p0, C is all the points in the mask, For point p i The pixel intensity distribution in the grid centered at is, j is The intensity of all pixels in max is the point whose entropy difference with point p0 is maximized.
6. The method for extracting cultivated land based on surface-line fusion according to claim 1, characterized in that: According to the preset line model, the initial plot data is subjected to ridge line extraction and boundary connection to obtain plot-line data, specifically: Inputting initial plot data into the line model to extract features and generate cultivated land boundary lines between various plots; Based on the edge breakpoint connection method, the breakpoint detection and direction connection of the cultivated land boundary line are performed to obtain the plot-line data.
7. The method for extracting cultivated land based on surface-line fusion according to claim 1, characterized in that: The surface-line fusion processing is performed on the plot-surface data and the plot-line data to obtain the cultivated land plot extraction result, which is specifically as follows: Cutting and fusing the plot-surface data and the plot-line data in sequence to obtain the surface-line fused plot data; The plot boundary optimization and vectorization processing are performed on the surface-line fused plot data to obtain the cultivated land plot extraction results.
8. The method for extracting cultivated land based on surface-line fusion according to claim 1, characterized in that: The initial plot data is specifically: Acquire the cultivated land image to be extracted; The cultivated land image is divided into blocks according to preset road boundary factors to obtain initial land block data.
9. A system for extracting cultivated land based on surface-line fusion, characterized in that: include: Surface data extraction module, line data extraction module and cultivated land plot extraction module; The surface data extraction module is used to classify the regional surface and extract the land parcels from the initial land parcel data according to the preset SAM model to obtain the land parcel-surface data; The line data extraction module is used to extract the ridge lines and connect the boundaries of the initial plot data according to the preset line model to obtain the plot-line data; The farmland plot extraction module is used to perform surface-line fusion processing on the plot-surface data and the plot-line data to obtain the farmland plot extraction result.
10. A storage medium, characterized in that: The storage medium stores computer-readable program codes, which, when executed, implement the steps of a method for extracting cultivated land plots based on surface-line fusion according to any one of claims 1 to 8.
Citation Information
Patent Citations
Crop artificial intelligence automatic identification method and system based on unmanned aerial vehicle image
CN116543325A
Parcel segmentation method based on SAM model
CN117197450A
Method for detecting damage change of fine-grained building by matching SAM model
CN117292255A
Cultivated land parcel segmentation method integrating multi-layer attention mechanism and edge features
CN117523396A
Image processing method and device, forcible entry robot and computer readable storage medium
CN118071822A
Cited By
Partition investigation and evaluation system based on black land cultivated land quality red line evaluation protection
CN120599501A
Zonal Survey and Assessment System for Evaluation and Protection of Cultivated Land Quality Based on the Red Line of Black Soil
CN120599501B
