Edge optimization method and device for dense feature segmentation, equipment and medium
By identifying and optimizing nodes and line segments in the segmented grayscale image of dense feature segmentation, the problem of topological errors in dense feature segmentation is solved, achieving more efficient vectorization processing while preserving the shape characteristics of the features.
Patent Information
- Application Number
- CN202510327436.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-19
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2045-03-19
AI Technical Summary
Existing technologies suffer from topological problems in the raster vectorization results of dense feature segmentation, especially in the vectorization process of features such as farmland plots, individual greenhouses, and dense residential areas. Issues such as noise, fragmented patches, holes, and irregular boundaries make it difficult to apply them directly.
By acquiring a segmented grayscale image, performing raster vectorization, identifying and removing important pixels, segmenting line segments based on node determination rules, performing deduplication and optimization processing, and finally reconstructing the line segments to obtain the optimized vector result.
It effectively solves the topological error problem, preserves the shape features of ground features, reduces algorithm complexity, improves processing efficiency, and reduces the amount of manual post-processing work.
Smart Images

Figure CN120259879B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image data processing, in particular to an edge optimization method and device for dense feature segmentation, equipment and medium. BACKGROUND
[0002] Remote sensing image is the image data of the earth's surface obtained by remote sensing technology. These data record the electromagnetic wave information of the earth's surface objects, and are the basis for remote sensing technology to realize earth observation and data analysis. Information extraction based on remote sensing image is an important content in the field of remote sensing image analysis, which can provide basic geographic data for various aspects required by social production and life, such as geographic conditions census and urban planning.
[0003] In recent years, with the continuous development of machine learning and artificial intelligence, the precision and efficiency of feature extraction and segmentation of remote sensing image have been greatly improved. However, the extraction result is mostly pixel-level segmentation, so there are problems such as noise, fine spot, hole, irregular boundary in the vectorization process, especially for dense feature vectorization process such as cultivated land plot, single greenhouse, dense residential area, etc. Topological problems are serious, and the processing result is difficult to be directly applied. SUMMARY
[0004] In order to solve the topological problem in the edge optimization process of grid vectorization result for dense feature segmentation, the present application provides an edge optimization method, device, equipment and medium for dense feature segmentation.
[0005] In the first aspect, the present application provides an edge optimization method for dense feature segmentation, which comprises:
[0006] obtaining a segmentation gray image of the feature to be extracted;
[0007] performing grid vectorization on the segmentation gray image to obtain a vector result;
[0008] obtaining all vector elements in the vector result to form an element set, and traversing the element set to obtain element points, and then forming an element point set by the de-duplicated element points;
[0009] traversing the element point set according to a preset node judgment rule, and forming an element node set by the element points judged as nodes;
[0010] based on the nodes in the element node set, respectively segmenting the corresponding vector elements into a plurality of line segments to obtain a line segment set, and recording the corresponding relationship between the line segments and the vector elements;
[0011] de-duplicating the line segments of the line segment set to obtain a de-duplicated line segment set;
[0012] The deduplicated line segments are then optimized to obtain an optimized set of line segments;
[0013] Based on the correspondence between line segments and vector elements, each vector element is traversed, and the line segments of the optimized line segment set are reorganized to obtain the optimized vector result.
[0014] Secondly, this application provides an edge optimization device for dense feature segmentation, the device comprising:
[0015] The data acquisition module is used to acquire the segmented grayscale image of the features to be extracted.
[0016] The vectorization module is used to perform raster vectorization on the segmented grayscale image to obtain a vector result;
[0017] The feature determination module is used to obtain all vector features in the vector result, form a feature set, and traverse the feature set to obtain feature points, and form a feature point set by deduplicating the feature points.
[0018] The feature node determination module is used to traverse the feature point set according to the preset node determination rules and form a feature node set by the feature points determined to be nodes.
[0019] The line segment set acquisition module is used to divide the corresponding vector features into multiple line segments based on the nodes in the feature node set, obtain the line segment set, and record the correspondence between the line segments and the vector features;
[0020] The deduplication module is used to deduplicate the line segments in the line segment set to obtain a deduplicated line segment set.
[0021] The optimization module is used to optimize the deduplicated line segments to obtain an optimized set of line segments;
[0022] The reorganization module is used to reorganize the line segments of the optimized line segment set based on the correspondence between line segments and vector elements, traversing each vector element to obtain the optimized vector result.
[0023] Thirdly, this application provides an electronic device that adopts the following technical solution:
[0024] An electronic device includes a processor coupled to a memory;
[0025] The memory stores a computer program that can be loaded by a processor and executed as described in any of the first aspects for edge optimization methods for dense feature segmentation.
[0026] Fourthly, this application provides a computer-readable storage medium, which adopts the following technical solution:
[0027] A computer readable storage medium storing a computer program capable of being loaded by a processor and executing the edge optimization method for dense feature segmentation according to any one of the first aspect.
[0028] Compared with the prior art, the application obtains the element nodes and the line segment set of the segmentation gray scale graph of the vectorized feature to be extracted, and the nodes and the line segments are unique, and then the line segments of the line segment set are optimized. Since the application divides the line segments by the nodes and then optimizes, for relatively regular polygon features, the nodes are also the key points of maintaining the structure form of the feature to be extracted. Thus, the edges of the feature to be extracted can be optimized in a targeted manner, the optimized result retains the shape features of the feature, and the problem of easy topological error is effectively solved. Furthermore, the application converts the two-dimensional surface vector of the processing data object into points and line segments, effectively reduces the complexity of the algorithm, and improves the optimization efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0029] Figure 1 is a flowchart of an edge optimization method for dense feature segmentation provided by an embodiment of the application;
[0030] Figure 2 is a schematic diagram of an edge optimization method for dense feature segmentation provided by an embodiment of the application;
[0031] Figure 3 is a schematic diagram of an edge optimization method for dense feature segmentation provided by an embodiment of the application;
[0032] Figure 4 is a schematic diagram of an edge optimization method for dense feature segmentation provided by an embodiment of the application;
[0033] Figure 5 is a schematic diagram of an edge optimization method for dense feature segmentation provided by an embodiment of the application;
[0034] Figure 6 is a schematic diagram of an edge optimization method for dense feature segmentation provided by an embodiment of the application;
[0035] Figure 7 is a schematic diagram of an edge optimization method for dense feature segmentation provided by an embodiment of the application;
[0036] Figure 8 is a schematic diagram of an edge optimization method for dense feature segmentation provided by an embodiment of the application;
[0037] Figure 9is a structural block diagram of an edge optimization device for dense feature segmentation provided by an embodiment of the present application.
[0038] Figure 10 is a structural block diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0039] In order for those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should be within the scope of protection of the present application.
[0040] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not necessarily limit to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0041] The present application will be described below in conjunction with embodiments:
[0042] As an optional implementation, as described above, an edge optimization method for dense feature segmentation includes: Figure 1
[0043] S101, obtaining a segmentation gray image of a to-be-extracted feature;
[0044] In an exemplary embodiment, the to-be-extracted feature can be a cultivated land plot, a single greenhouse, a dense residential area, etc. Among them, cultivated land as a typical dense distribution feature, the present application can select cultivated land plot as the to-be-extracted feature, and extract the cultivated land feature of an area by using an automatic semantic segmentation model, as described above. Exemplarily, a fine-tuned large model SAM can be selected as the automatic extraction model for segmentation, and other remote sensing image automatic extraction or classification algorithms can also be used, and the present application does not make specific limitations. Figure 2
[0045] It should be noted that remote sensing imagery is inherently raster-based. Current computer-aided interpretation methods for remote sensing imagery primarily rely on supervised classification, with machine learning and deep learning technologies playing a significant role. However, these methods merely convert the input raster imagery into an output image containing semantic information, also in raster format, yielding the initial extraction result. Further processing using these methods is required for subsequent utilization.
[0046] Furthermore, the aforementioned edge optimization method for dense feature segmentation may, but is not limited to, also include:
[0047] S201. Identify the groups of pixels with the same pixel value and spatially connected in the segmented grayscale image as objects, and record the pixel value and number of pixels of the objects, as well as the number of pixels and pixel value of each object connected to them.
[0048] S202. Determine whether the number of pixels for each object is less than a preset threshold.
[0049] S203. If the number of pixels is less than the threshold, the pixel value of the object is changed to the pixel value of the object with the most adjacent pixels. It should be noted that if the number of pixels of an object is not less than the preset threshold, it indicates that the object is not a small feature patch, and the feature object should be retained for subsequent optimization processing.
[0050] In this embodiment, considering that the initially obtained grayscale image of the ground features to be extracted may contain some small ground feature patches, in order to reduce the amount of subsequent data processing, this embodiment uses an algorithm to fuse patches with a small number of pixels in the grayscale image.
[0051] Specifically, based on the grayscale values of the segmented grayscale image, the grayscale image is segmented into feature patch objects O. An object can be defined as a set of spatially connected pixel groups with the same pixel value in the segmented grayscale image. A record list C is created for each object. O This records the number of pixels and pixel value for each object, as well as the number of pixels and pixel value for each object adjacent to it. A threshold for the minimum number of pixels in an object is set. This threshold can be set according to actual business needs. For example, if the business requires a map size M of 5 square meters for extracted features and a pixel P (i.e., image unit) size of 0.5 meters, then the threshold T can be set as T = M / (P * P) = 5 / (0.5 * 0.5) = 20. Object O is then determined based on the threshold. min Whether merging is needed depends on whether the number of pixels in each object is less than a preset threshold. If it is less, merging is required, and then the record list C is traversed. O Among the other objects, find the object O with the highest pixel count. max Read the pixel value of the object and assign it to the object's value O.min As described above, Figure 3 As described above, Figure 3 / a is before fusion, Figure 3 / b is after fusion. Through this example, the small spot fusion processing is performed on the initial segmentation gray image, which not only removes part of the noise, but also reduces the calculation amount of the later optimization data processing, thereby improving the processing efficiency.
[0052] S102, raster vectorization is performed on the segmentation gray image to obtain a vector result;
[0053] In order to obtain the information extraction result in vector format, the initial extraction result of the image is generally raster vectorized along the grid boundary, and the adjacent pixels with the same semantics are surrounded to form a planar vector element.
[0054] This embodiment adopts a polygon vectorization method of 4-connection Freeman chain code encoding. This part can also use other vectorization methods for raster vectorization, such as 8-connection Freeman chain code encoding. The present application is not limited in this regard.
[0055] S103, obtaining all vector elements in the vector result, forming an element set, and traversing the element set to obtain element points, and forming an element point set by the de-duplicated element points;
[0056] It should be explained that the element is a block composed of a group of pixels with the same pixel value and spatially connected in the segmentation gray image, that is, a spot. First, define an element set F, obtain all elements in the vector result to form the element set. Then define an element point set P, traverse the element set F, take out the points contained in the element and add them to the element point set P, and record the correspondence between the element and the element points contained therein. However, considering the case that there are common points between different elements, the element point set P needs to be de-duplicated. The specific de-duplication method includes: judging whether the coordinates (x, y) of a point in the element point set P are the same as the coordinates (x, y) of the remaining points, if the same, the point is discarded, otherwise the point is retained, thereby obtaining the de-duplicated element point set.
[0057] S104, according to the preset node judgment rule, traversing the element point set, and forming an element node set by the element points judged as nodes;
[0058] It should be noted that in the present embodiment, the relationship between the element point and different elements needs to be determined. In one case, the point only belongs to a certain element and is not included in or adjacent to any other element. In a second case, the point belongs to a certain element and is also adjacent to other elements. In a third case, the point belongs to two or more elements. Therefore, it is necessary to determine whether the point belongs to a node according to different cases. In the present example, a node can be understood as a part of the element point having at least three adjacent points and the adjacent points being non-repetitive. The points in the element point set P are determined according to a preset node determination rule, and the points meeting the condition are added to the element node set N.
[0059] Further, as shown in Figure 4 The above edge optimization method for dense feature segmentation can but not limited to further include:
[0060] S401, respectively determine whether the point in the element point set only belongs to the first element, the first element being any element in the element set;
[0061] S402, if yes, determine whether the point belongs to the first element and simultaneously has an adjacent relationship with the second element, the second element being any element in the element set except the first element;
[0062] It should be noted that the adjacent relationship can be understood as the point being on the boundary of the second element, but the point only belongs to the first element. In addition, if the point does not meet the condition of belonging to the first element and simultaneously having an adjacent relationship with the second element, step S406 is performed.
[0063] S403, if yes, the point is inserted into the second element to obtain a third element, the third element being different from any element in the element set; if no, that is, the point belongs to the first element and simultaneously does not have an adjacent relationship with the second element, the point is a non-node;
[0064] S404, the number of adjacent points of the point is counted, the number of adjacent points being the number of adjacent points of the point in the first element and the third element after deduplication;
[0065] S405, if the number of adjacent points is greater than or equal to a preset value, the point is a node;
[0066] Wherein, unless special circumstances, the default value of the preset value of the present application is 3. It needs to be further explained that there are many cases of the adjacent points of the general element points. When the preset value is less than 3, it indicates that the point is located on the edge of the element, so there is no need to split the line segment, and the original vector can be maintained. When the preset value is greater than 3, the point that affects the shape feature of the element may be missed, and the optimized vector result may have topological errors, in which case, the automatic and / or manual method needs to be used to correct.
[0067] S406, if the point belongs to at least two elements and there are at least preset value of adjacent points and the adjacent points are not repeated, it is determined that the point is a node.
[0068] If the point does not meet the condition that it belongs to at least two elements and there are at least preset value of adjacent points and the adjacent points are not repeated, it is determined that the point is not a node.
[0069] Further explained, in the first case, the point has only one adjacent point before and after, and belongs to one element, the point is not a node. In the third case, the point has 2 adjacent points in each vector element, i.e. at least 4 adjacent points. The adjacent points are de-duplicated, when the de-duplicated adjacent points are 2, it indicates that the point belongs to the point on the common edge, the point is not a node. When the number of adjacent points is greater than or equal to 3, the point is a node. In the second case, the point is inserted into the adjacent element to form a new element and update the element to the element set, at this time the point belongs to at least two elements, i.e. the third case is formed, similarly, the adjacent points of the point are judged, when the number of de-duplicated adjacent points is greater than or equal to 3, the point is a node. Thus, all the nodes in the vector element are obtained, and the nodes contained in each element are recorded to form an element node set.
[0070] Exemplarily, it is determined according to the preset node determination rule which points in the above element point set belong to the node, and the points determined as the node are added to the element node set N, and finally the element node set N is obtained. The specific implementation process is as follows: the points in the A and B elements are divided into three cases: 1. Belonging to only one element of A or B, and not contained in or adjacent to any other element. 2. Belonging to a certain element, and also having an adjacent relationship with other vectors. 3. Belonging to two or more elements. A4, A5, A6, A7, A8, B2, B3, B4, B5, B6 belong to the first case, the point has only one adjacent point before and after, and belongs to one element. These points are not nodes. A1, A2, A3 (B1, B7, B8) belong to the third case, these points have two adjacent points in each vector element, that is, at least four adjacent points. The adjacent points are de-duplicated, and the de-duplicated adjacent points of A2 (B8) are two, indicating that the point belongs to the point on the common edge and does not belong to the node. The number of adjacent points of A1 (B1), A3 (B7) is greater than or equal to 3, and these points belong to the node. Finally, A1 (B1) and A3 (B7) are determined to belong to the node according to the rule. According to the rule, all nodes of the above cultivated land vector can be obtained, and the element node set N is obtained.
[0071] The second case is shown in FIG. 6B. As shown in FIG. 6B, point A3 belongs to element A but is adjacent to element B. At this time, the point is inserted into the adjacent element B to form a new element B', and the composition of B' is: Figure 6 B': POLYGON ((B1, A3, B2, B3, B4, B1))
[0072] At this time, A3 belongs to two elements A and B', forming the third case. Similarly, the adjacent points of the point are determined, and there are A2, A4, B1, B2. When the de-duplicated adjacent points are three, the point belongs to the node.
[0073] Through the embodiment, the nodes in the element point set can be accurately found out, which are also the key points of the structure form of the to-be-extracted ground object. Then, the corresponding elements are segmented into line segments according to the nodes. Since the optimization operation is performed on the line segments segmented based on the nodes, the optimization processing can be performed on each edge of the to-be-extracted ground object in a targeted manner, so that the shape characteristics of the ground object after optimization are retained, and the problem of serious topological error of the combined elements is also effectively solved.
[0074] S105, based on the nodes in the element node set, respectively segmenting the corresponding vector elements into a plurality of line segments to obtain a line segment set, and recording the corresponding relationship between the line segment and the vector element;
[0075]
[0076] It should be noted that the nodes in the element node set are the intersection points between different elements, that is, the connection relationship between each element can be determined through the nodes. The corresponding elements are divided into multiple line segments through the nodes, which can be understood as based on all the points contained by the elements, wherein the nodes are contained, and the nodes are taken as the start point and end point of the line segment, wherein the start point and end point can contain multiple other points, thereby forming a line segment. According to the order of the nodes, the end point of the preceding line segment is taken as the start point of the next line segment, and the new node is taken as the end point, thereby obtaining the second line segment. In this way, the first line segment is obtained, and the second line segment is obtained in the same way, until all the nodes corresponding to the element are traversed. Similarly, all elements are traversed to perform the corresponding line segment division operation, and finally a line segment set is formed.
[0077] Further, the above edge optimization method for dense feature segmentation can but not limited to further include:
[0078] S501, for any element, determining the corresponding first node from the element node set, the first node being the node corresponding to the currently processed element;
[0079] S502, connecting each first node in sequence with different nodes as start point and end point to form multiple line segments;
[0080] S503, obtaining a line segment set based on the line segments corresponding to all vector elements.
[0081] In this embodiment, line segment division needs to be performed for any element in the element set. Taking an element in the element set as an example for description. Specifically, the nodes contained by the vector element are obtained from the element node set. In order to distinguish the nodes in the currently processed element from the nodes of other elements in the traversal process, the nodes corresponding to the current vector element are taken as first nodes, and the first nodes can be multiple. Each first node is connected in sequence with different nodes as start point and end point to form multiple line segments. It should be noted that for any vector element, the current node is the start point of the line segment. According to the order of the nodes, the first node is selected as the start point of the first line segment, and the next node is selected as the end point of the line segment, thereby determining the first line segment. Then, the node in the first line segment as the end point is taken as the start point of the second line segment, and according to the order of the nodes, the next node is selected as the end point of the second line segment. In this way, all the nodes are selected according to the order of the nodes, that is, the start point of the first line segment is the end point of the last line segment.
[0082] In a specific embodiment, an element contains three nodes N1, N2, and N3, and the element can be scattered into three line segments L1: N1…N2, L2: N2…N3, and L3: N3…N1, wherein the two end points of the line segment can include other points. The line segments contained in each element are recorded to clearly indicate the correspondence between the element and the line segments contained therein.
[0083] Through the embodiment, the line segments obtained by node segmentation can be obtained, and the processing object is converted from the face vector data to the line segments, so that the complexity of the algorithm is reduced, and the processing efficiency is improved.
[0084] S106, the line segments of the line segment set are de-duplicated to obtain a de-duplicated line segment set;
[0085] It should be explained that since the line segment has no direction, the point coordinates contained in the line segment are the same, that is, two line segments are the same line segment. Through the embodiment, the de-duplicated line segment set can be obtained, that is, the line segments in the line segment set are unique, which ensures the accuracy of subsequent simplification processing and reorganization results.
[0086] Further, the above edge optimization method for dense feature segmentation can but not limited to further include:
[0087] S601, each line segment corresponding to the element is traversed, and it is judged whether the element after the traversal order and the vector element before the traversal order exist a line segment containing the same point;
[0088] S602, if yes, the line segment corresponding to the element after the traversal order is deleted, and the corresponding relationship between the line segment containing the same point of the element before the traversal order and the element after the traversal is established;
[0089] It should be noted that if the element after the traversal order and the vector element before the traversal order do not exist a line segment containing the same point, the subsequent steps do not need to be executed.
[0090] S603, a unique line segment identifier is added to each line segment, so as to obtain a de-duplicated line segment set.
[0091] In a specific embodiment, the element A, the element B: that is, the element A is composed of line segments A1A2A3, A3A4A5A6A7A8A1. It is judged whether the line segment set L already exists or not, and if not, it is added to the line segment set L, and the label in the set is L1, L2. The element B is composed of B1B2B3B4B5B6B7 and B7B8B1. Since the line segment does not exist direction, it can be considered that B7B8B1 and A1A2A3 are the same line segment, and L1 already exists in the line segment set L, so B7B8B1 needs to be deleted, and the line segment set L retains B1B2B3B4B5B6B7 and is labeled as L3. In this way, until all the repeated line segments contained by the vector elements are deleted, the de-duplicated line segment set is obtained. And add a unique line segment identifier to each line segment to form the de-duplicated line segment set L: {L1, L2, L3…L n}. At the same time, record the line segments combined by each element, for example, the line segments composed of element A are L1, L2, and the line segments composed of element B are L3, L1. In this way, record the line segments contained by all elements.
[0092] It should be noted that after deleting B7B8B1 belonging to element B, A1A2A3
[0093] corresponding to element B, so as to clearly correspond the elements to the line segments contained by the elements, so as to facilitate subsequent recombination of the optimized line segments based on the elements to obtain the optimized vector result.
[0094] S107, optimizing the de-duplicated line segments to obtain an optimized line segment set;
[0095] It should be noted that the optimization processing is a smoothing processing of the element boundary. Generally speaking, the simpler and closer to the actual ground object boundary of the element boundary indicates that the information extraction result is better, and the mapping is also more beautiful. Therefore, in order to make the to-be-extracted ground object closer to the shape characteristics of the original relatively regular ground object, such as the regular polygon characteristics of the cultivated land, the de-duplicated line segments contained by the element need to be optimized.
[0096] Further, the above edge optimization method for dense ground object segmentation can but not limited to further include:
[0097] S701, according to a preset optimization threshold, optimizing the line segments of the de-duplicated line segment set to obtain an optimized line segment set.
[0098] The line segment simplification algorithm in the application adopts the Ramer-Douglas-Peucker (RDP) algorithm, and this part can also adopt the limit perpendicular distance method or the Visvalingam-Whyatt algorithm, which is not limited in the application.
[0099] Exemplarily, the application simplifies the algorithm using the Ramer-Douglas-Peucker (RDP) algorithm, and specifically, a preset optimization threshold can be set according to the type of the ground object to be extracted, the image pixel resolution, and / or the business requirement. For example, the preset optimization threshold can be set to a size of 2-8 pixels according to the image pixel resolution.
[0100] The present example can make the boundary of the polygon element smooth to a certain extent, and make the boundary of the densely distributed ground object closer to the shape characteristics of the actual relatively regular ground object, thereby improving the utilization rate in production application and reducing the workload of manual post-processing.
[0101] Exemplarily, as shown in Figure 7 , the line segment set L obtained by traversing the above-mentioned cultivated land plot vector is subjected to RDP thinning operation, and the thinning threshold is a preset optimization threshold set according to the type of the ground object to be extracted, the image pixel resolution, and the task requirement. Generally, the thinning threshold can be set to a size of 2-8 pixels according to the experience value. The line segment L' after thinning optimization can be obtained, the number of line segments in L' is the same as that in L, and each line segment in L' corresponds to one line segment in L. In the thinning optimization process, A2(B8), A4, A6, A8, B2, B4, and B6 are deleted because they meet the thinning threshold, and the line segment after thinning optimization is obtained as follows: L1 ’ : A1A3; L2 ’ : A3A5A7A1; L3 ’ : B1B3B5B7.
[0102] S108, based on the correspondence between the line segment and the vector element, each vector element is traversed, and the line segment of the optimized line segment set is recombined to obtain an optimized vector result.
[0103] Further, the above-mentioned edge optimization method for dense ground object segmentation can but not limited to further include:
[0104] S801, based on the correspondence between the line segment and the vector element, the line segment contained in each element of the element set is obtained from the optimized line segment set;
[0105] S802, the order of the line segment is determined according to the node contained in the element;
[0106] S803, when the order of the node is inconsistent with the order of the node in the line segment, the order of the node in the line segment is adjusted according to the order of the node;
[0107] S804, the optimized vector result is obtained by recombining the adjusted line segment.
[0108] In this embodiment, the traversal vector element F is taken out from the optimized line segment set. For example, the element Fn contains three line segments L1:N1...N2, L2:N2...N3, and L3:N3...N1. The line segment order is determined according to the nodes contained in the vector element, and the order of the line segment midpoints is adjusted according to the order of the nodes. For example, the order of the nodes in a certain element is N1, N2, N3, and N4. The contained line segments are L1:N1...N2, L2:N2...N3, L3:N3...N4, and L4:N4...N1. The line segment order in the line segment set can be L1:N1...N2 or L1:N2...N1,..., L4:N4...N1 or L4:N1...N4. If the line segment order is inconsistent with the node order, the order of the line segment midpoints needs to be adjusted. Then, the optimized vector element is recombined.
[0109] The following takes elements A and B as examples to illustrate the element recombination process. The line segments L1 ’ , L2 ’ contained in element A are obtained, and the order of the points does not need to be adjusted, so the optimized element A can be directly combined. The line segment order contained in element B is obtained, and the contained line segments L1 ’ , L3 ’ are taken out from the optimized line segment set. According to the node order, L3 ’ is first taken out to form part of the new element, at which time the order of the points does not need to be adjusted. Then, L1 ’ is taken out, the order of the points of L1 ’ is adjusted to A3(B7)A1(B1) according to the node order, and is added to the new element to form the optimized element B ’ . The above steps are repeated until all elements are processed.
[0110] The present application obtains the element nodes and line segment set of the segmented gray-scale image of the vectorized to-be-extracted ground object, and the nodes and line segments are unique. Then, the line segments of the line segment set are optimized. After the nodes are used to divide the line segments and then the optimization processing is performed, for a relatively regular polygon ground object, the nodes are also the key points of maintaining the structure shape of the to-be-extracted ground object. In this way, the to-be-extracted ground object can be optimized in a targeted manner, the optimized result retains the shape features of the ground object, and the problem of topological errors is effectively solved. Furthermore, the present application converts the two-dimensional surface vector into points and line segments, effectively reduces the complexity of the algorithm, and improves the optimization processing efficiency. In addition, the degree of automation is also improved, and the labor and time costs are effectively saved.
[0111] In another embodiment, the above edge optimization method for dense ground object segmentation can but is not limited to further include:
[0112] The vector result after optimization is subjected to a polygon fusion operation to obtain a final optimization result.
[0113] In actual application, whether the polygon fusion operation is needed is determined according to actual conditions. Specifically, in one case, the areas of the obtained optimization vector polygons are all greater than a set threshold, and the polygon fusion operation is not performed. In another case, new small polygons can be formed after optimization, and for such polygons, whether the fusion polygon processing is performed can be determined according to actual requirements to remove polygons smaller than a set threshold. The specific threshold can be set according to requirements.
[0114] In specific embodiments, a certain cultivated land feature image product of Beijing No. 2 remote sensing image is selected as the data source for automatic extraction, the image pixel resolution is 0.8 m, the wave band is composed of three RGB wave bands, and the storage is 8 bit, as shown in Figure 2 For comparison, manual optimization experiments are performed by using QGIS (an open source GIS software) to perform raster vectorization and vector simplification, and the entire process takes 1.59 s, and the generated vector polygon has topological errors, and a large amount of time is still spent on correction in the later stage. The new cultivated land plot vector generated by using the technical solution of the present application takes 0.23 s in the entire optimization process, the optimization result meets the production requirements, and there is no topological error. The comparison before and after optimization is shown in Figure 8 , wherein 8 / a is the graph before optimization, and 8 / b is the graph after optimization. It can be seen from comparison that the vector boundary after optimization is closer to the original feature shape. It can be seen that the present application can meet the expected effect.
[0115] Based on the same inventive concept, the embodiments of the present application also provide a dense feature segmentation-oriented edge optimization device for implementing the dense feature segmentation-oriented edge optimization method described above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, and therefore the specific limitations in one or more dense feature segmentation-oriented edge optimization device embodiments provided below can refer to the limitations of the dense feature segmentation-oriented edge optimization method described above, and will not be repeated here.
[0116] In one embodiment, as shown in Figure 9 , a dense feature segmentation-oriented edge optimization device 900 is provided, which includes:
[0117] The data acquisition module 901 is configured to acquire a segmented gray image of a feature to be extracted.
[0118] The vectorization module 902 is configured to perform raster vectorization on the segmented gray image to obtain a vector result.
[0119] The element determination module 903 is configured to acquire all vector elements in the vector result, compose an element set, and traverse the element set to acquire element points, and compose an element point set by using the de-duplicated element points.
[0120] The element node determination module 904 is configured to traverse the element point set according to a preset node determination rule, and compose an element node set by using the element points determined as nodes.
[0121] The line segment set determination module 905 is configured to respectively split the corresponding vector elements into a plurality of line segments based on the nodes in the element node set, to obtain a line segment set, and to record a corresponding relationship between the line segments and the vector elements.
[0122] The de-duplication module 906 is configured to perform de-duplication processing on the line segments in the line segment set, to obtain a de-duplicated line segment set.
[0123] The optimization module 907 is configured to perform optimization processing on the de-duplicated line segments, to obtain an optimized line segment set.
[0124] The recombination module 908 is configured to traverse each vector element based on the corresponding relationship between the line segments and the vector elements, to perform recombination on the line segments in the optimized line segment set, and to obtain an optimized vector result.
[0125] In another embodiment, the modules in any of the above apparatuses can be one or more integrated circuits configured to implement the above methods, for example, one or more application specific integrated circuits (ASICs), or one or more digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs), or a combination of at least two of these integrated circuit forms.
[0126] For example, when the modules in the apparatus can be implemented in the form of a processing element scheduler, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor that can invoke programs. For example, these modules can be integrated together in the form of a system-on-a-chip (SOC).
[0127] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the apparatuses and modules described above can refer to the corresponding processes in the foregoing method embodiments, which will not be described here.
[0128] Figure 10 A structural block diagram of an electronic device 300 is provided for embodiments of the present application.
[0129] As shown in Figure 10 The electronic device 300 includes a processor 301 and a memory 302, and can further include one or more of an information input / output (I / O) interface 303, a communication component 304, and a communication bus 305.
[0130] The processor 301 is configured to control overall operations of the electronic device 300 to complete all or part of the steps of the edge optimization method for dense feature segmentation described above. The memory 302 is configured to store various types of data to support operations of the electronic device 300, which can include, for example, instructions for operating any application or method on the electronic device 300, and application-related data. The memory 302 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as one or more of a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic memory, a flash memory, a magnetic disk, or an optical disk.
[0131] The I / O interface 303 provides an interface between the processor 301 and other interface modules, which can be a keyboard, a mouse, a button, and the like. These buttons can be virtual buttons or physical buttons. The communication component 304 is configured to perform wired or wireless communication between the electronic device 300 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, near field communication (NFC), 2G, 3G, or 4G, or a combination of one or more of them, so the corresponding communication component 304 can include a Wi-Fi component, a Bluetooth component, and an NFC component.
[0132] The electronic device 300 can be implemented with one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic elements for performing the edge optimization method for dense feature segmentation given in the above-described embodiments.
[0133] The communication bus 305 can include a path for transmitting information between the above-described components. The communication bus 305 can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, or the like. The communication bus 305 can be divided into an address bus, a data bus, a control bus, and the like.
[0134] The electronic device 300 can include, but is not limited to, a mobile terminal of a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (Personal Digital Assistant), a PAD (Tablet PC), a PMP (Portable Multimedia Player), a car terminal (for example, a car navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like, and can be a server or the like.
[0135] The present application also provides a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the steps of the edge optimization method for dense feature segmentation.
[0136] The computer-readable storage medium can include a U disk, a mobile hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and the like, various media capable of storing program codes.
[0137] The terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus.
[0138] The description above only concerns preferred embodiments of the application and the explanation of the principles of the technology used. The person skilled in the art should understand that the scope of the application involved in the application is not limited to the technical solutions formed by the specific combinations of the technical features described above, and should also cover other technical solutions formed by any combinations of the technical features described above or their equivalent features without departing from the above-mentioned application concept. For example, the technical solutions formed by the mutual replacement of the above-mentioned features and the technical features applied in the application (but not limited to) having similar functions.
Claims
1. An edge optimization method for dense feature segmentation, characterized in that, The method includes: Obtain the segmented grayscale image of the features to be extracted; The segmented grayscale image is rasterized into vectors to obtain a vector result; Obtain all vector elements in the vector result, form an element set, and traverse the element set to obtain element points, then form an element point set by removing duplicate element points. The process involves traversing the set of element points according to a preset node determination rule, forming a set of element nodes from the element points determined to be nodes. This includes: determining whether each point in the set belongs only to a first element, where the first element is any element in the set; if so, determining whether the point belongs to the first element and is also adjacent to a second element, where the second element is any element in the set other than the first element; if so, inserting the point into the second element to obtain a third element, where the third element is different from any element in the set; counting the number of adjacent points of the point, where the number of adjacent points is the number of points adjacent to the point in the first element and the third element after deduplication; if the number of adjacent points is greater than or equal to a preset value, then the point is determined to be a node; if the point belongs to at least two elements and has at least a preset value of adjacent points that are not repeated, then the point is determined to be a node. Based on the nodes in the set of feature nodes, the corresponding vector features are divided into multiple line segments to obtain a set of line segments, and the correspondence between the line segments and the vector features is recorded. The line segments in the set of line segments are deduplicated to obtain a set of deduplicated line segments; The deduplicated line segments are then optimized to obtain an optimized set of line segments; Based on the correspondence between line segments and vector elements, each vector element is traversed, and the line segments of the optimized line segment set are reorganized to obtain the optimized vector result.
2. The method according to claim 1, characterized in that, The method further includes: Groups of pixels with the same pixel value and spatial connectivity in the segmented grayscale image are identified as objects, and the pixel value and number of pixels of the object, as well as the number of pixels and pixel value of each adjacent object, are recorded. Determine whether the number of pixels for each object is less than a preset threshold; If it is less than, then the pixel value of the object is changed to the pixel value of the object with the most connected pixels.
3. The method according to claim 1, characterized in that, The optimization process for the deduplicated line segments to obtain an optimized set of line segments includes: The deduplicated line segments are thinned out according to a preset optimization threshold to obtain an optimized set of line segments.
4. The method according to claim 1, characterized in that, Based on the nodes in the feature node set, the corresponding vector features are divided into multiple line segments to obtain a line segment set, including: For any element, determine its corresponding first node from the set of element nodes, where the first node is the node corresponding to the element being processed. Connect the first nodes sequentially according to their different starting and ending points to form multiple line segments; A set of line segments is obtained based on the line segments corresponding to all vector elements.
5. The method according to claim 4, characterized in that, The process of deduplicating the line segments in the set of line segments to obtain a deduplicated set of line segments includes: Traverse the line segments corresponding to each of the aforementioned elements, and determine whether there are line segments containing the same points between the later-traversed elements and the earlier vector elements. If so, delete the line segments corresponding to the later elements in the traversal order, and establish a correspondence between the line segments containing the same points of the earlier elements in the traversal order and the later elements. Each line segment is assigned a unique segment identifier to obtain a set of deduplicated line segments.
6. The method according to claim 5, characterized in that, Based on the correspondence between the line segments and vector elements, the process iterates through each vector element and reorganizes the line segments of the optimized line segment set to obtain the optimized vector result, including: Based on the correspondence between the line segments and vector elements, for each element in the element set, the line segments contained in the element are obtained from the optimized line segment set. The order of the line segments is determined based on the nodes contained in the element; When the order of nodes is inconsistent with the order of nodes in a line segment, the order of points in the line segment is adjusted according to the order of the nodes. The optimized vector result is obtained by recombining the adjusted line segments.
7. An edge optimization device for dense feature segmentation, characterized in that, The device includes: The data acquisition module is used to acquire the segmented grayscale image of the features to be extracted. The vectorization module is used to perform raster vectorization on the segmented grayscale image to obtain a vector result; The feature determination module is used to obtain all vector features in the vector result, form a feature set, and traverse the feature set to obtain feature points, and form a feature point set by deduplicating the feature points. The element node determination module is used to traverse the element point set according to a preset node determination rule, and form an element node set from the element points determined to be nodes. The step of traversing the element point set according to the preset node determination rule and forming an element node set from the element points determined to be nodes includes: determining whether each point in the element point set belongs only to a first element, where the first element is any element in the element set; if so, determining whether the point belongs to the first element and simultaneously has an adjacency relationship with a second element, where the second element is any element in the element set other than the first element; if so, inserting the point into the second element to obtain a third element, where the third element is different from any element in the element set; counting the number of adjacent points of the point, where the number of adjacent points is the number of adjacent points of the point in the first element and the third element after deduplication; if the number of adjacent points is greater than or equal to a preset value, then the point is determined to be a node; if the point simultaneously belongs to at least two elements and has at least a preset value of adjacent points, and the adjacent points are non-repeating, then the point is determined to be a node. The line segment set determination module is used to divide the corresponding vector features into multiple line segments based on the nodes in the feature node set, obtain the line segment set, and record the correspondence between the line segments and the vector features; The deduplication module is used to deduplicate the line segments in the line segment set to obtain a deduplicated line segment set. The optimization module is used to optimize the deduplicated line segments to obtain an optimized set of line segments; The reorganization module is used to reorganize the line segments of the optimized line segment set based on the correspondence between line segments and vector elements, traversing each vector element to obtain the optimized vector result.
8. An electronic device, characterized in that, Includes a processor, which is coupled to a memory; The processor is configured to execute a computer program stored in the memory, causing the electronic device to perform the method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, It includes a computer program or instructions that, when run on a computer, cause the computer to perform the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Geological profile polyline optimization method and system for finite element analysis
CN114491718A
Target segmentation vector boundary simplification method, electronic equipment and storage medium
CN119540275A