A data processing method and device for a grid-to-vector surface and related equipment
By introducing a preset scanline algorithm and a double-ended queue to optimize boundary tracking, and combining it with a polygon data structure to manage memory, the problem of low efficiency in raster data vectorization in traditional methods is solved, achieving efficient raster-to-vector surface processing and improving processing speed and memory utilization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING SUPERMAP SOFTWARE CO LTD
- Filing Date
- 2026-04-21
- Publication Date
- 2026-07-14
AI Technical Summary
When processing large-scale, high-resolution binary raster data, existing technologies often suffer from performance bottlenecks due to the use of lists or stacks to store temporary boundary points. This leads to memory reallocation and data copying when the boundaries are complex or long, resulting in reduced efficiency in boundary tracing and topology construction.
A pre-defined scan line algorithm is used to identify continuous target pixel segments. Boundary tracking and polyline generation are performed through a boundary tracking optimization mechanism and a double-ended queue. A polygonal data structure is used to optimize memory management. A double-ended queue is introduced as the core data structure for the boundary point sequence to ensure that the time complexity of adding new boundary points is constant. A polygonal data structure is designed to release the polyline and its node resources.
It significantly improves the efficiency of vectorizing raster data, reduces unnecessary calculations, increases processing speed, and optimizes memory usage, especially when dealing with complex surface objects and large-scale data.
Smart Images

Figure CN122390945A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and more specifically, to a data processing method, apparatus, and related equipment for converting raster to vector plane. Background Technology
[0002] With the rapid development of technologies such as remote sensing, sensor networks, and computing power, raster data, such as high-resolution satellite imagery, UAV aerial photographs, and meteorological grid data, are being used more and more widely. However, due to the inherent limitations of raster data's data structure, directly using raster data in many spatial analyses can lead to problems such as low efficiency, insufficient accuracy, or even inability to perform the analysis.
[0003] Vector data offers several advantages over raster data, including a more compact data structure, lower redundancy, improved network and retrieval analysis, higher graphical display quality, higher output accuracy, and easier establishment of topological relationships for advanced spatial analysis. Therefore, vectorizing raster data is a crucial and necessary step in certain application analyses.
[0004] Existing techniques for vectorizing raster data typically employ traditional boundary tracing algorithms. When processing large-scale, high-resolution binary raster data, traditional boundary tracing algorithms often use lists or stacks to store temporary boundary points. When the boundaries are complex or long, adding points at any end of the sequence can trigger memory reallocation and data copying, resulting in an average time complexity of O(n), which becomes a performance bottleneck. This reduces the efficiency of boundary tracing and topology construction, ultimately leading to low efficiency in raster data vectorization. Summary of the Invention
[0005] In view of this, this application discloses a data processing method, apparatus and related equipment for raster to vector plane conversion, which aims to improve the efficiency of raster data vectorization.
[0006] To achieve the above objectives, the disclosed technical solution is as follows:
[0007] The first aspect of this application discloses a data processing method for converting raster data to vector surfaces, the method comprising:
[0008] Acquire target raster data;
[0009] Identify consecutive target pixel segments within each row of the target raster data;
[0010] By using a preset scan line algorithm, continuous target pixel segments in each row of the target raster data are identified to construct connected components.
[0011] In the process of constructing connected components, boundary tracking optimization mechanism and double-ended queue are used to perform boundary tracking and polyline generation to obtain a set of vector polylines; wherein, the boundary tracking optimization mechanism is an optimization mechanism with constant time complexity for adding new boundary points at the head or tail of the double-ended queue.
[0012] Based on the vector polyline set, a topologically complete vector surface object is constructed and written out using a pre-constructed polygon data structure via I / O.
[0013] Release the resources occupied by the polyline and its nodes when performing I / O write operations on the vector surface object.
[0014] A second aspect of this application discloses a data processing apparatus for converting raster to vector plane, the apparatus comprising:
[0015] The acquisition unit is used to acquire target raster data;
[0016] The recognition unit is used to identify consecutive target pixel segments in each row of the target raster data.
[0017] The identification building unit is used to identify consecutive target pixel segments in each row of the target raster data to construct connected components using a preset scan line algorithm;
[0018] The boundary tracking unit is used to perform boundary tracking and polyline generation during the construction of connected components through a boundary tracking optimization mechanism and a double-ended queue to obtain a set of vector polylines; wherein, the boundary tracking optimization mechanism is an optimization mechanism with a constant time complexity for adding new boundary points at the head or tail of the double-ended queue.
[0019] A construction processing unit is used to construct a topologically complete vector surface object based on the vector polyline set and perform I / O write operations through a pre-constructed polygon data structure;
[0020] The release unit is used to release the resources occupied by the polyline and its nodes when performing I / O write operations on the vector surface object.
[0021] A third aspect of this application discloses a storage medium comprising stored instructions, wherein, when the instructions are executed, the device in which the storage medium is located is controlled to perform a raster-to-vector plane data processing method as described in any one of the first aspects.
[0022] The fourth aspect of this application discloses an electronic device, including a memory and one or more instructions, wherein one or more instructions are stored in the memory and configured to be executed by one or more processors using the raster-to-vector plane data processing method as described in any one of the first aspects.
[0023] As can be seen from the above technical solution, this application discloses a data processing method, apparatus, and related equipment for raster-to-vector surface conversion. The method involves acquiring target raster data, identifying continuous target pixel segments in each row of the target raster data using a preset scan line algorithm to construct a connected component, and performing boundary tracking and polyline generation through a boundary tracking optimization mechanism and a dequeue to obtain a vector polyline set. The boundary tracking optimization mechanism is an optimization mechanism where the time complexity of adding new boundary points at the beginning or end of the dequeue is a constant. A topologically complete vector surface object is constructed based on the vector polyline set, and I / O write operations are performed using a pre-constructed polygon data structure. During I / O write operations on the vector surface object, the resources occupied by the polylines and their nodes are released. This solution introduces a dequeue as the core data structure for the boundary point sequence, ensuring that the time complexity of adding new boundary points at the beginning or end of the sequence remains constant O(1) regardless of the direction of movement during boundary tracking, fundamentally eliminating the performance loss associated with using lists or stacks during dynamic growth. Furthermore, this scheme designs a polygonal data structure. Once a polyline is closed, it is immediately migrated from an unclosed linked list to a closed linked list, thereby releasing the resources occupied by the polyline and its nodes. This ensures that all subsequent merging and traversal operations only occur on the unclosed linked list whose size is continuously decreasing, greatly reducing unnecessary calculations and thus improving the efficiency of raster data vectorization. Attached Figure Description
[0024] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0025] Figure 1 This is a schematic flowchart of a data processing method for converting a raster to a vector surface, as disclosed in an embodiment of this application.
[0026] Figure 2 This is a schematic diagram of the connected domains disclosed in the embodiments of this application;
[0027] Figure 3 This is a schematic diagram of raster vectorization disclosed in an embodiment of this application;
[0028] Figure 4 This is a schematic diagram of the structure of a data processing device for converting a raster to a vector surface, as disclosed in an embodiment of this application.
[0029] Figure 5 This is a schematic diagram of the structure of the electronic device disclosed in the embodiments of this application. Detailed Implementation
[0030] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0031] In this application, the terms "comprising," "including," 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 includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0032] As the background technology shows, when processing large-scale, high-resolution binary raster data, traditional boundary tracking algorithms usually use lists or stacks to store temporary boundary points. When the boundary is complex or there are long boundaries, the operation of adding points at any end of the sequence may cause memory reallocation and data copying, with an average time complexity of O(n), which becomes a performance bottleneck. This reduces the efficiency of boundary tracking and topology construction, and ultimately leads to low efficiency in vectorizing raster data.
[0033] To address the aforementioned issues, this application discloses a data processing method, apparatus, and related equipment for converting raster data to vector surfaces. This solution introduces a double-ended queue as the core data structure for the boundary point sequence. This ensures that during boundary tracing, regardless of the direction of travel, the time complexity of adding new boundary points at the beginning or end of the sequence remains constant at O(1), fundamentally eliminating the performance overhead of using lists or stacks during dynamic growth. Furthermore, this solution designs a polygonal data structure. Once a polyline closes, it is immediately migrated from an unclosed linked list to a closed linked list, thereby releasing the resources occupied by the polyline and its nodes. This ensures that all subsequent merging and traversal operations occur only on the continuously decreasing size of the unclosed linked list, significantly reducing redundant computation and thus improving the efficiency of raster data vectorization. The specific implementation is illustrated in the following embodiments.
[0034] It should be noted that the data processing method, apparatus and related equipment for raster-to-vector conversion provided in this application relate to the technical fields of data processing and raster-to-vector conversion. The above is only an example and does not limit the application field of the data processing method, apparatus and related equipment for raster-to-vector conversion provided in this application.
[0035] refer to Figure 1 The image shows a data processing method for converting a raster to a vector surface according to an embodiment of this application. This method mainly includes the following steps:
[0036] S101: Acquire target raster data.
[0037] Target raster data is a data format that divides space into a regular grid and assigns attribute values to represent entities. The data structure of target raster data uses a continuous set of cells with the same attribute values to represent geographic features, and the geographic location of a feature is defined by its raster row and column number.
[0038] The specific process of acquiring the target raster data is shown in A1-A2.
[0039] A1: Obtain the raster data to be processed, and extract the classification values from the raster data to obtain the target classification value and the background classification value.
[0040] Here, "raster data to be processed" refers to raster data that has not undergone preprocessing. Preprocessing involves extracting classification values and labeling the raster data to be processed.
[0041] A2: The raster data to be processed is labeled using the target classification value and the background classification value to obtain the target raster data.
[0042] The input raster data is processed by extracting classification values, marking the pixels of interest as target pixels and the remaining pixels as background pixels; each value of the target pixel represents a category. For binary raster data, the pixels of interest are marked as target pixels (e.g., 1), and the remaining pixels are marked as background pixels (e.g., 0).
[0043] For example, to extract the boundaries of water bodies and the scope of construction land, the corresponding feature pixels are set as target pixels, and the remaining features are set as background pixels.
[0044] S102: Using a preset scan line algorithm, identify consecutive target pixel segments in each row of the target raster data to construct connected components.
[0045] In S102, an improved preset scan line algorithm is used to scan the preprocessed target raster data line by line. Specifically, the preprocessed target raster data is scanned line by line in a top-to-bottom and left-to-right order.
[0046] The line-by-line scanning order can be from top to bottom, from bottom to top, from left to right, etc. The line-by-line scanning order in this application is designed according to the actual situation, and this application does not make any specific limitation.
[0047] While marking connected components, the target raster data is scanned row by row to identify the start and end points of the boundaries (such as the start column number, end column number, row number, etc.), and a linked list of all target pixel segments (scan segments) arranged by row is obtained.
[0048] Specifically, the process of identifying consecutive target pixel segments in each row of the target raster data to construct connected components using a preset scan line algorithm is shown in B1-B4.
[0049] B1: For each row of consecutive target pixel segments, count the starting and ending column numbers of the consecutive target pixel segments in the current row.
[0050] B2: Compare the starting and ending column numbers of consecutive target pixel segments in the current row with the starting and ending column numbers of consecutive target pixel segments in the previous row, until the comparison of consecutive target pixel segments in each row is completed, and obtain the comparison result.
[0051] In B2, the scan segment of the current row (i.e., the start and end column numbers of the consecutive target pixel segments in the current row) is compared with the scan segment of the previous row (the start and end column numbers of the consecutive target pixel segments in the previous row) to obtain the comparison result.
[0052] B3: Obtain the column numbers that have overlapping relationships and / or adjacent relationships from the comparison results.
[0053] The column numbers that have an overlapping relationship are the starting and ending column numbers of the consecutive target pixel segments in the current row, which overlap or connect with the starting and ending column numbers of the consecutive target pixel segments in the previous row.
[0054] If the comparison results indicate that the column numbers overlap or are adjacent, they are determined to belong to the same connected component, and dynamic merging and labeling are performed, assigning them a unique connected component number. To facilitate understanding of the specific process, we will combine... Figure 2 To explain, Figure 2 This is a schematic diagram of a connected region.
[0055] Figure 2In the image, the first row of scan segments (row 1, column 3), the second row of scan segments (row 2, column 2-3), and the third row of scan segments (row 3, column 2-3) overlap in columns and are merged into the same connected component. Although the left-hand scan segment of the fourth row (row 4, column 1-2) and the third row of scan segments (row 3, column 2-3) do not directly overlap in columns, they are merged because they are adjacent. Through row-by-row association, these vertically associated pixel segments with a raster value of "1" are ultimately merged into a single connected component.
[0056] B4: Construct connected components based on column numbers that have overlapping relationships and / or column numbers that are adjacent.
[0057] Figure 2 First, during the construction of connected components, the adjacency points between the target pixel (1) and the background pixel (0) in each row are identified and recorded in real time. These adjacency points constitute the initial, tiny boundary arc segments (i.e., Figure 2 (The red line segment in the image); each boundary arc segment has its starting point, direction (ensuring the target is on the right), and the connected component number it belongs to; it should be noted that the arc segment is the target pixel ( Figure 2 The median value of 1 is the adjacent boundary line between the target pixel and the background pixel (value of 0 in the image). For example, when scanning the grid line by line, for each target pixel, it is determined whether its 4 neighbors (top / bottom / left / right) are background pixels. If one side is the background, then this side of the pixel is an initial, tiny boundary arc segment.
[0058] The first target pixel found by scanning the target raster data in a "top-down, left-to-right" order is the starting point.
[0059] Then, the obtained boundary arc segment is initialized to put all points in the boundary arc segment into a double-ended queue.
[0060] Finally, the system tracks the grid pixels according to their scanning direction, searching for other connected arcs. When a connectable arc is found (i.e., the coordinates match after initialization), it is dynamically added to the head or tail of the queue based on the current tracking direction. This process is repeated until both ends of the current polyline encounter closure points, ultimately outputting a complete set of vector polylines.
[0061] S103: In the process of constructing connected components, boundary tracking and polyline generation are performed through a boundary tracking optimization mechanism and a double-ended queue to obtain a set of vector polylines; among them, the boundary tracking optimization mechanism is an optimization mechanism with a constant time complexity for adding new boundary points at the beginning or end of the double-ended queue (boundary point sequence).
[0062] This scheme introduces a double-ended queue as the core data structure for the boundary point sequence (similar to a deque). This ensures that during boundary tracking, regardless of the direction of travel, the time complexity of adding a new boundary point at the beginning or end of the sequence remains constant at O(1), fundamentally eliminating the performance overhead of using lists or stacks during dynamic growth.
[0063] Specifically, in the process of constructing connected components, the boundary tracking optimization mechanism and double-ended queue are used to perform boundary tracking and polyline generation to obtain a set of vector polylines, as shown in C1-C4.
[0064] C1: During the construction of connected components, the adjacency of the target pixel and the background pixel in each row is obtained in real time, and the initial boundary arc is constructed based on the adjacency.
[0065] C2: Store all points in the initial boundary arc into a pre-built double-ended queue.
[0066] For example, following the scanning rule of "from top to bottom and from left to right", the first target pixel found is 1 in the first row, third column, and first row, with a pixel range of x∈[2,3] and y∈[0,1]. Its upper boundary (from point (2,0) to point (3,0)) is the adjacent edge between the target pixel and the background pixel, i.e., the initial arc segment. The two endpoints of the initial arc segment are stored in a deque according to the initial tracking direction (positive right): Deque=[(2,0), (3,0)].
[0067] C3: Track the double-ended queue according to the scanning direction of the raster pixels to obtain other arc segments connected to the boundary arc segment.
[0068] C4: Add other arcs to the head or tail of the double-ended queue, and return the step of obtaining the adjacency of the target pixel and the background pixel in each row in real time, and constructing the boundary arc based on the adjacency, until the two ends of the polyline formed by all the boundary arcs in the connected domain have closure points, and obtain the vector polyline set.
[0069] S104: Construct a topologically complete vector polygon object from the vector polyline set and perform I / O write operations through a pre-constructed polygon data structure.
[0070] In S104, the coordinate sequence of the vector polyline set in the double-ended queue is converted into geographic coordinates. Based on the geographic coordinates, a topologically complete vector polygon object is constructed and I / O write-out operations are performed through a pre-constructed polygon data structure.
[0071] In this context, the set of vector polylines is the set of polylines within the connected region. Generally, polyline sets within a connected region are managed using singly linked lists. While this is convenient and efficient for merging polylines in the early stages when dealing with data containing numerous islands, holes, and sub-objects, closed lines still require continuous traversal during later checks for closure, and the traversal overhead of a singly linked list is too high. Therefore, this scheme defines two core linked lists, and the core members of the polygon data structure used are shown in Table 1.
[0072] Table 1
[0073] member illustrate Incomplete closed polyline linked list It can still process the merging of lines at high speed. Completed closed polyline linked list It no longer participates in the segment merging process, and no longer repeatedly checks whether the line is closed. The final result is directly constructed from this set of already closed polylines.
[0074] It's important to note that the default scanline algorithm only iterates through incomplete closure linked lists. This algorithm fully leverages the characteristics of linked lists; when two polylines are connected end-to-end, merging them is achieved simply by moving a node from one object to the other, eliminating the need to copy the polyline object and significantly improving efficiency. During the merging process, once a closed polyline is found, it is immediately moved to the completed linked list, and only the linked list node is moved, without copying coordinate data. Furthermore, because closed polylines are immediately moved into the completed linked list, redundant checks for closure are eliminated during the merging process.
[0075] This solution provides an efficient management strategy for complex polygon objects. Specifically, it designs a polygon data structure that maintains two independent linked lists: one for managing unclosed polylines still being processed, and the other for storing closed polylines. Once a polyline is closed, it is immediately moved from the "unclosed" linked list to the "closed" linked list. This ensures that all subsequent merging and traversal operations occur only on the continuously decreasing "unclosed" linked list, significantly reducing unnecessary computation.
[0076] When a polyline closure is detected, the coordinate sequence in the dequeue is converted into geographic coordinates, a topologically complete vector polygon object is constructed, and an I / O write operation is performed. The result of the I / O write operation is as follows: Figure 3 As shown.
[0077] S105: Releases the resources occupied by polylines and their nodes when performing I / O write operations on vector surface objects.
[0078] When a vector polygon object completes its I / O write operation, the resources occupied by the polyline and its nodes are immediately released. This mechanism optimizes memory usage and ensures efficient memory utilization, effectively preventing memory overflow issues, especially when processing large-scale raster data.
[0079] Moving the closed polyline to the completed linked list and moving only the linked list nodes when merging two polyline objects avoids data copying operations during the merging process, further reducing memory usage and ensuring that system memory usage remains in a stable and low range during computation.
[0080] This solution, through innovative algorithm optimization, achieves high-performance processing of raster-to-vector surface conversion while maintaining the accuracy of vector surface topology. It provides an efficient solution for large-scale geospatial data processing, resolving the performance bottlenecks of traditional methods when surface objects cover a large number of raster cells or complex surface objects have numerous holes. Its performance advantage is most pronounced in binary raster data processing, and the algorithm is also applicable to the conversion of multi-value raster data, ensuring good performance across various raster data processing methods. The performance improvement results obtained from experiments are shown in Table 2.
[0081] Table 2
[0082] Data types Number of rows and columns Number of objects in the result Optimized time (N) Time consumed before optimization (O) Performance improvement (ON) / O*100% Land use types 18962*22012 2,694,953 702 seconds 1542 seconds 54.47% Digital Elevation Model (DEM) 3693*8228 8,580,311 343 seconds 435 seconds 21.15% DEM reclassification results 14400*14400 5,134 5.3 seconds 8 seconds 33.75%
[0083] The advantages of this solution are as follows:
[0084] 1. Significantly improved performance: Compared with traditional methods, as shown in the test data, the speed is improved by 30%-50% when processing binary raster data. The performance improvement is more obvious when processing complex face objects containing a large number of islands and holes. It is suitable for processing various raster data scenarios. The single row traversal mechanism avoids the overhead of multiple scans.
[0085] 2. High resource utilization: The optimized management mechanism significantly reduces memory usage and data processing overhead, especially when dealing with complex faceted objects.
[0086] This solution provides fine-grained memory management. Specifically, it optimizes memory management strategies in two ways: first, when merging polylines, only the linked list node pointers are moved, rather than copying the underlying coordinate data; second, after a polyline is closed and moved into the closed linked list, the generation and output of the vector surface object are triggered immediately, and the memory resources occupied by the polyline are released immediately, ensuring that memory usage remains at a stable low level throughout the entire processing.
[0087] This solution is most effective when processing binary raster data, but it is also applicable to multi-value raster data.
[0088] This solution employs a collaborative mechanism of "bidirectional scalable tracing, dynamic linked list partitioning, and real-time resource reclamation." First, it preprocesses and analyzes the connected components of the input raster data. Then, it generates initial boundary arcs using an improved boundary tracing algorithm, followed by polyline merging and polygon data structure construction. Finally, it outputs the final I / O results through refined memory management. This achieves a significant performance improvement in raster-to-vector polygon conversion. The core theme of this solution is the conversion of raster data to vector polygon data. Its primary technical challenge is how to significantly improve the efficiency of boundary tracing and topology construction while optimizing memory usage when processing large-scale raster data. By optimizing data structures and memory management, conversion efficiency is improved, especially for processing complex polygon objects (such as areas containing numerous islands and holes) and large-scale data scenarios. Addressing the slow conversion speed and high memory consumption of traditional methods, this solution can quickly and accurately generate polygon boundaries, facilitating subsequent spatial analysis.
[0089] In this embodiment, the proposed solution introduces a double-ended queue as the core data structure for the boundary point sequence. This ensures that during boundary tracing, regardless of the direction of travel, the time complexity of adding new boundary points at the beginning or end of the sequence remains constant at O(1), fundamentally eliminating the performance overhead of using lists or stacks during dynamic growth. Furthermore, the proposed solution employs a polygonal data structure. Once a polyline closes, it is immediately migrated from an unclosed linked list to a closed linked list, thereby releasing the resources occupied by the polyline and its nodes. This ensures that all subsequent merging and traversal operations occur only on the continuously decreasing unclosed linked list, significantly reducing redundant computation and improving the efficiency of raster data vectorization.
[0090] Based on the above embodiments Figure 1 The present application discloses a data processing method for converting raster to vector plane, and also discloses a corresponding data processing apparatus for converting raster to vector plane. Figure 4 As shown, the data processing device for converting a raster to a vector plane includes:
[0091] Acquisition unit 401 is used to acquire target raster data;
[0092] The identification building unit 402 is used to identify consecutive target pixel segments in each row of the target raster data to construct connected components by using a preset scan line algorithm;
[0093] Boundary tracking unit 403 is used to perform boundary tracking and polyline generation through a boundary tracking optimization mechanism and a double-ended queue during the construction of connected components, and obtain a set of vector polylines; wherein, the boundary tracking optimization mechanism is an optimization mechanism with a constant time complexity for adding new boundary points at the head or tail of the double-ended queue.
[0094] The construction processing unit 404 is used to construct a topologically complete vector surface object based on the vector polyline set and perform I / O write operations through a pre-constructed polygon data structure;
[0095] Release unit 405 is used to release the resources occupied by polylines and their nodes when performing I / O write operations on vector surface objects.
[0096] Furthermore, the acquisition unit 401 includes:
[0097] The first acquisition module is used to acquire the raster data to be processed and extract the classification values from the raster data to be processed to obtain the target classification value and the background classification value.
[0098] The labeling module is used to label the raster data to be processed using the target classification value and the background classification value, so as to obtain the target raster data.
[0099] Furthermore, the identification building unit 402 includes:
[0100] The statistics module is used to count the start and end column numbers of consecutive target pixel segments in the current row for each row.
[0101] The comparison module is used to compare the start and end column numbers of consecutive target pixel segments in the current row with the start and end column numbers of consecutive target pixel segments in the previous row, until the comparison of consecutive target pixel segments in each row is completed, and the comparison result is obtained.
[0102] The second acquisition module is used to acquire column numbers with overlapping relationships and / or column numbers with adjacent relationships from the comparison results;
[0103] The first building module is used to construct connected components based on column numbers that have overlapping relationships and / or column numbers that have adjoining relationships.
[0104] Furthermore, the boundary tracking unit 403 includes:
[0105] The first building module is obtained, which is used to obtain the adjacency of the target pixel and the background pixel in each row in real time during the construction of the connected component, and to construct the initial boundary arc based on the adjacency.
[0106] The storage module is used to store all points in the initial boundary arc into a pre-built double-ended queue;
[0107] The tracking module is used to track the double-ended queue according to the scanning direction of the grid pixels to obtain other arc segments connected to the boundary arc segment;
[0108] The addition module is used to add other arc segments to the head or tail of the double-ended queue and return the adjacency of the target pixel and background pixel in each row in real time. The step of constructing the boundary arc segment based on the adjacency is repeated until the two ends of the polyline formed by all the boundary arc segments in the connected domain have closure points, thus obtaining a set of vector polylines.
[0109] Furthermore, the processing unit 404 is constructed, including:
[0110] The conversion module is used to convert the coordinate sequence of the vector polyline set in the double-ended queue into geographic coordinates;
[0111] The second construction module is used to construct topologically complete vector polygon objects based on geographic coordinates and perform I / O write operations through a pre-constructed polygon data structure.
[0112] In this embodiment, a double-ended queue is introduced as the core data structure for the boundary point sequence. This ensures that during boundary tracing, regardless of the direction of travel, the time complexity of adding new boundary points at the beginning or end of the sequence remains constant at O(1), fundamentally eliminating the performance overhead of using lists or stacks during dynamic growth. Furthermore, this scheme designs a polygonal data structure. Once a polyline is closed, it is immediately migrated from an unclosed linked list to a closed linked list, thereby releasing the resources occupied by the polyline and its nodes. This ensures that all subsequent merging and traversal operations occur only on the continuously decreasing unclosed linked list, significantly reducing redundant computation and improving the efficiency of raster data vectorization.
[0113] This application embodiment also provides a storage medium, the storage medium including stored instructions, wherein, when the instructions are executed, the device where the storage medium is located is controlled to perform the data processing method such as the above-described raster-to-vector plane conversion.
[0114] This application also provides an electronic device, the structural schematic diagram of which is shown below. Figure 5 As shown, it specifically includes a memory 501 and one or more instructions 502, wherein one or more instructions 502 are stored in the memory 501 and configured to be executed by one or more processors 503 to perform the above-mentioned raster-to-vector surface data processing method.
[0115] For the foregoing method embodiments, in order to simplify the description, they are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, because according to this application, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0116] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For apparatus embodiments, since they are basically similar to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0117] The steps in the methods of the various embodiments of this application can be adjusted, combined, or deleted according to actual needs.
[0118] Finally, it should be noted that in this paper, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations.
[0119] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
[0120] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A data processing method for converting raster data to vector surfaces, characterized in that, The method includes: Acquire target raster data; By using a preset scan line algorithm, continuous target pixel segments in each row of the target raster data are identified to construct connected components. In the process of constructing connected components, boundary tracking optimization mechanism and double-ended queue are used to perform boundary tracking and polyline generation to obtain a set of vector polylines; wherein, the boundary tracking optimization mechanism is an optimization mechanism with constant time complexity for adding new boundary points at the head or tail of the double-ended queue. Based on the vector polyline set, a topologically complete vector surface object is constructed and written out using a pre-constructed polygon data structure via I / O. Release the resources occupied by the polyline and its nodes when performing I / O write operations on the vector surface object.
2. The method according to claim 1, characterized in that, The acquisition of target raster data includes: Obtain the raster data to be processed, and extract the classification values from the raster data to obtain the target classification value and the background classification value; The target raster data is obtained by labeling the raster data to be processed using the target classification value and the background classification value.
3. The method according to claim 1, characterized in that, The step of identifying consecutive target pixel segments in each row of the target raster data to construct connected components using a preset scan line algorithm includes: For each consecutive target pixel segment in a row, count the starting and ending column numbers of the consecutive target pixel segments in the current row; The start and end column numbers of the consecutive target pixel segments in the current row are compared with the start and end column numbers of the consecutive target pixel segments in the previous row, until the comparison of consecutive target pixel segments in each row is completed, and the comparison result is obtained. Obtain the column numbers that have overlapping relationships and / or adjacent relationships from the comparison results; Construct connected components based on the column numbers that have overlapping relationships and / or the column numbers that have adjoining relationships.
4. The method according to claim 1, characterized in that, In the process of constructing connected components, boundary tracking and polyline generation are performed through a boundary tracking optimization mechanism and a double-ended queue, resulting in a set of vector polylines, including: During the construction of connected components, the adjacency points between the target pixel and the background pixel in each row are obtained in real time, and the initial boundary arc segment is constructed based on the adjacency points. Store all points in the initial boundary arc segment into a pre-constructed double-ended queue; The double-ended queue is tracked according to the grid pixel scanning direction to obtain other arc segments connected to the boundary arc segment; The other arc segments are added to the head or tail of the double-ended queue, and the process of obtaining the adjacency of the target pixel and the background pixel in each row in real time and constructing the boundary arc segments based on the adjacency is repeated until the two ends of the polyline formed by all the boundary arc segments in the connected domain have closure points, thus obtaining a set of vector polylines.
5. The method according to claim 1, characterized in that, The step of constructing a topologically complete vector polygon object based on the vector polyline set and performing I / O write operations through a pre-constructed polygon data structure includes: Convert the coordinate sequence of the vector polyline set in the double-ended queue into geographic coordinates; Based on the geographic coordinates, a topologically complete vector polygon object is constructed and written out using a pre-constructed polygon data structure via I / O.
6. A data processing device for converting raster to vector surface, characterized in that, The device includes: The acquisition unit is used to acquire target raster data; The identification building unit is used to identify consecutive target pixel segments in each row of the target raster data to construct connected components using a preset scan line algorithm; The boundary tracking unit is used to perform boundary tracking and polyline generation during the construction of connected components through a boundary tracking optimization mechanism and a double-ended queue to obtain a set of vector polylines; wherein, the boundary tracking optimization mechanism is an optimization mechanism with a constant time complexity for adding new boundary points at the head or tail of the double-ended queue. A construction processing unit is used to construct a topologically complete vector surface object based on the vector polyline set and perform I / O write operations through a pre-constructed polygon data structure; The release unit is used to release the resources occupied by the polyline and its nodes when performing I / O write operations on the vector surface object.
7. The apparatus according to claim 6, characterized in that, The acquisition unit includes: The first acquisition module is used to acquire raster data to be processed and extract classification values from the raster data to be processed to obtain target classification values and background classification values. The labeling module is used to label the raster data to be processed using the target classification value and the background classification value, so as to obtain the target raster data.
8. The apparatus according to claim 6, characterized in that, The identification construction unit includes: The statistics module is used to count the start and end column numbers of consecutive target pixel segments in the current row for each row. The comparison module is used to compare the start and end column numbers of consecutive target pixel segments in the current row with the start and end column numbers of consecutive target pixel segments in the previous row, until the comparison of consecutive target pixel segments in each row is completed, and the comparison result is obtained. The second acquisition module is used to acquire column numbers with overlapping relationships and / or column numbers with adjacent relationships from the comparison results; The first construction module is used to construct a connected component based on the column numbers that have overlapping relationships and / or the column numbers that have adjoining relationships.
9. A storage medium, characterized in that, The storage medium includes stored instructions, wherein, when the instructions are executed, the device containing the storage medium is controlled to perform the data processing method for raster-to-vector conversion as described in any one of claims 1 to 5.
10. An electronic device, characterized in that, It includes a memory, and one or more instructions, wherein one or more instructions are stored in the memory and configured to be executed by one or more processors as described in any one of claims 1 to 5, the raster-to-vector surface data processing method.