Channel extraction method and device, electronic equipment and storage medium
By constructing an undirected graph and dividing it into undirected subgraphs, performing density clustering and rasterization, the adaptability and efficiency problems of channel extraction in existing technologies are solved, and global continuous channel centerline extraction is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- PEKING UNIV SHENZHEN GRADUATE SCHOOL
- Filing Date
- 2026-03-13
- Publication Date
- 2026-06-05
AI Technical Summary
Existing technologies for channel extraction in complex sea areas suffer from insufficient adaptability, computational efficiency, and result continuity, making it difficult to accurately and efficiently extract channels in a wide range of global sea areas.
An undirected graph is constructed using the track segment as the node and the distance between track segments as the edge weight. This graph is then divided into multiple unconnected undirected subgraphs, and density clustering is performed to obtain track clusters. The centerline of the channel is extracted through rasterization and binary raster graph.
It achieves global continuous and topologically complete channel centerline extraction, improves computational efficiency and result stability, avoids channel breakage or misalignment problems, and is suitable for channel extraction in complex sea areas.
Smart Images

Figure CN121834381B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a method, apparatus, electronic device and storage medium for waterway extraction. Background Technology
[0002] With the continued growth of global maritime trade and the widespread application of Automatic Identification Systems (AIS), automatically extracting waterways from massive AIS trajectory data has become a crucial foundation for intelligent maritime traffic management, navigation safety early warning, and marine spatial planning. As the main channels for ship navigation, the accurate and efficient identification of waterways not only helps optimize maritime traffic flow organization and improve navigation efficiency, but also provides key support for chart updates, route planning, and accident risk assessment. Therefore, developing high-precision and robust automatic waterway extraction methods is of great significance.
[0003] Currently, waterway extraction mainly relies on manual mapping, grid-based methods, and clustering techniques based on key feature points of navigation tracks. While manual mapping offers high accuracy, it is time-consuming and labor-intensive, making it difficult to adapt to the needs of large-scale, dynamically changing sea areas. Grid-based methods divide the sea area into regular units to statistically analyze ship traffic frequency, but they perform poorly in complex coastal waters with dense traffic and variable course, and are sensitive to abnormal trajectories, making it difficult to obtain robust results. Spatial clustering methods based on key feature points of navigation tracks (such as stopping points and waypoints) can capture local navigation patterns, but they struggle to effectively identify main channels in areas with highly diverse ship behaviors. If a strategy of partitioning and then stitching together is adopted, it can easily lead to channel breaks, deviations, or misjudgments at regional boundaries. Furthermore, when dealing with massive amounts of AIS data, existing clustering algorithms generally suffer from low computational efficiency and parameter sensitivity, severely restricting their widespread application on a global scale.
[0004] In conclusion, how to accurately and efficiently extract shipping routes across a large global sea area has become an urgent technical problem to be solved. Summary of the Invention
[0005] This application provides a method, apparatus, electronic device, and storage medium for channel extraction, which addresses the shortcomings of existing channel extraction methods in terms of adaptability to complex sea areas, computational efficiency, result continuity, and robustness.
[0006] This application provides a method for waterway extraction, comprising the following steps:
[0007] An undirected graph is constructed using the track segments as nodes and the distance between the track segments as the edge weights. The track segments are the trajectories of the ship's navigation.
[0008] The undirected graph is divided into multiple unconnected undirected subgraphs;
[0009] For any of the undirected subgraphs, density clustering is performed to obtain multiple track clusters within the undirected subgraph, and the track clusters represent a group of spatially similar ship trajectories;
[0010] Each of the aforementioned track clusters is rasterized to obtain a binary raster image, wherein the two values in the binary raster image represent the track coverage area and the background area, respectively;
[0011] The channel centerline is extracted from the binary raster image.
[0012] According to the channel extraction method provided in this application, before performing density clustering for any of the undirected subgraphs to obtain multiple channel clusters within the undirected subgraph, the method further includes:
[0013] If the number of neighbors of any node is k i If the number of samples is less than the preset minimum number k, then virtual adjacency edges are added between the node and other nodes based on the following steps:
[0014] Determine a set of candidate nodes, wherein the candidate nodes in the set are nodes that are not adjacent to the node;
[0015] Randomly select kk from the candidate node set. i A number of candidate nodes are used as virtual adjacent nodes of the node, and a preset distance constant is used as the weight of the edge between the node and the virtual adjacent node.
[0016] According to a channel extraction method provided in this application, the step of performing density clustering for any undirected subgraph to obtain multiple channel clusters within the undirected subgraph includes:
[0017] For any node in the undirected subgraph, calculate the core distance of the node, which is the distance from the node to its k-th nearest neighbor.
[0018] The maximum value between the adjacency distance and the core distance is taken as the reachable distance between the node and its neighboring nodes, where the adjacency distance is the distance between the node and its neighboring nodes.
[0019] Based on the reachability distances between the nodes, a reachability distance sequence is generated;
[0020] Based on the reachability sequence and the preset threshold, multiple track clusters are identified.
[0021] According to the channel extraction method provided in this application, the step of rasterizing each of the track clusters to obtain a binary raster image includes:
[0022] Based on the preset spatial resolution, the spatial range is divided into multiple pixels;
[0023] The pixels that intersect with the track cluster are assigned a first value, and the pixels that do not intersect with the track cluster are assigned a second value to obtain the track cluster image;
[0024] Based on a preset pixel width, the boundary of the track cluster image is expanded to obtain a binary raster image.
[0025] According to the channel extraction method provided in this application, after rasterizing each of the track clusters to obtain a binary raster image, the method further includes:
[0026] After dilating the binary raster image using a rectangular structuring element, the binary raster image is then eroded using the same rectangular structuring element to obtain a binary raster image containing continuous track bands.
[0027] According to a waterway extraction method provided in this application, the step of extracting the waterway centerline from the binary raster image includes:
[0028] Remove non-critical pixels from the boundary of the track, wherein the non-critical pixels are points that, when removed, do not disrupt the connectivity of the track and do not create holes in the track.
[0029] Iteratively remove non-critical pixels until no more pixels can be removed, resulting in a refined binary raster image.
[0030] Based on the preset pixel width, the thinned binary raster image is cropped to obtain a skeleton image;
[0031] After extracting continuous path segments from the skeleton graph, continuous path segments in the same track cluster are merged to obtain the channel centerline.
[0032] This application also provides a waterway extraction device, comprising the following modules:
[0033] The graph construction module is used to construct an undirected graph with the track segments as nodes and the distance between the track segments as the edge weights, where the track segments are the trajectory lines of the ship's navigation.
[0034] The graph segmentation module is used to: divide the undirected graph into multiple unconnected undirected subgraphs;
[0035] The density clustering module is used to: perform density clustering on any of the undirected subgraphs to obtain multiple track clusters within the undirected subgraphs, wherein the track clusters represent a group of spatially similar ship trajectories;
[0036] The rasterization module is used to: perform rasterization processing on each of the track clusters to obtain a binary raster image, wherein the two values in the binary raster image represent the track coverage area and the background area, respectively;
[0037] The centerline extraction module is used to extract the channel centerline from the binary raster image.
[0038] This application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any of the above-described channel extraction methods.
[0039] This application also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the channel extraction method as described above.
[0040] This application also provides a computer program product, including a computer program that, when executed by a processor, implements any of the above-described channel extraction methods.
[0041] The channel extraction method, apparatus, electronic device, and storage medium provided in this application construct an undirected graph using track segments as nodes and the distance between track segments as edge weights. This preserves the geometric shape of the trajectory and reduces the data dimensionality of subsequent calculations. The undirected graph is divided into multiple disconnected undirected subgraphs. In other words, by performing connectivity analysis on the undirected graph, groups of sparsely connected track segments are automatically identified, forming multiple disconnected undirected subgraphs. This avoids the boundary effects caused by artificially pre-defined partitions, ensuring that track segments within the same channel are grouped into the same subgraph. This fundamentally eliminates the channel breakage or misalignment problem caused by hard partitioning, guaranteeing the global consistency and topological integrity of the extraction results. Furthermore, for any of the aforementioned... An undirected subgraph is subjected to density clustering to obtain multiple track clusters within it. Since the size of the undirected subgraph is significantly smaller than the original undirected graph, and the track segments within it have high similarity, clustering the undirected subgraph greatly reduces the computational complexity of the clustering process. Furthermore, density clustering is relatively insensitive to parameter changes in locally high-density regions, and combined with the homogeneity of the undirected subgraph, it further improves the stability of the clustering results. Next, each track cluster is rasterized to obtain a binary raster image, which can effectively fuse the spatial coverage of multiple similar trajectories, smooth individual navigation deviations and anomaly interference, and output a geometrically continuous and semantically clear channel representation. Finally, a continuous and smooth channel centerline is extracted from the binary raster image. In summary, this application, through track segment graph modeling, adaptive graph partitioning, local density clustering, and rasterized centerline extraction, can accurately and efficiently output a globally continuous channel centerline. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in 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 some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 This is one of the flowcharts illustrating the waterway extraction method provided in this application;
[0044] Figure 2 This is the second flowchart illustrating the waterway extraction method provided in this application;
[0045] Figure 3 This is a schematic diagram of the channel extraction device provided in this application;
[0046] Figure 4 This is a schematic diagram of the structure of the electronic device provided in this application. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions 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, 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.
[0048] It should be noted that in the description of the embodiments of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that includes 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 limitations, 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. The terms "upper," "lower," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this application. Unless otherwise expressly specified and limited, the terms "installed," "connected," and "linked" should be interpreted broadly, for example, they can be fixed connections, detachable connections, or integral connections; they can be mechanical connections or electrical connections; they can be direct connections or indirect connections through an intermediate medium; and they can be internal connections between two elements. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances.
[0049] The terms "first," "second," etc., used in this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class, without limiting the number of objects; for example, a first object can be one or more. Furthermore, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects have an "or" relationship.
[0050] The following is combined Figures 1-4 This application describes the waterway extraction method, apparatus, electronic device, and storage medium provided in the embodiments of this application.
[0051] Figure 1 This is one of the flowcharts illustrating the waterway extraction method provided in this application, such as... Figure 1 As shown, the method includes the following:
[0052] S110, construct an undirected graph with the track segment as the node and the distance between the track segments as the edge weight, where the track segment is the trajectory line of the ship's navigation;
[0053] S120, the undirected graph is divided into multiple unconnected undirected subgraphs;
[0054] S130, For any of the undirected subgraphs, perform density clustering to obtain multiple track clusters within the undirected subgraph, where each track cluster represents a set of spatially similar ship trajectories.
[0055] S140, each of the track clusters is rasterized to obtain a binary raster image, wherein the two values in the binary raster image represent the track coverage area and the background area, respectively;
[0056] S150, the channel centerline is extracted from the binary raster image.
[0057] It should be noted that the execution subject of the waterway extraction method provided in this application embodiment can be a server, computer equipment, such as mobile phone, tablet computer, laptop computer, handheld computer, vehicle electronic equipment, wearable device, ultra-mobile personal computer (UMPC), netbook or personal digital assistant (PDA), etc.
[0058] In S110, a track segment is a path along a ship's course, consisting of a series of consecutive geographical locations. An undirected graph is a graph where edges have no directionality. Nodes in an undirected graph represent track segments, edges represent the proximity relationships between these track segments, and the weight of an edge reflects the distance between two track segments, indirectly reflecting the similarity between them.
[0059] In the specific implementation process, historical data for the target year is obtained from AIS. AIS data includes attributes such as the vessel's timestamp, latitude and longitude, speed, heading, Maritime Mobile Service Identity (MMSI), and International Maritime Organization Number (IMO). To ensure data accuracy, the acquired raw AIS data is first cleaned and preprocessed to remove duplicate records, drift points, and time anomalies. After processing, all data is uniformly sorted by time, and voyages are segmented based on time intervals and port stay times. In addition, berthing data (including vessel codes and departure / arrival times) can be combined, grouped by unique vessel identifier and sorted by time, for trajectory reconstruction and anomaly removal. Interpolation or resampling is then performed using fixed or adaptive step sizes to ensure trajectory continuity.
[0060] Furthermore, after data cleaning and time sorting, voyages are segmented based on ship berthing data. Berthing data includes the ship's departure port, arrival port, and corresponding departure / arrival time. This information is used to determine the start and end of a voyage, thereby accurately segmenting the AIS trajectory data into multiple voyage segments, generating a set of track segments, and indexing each track segment.
[0061] Furthermore, after the cruise segments are divided, interpolation and thinning are performed on the trajectory data for each cruise. The purpose of interpolation is to ensure the temporal and spatial continuity of the cruise trajectories and avoid geometric errors caused by irregular or discontinuous sampling. Linear interpolation or other suitable interpolation methods are usually used to ensure that the time step of each cruise trajectory is uniform for subsequent analysis.
[0062] In this embodiment, the trajectory of each voyage will be represented as a broken line. The voyage track file is stored in a vector format and contains multiple fields, including but not limited to unique identifiers (such as the unique identifier voyage_id generated from the ship identification number MMSI and timestamp to ensure the uniqueness of each voyage), and other fields such as the starting point. and end point The latitude and longitude coordinates are provided for subsequent processing and analysis. The generation of the cruise track file lays the foundation for subsequent track similarity calculations. Then, using `group_id_sample` as the grouping index for each track, the spatial similarity between any two cruise tracks is calculated to generate a track distance file. The track distance file uses columnar storage (such as Parquet format) and mainly contains fields... and ,in It is the spatial distance between the x and y axes of the trajectory line.
[0063] Optionally, the Hausdorff distance can be used to calculate the distance between node A and node B. (Edge weight):
[0064] ;
[0065] in, It is the distance between points a and b. It is the shortest distance from point a to set B. It is the maximum value among the shortest distances from all points in set A to set B. It is the shortest distance from point b to set A. It is the maximum value among the shortest distances from all points in set B to set A.
[0066] Furthermore, this data is used to construct a sparse adjacency matrix to represent the spatial similarity between voyage trajectories. Specifically, the distance between each pair of voyage trajectory lines is used as the edge weight in the matrix, and the group_id_sample of each voyage trajectory line is used as the node index of the matrix to construct a sparse matrix.
[0067] Optionally, to improve computational efficiency and reduce storage requirements, the adjacency matrix is thresholded. Specifically, a maximum neighborhood radius (OPTICS_MAX_EPS=) is set. Then, set the edge weights of all trajectory pairs whose distance is greater than the threshold to zero. That is:
[0068] ;
[0069] Elements of the adjacency matrix This represents the spatial distance between the i-th and j-th trajectory lines. Thus, edges between trajectories are only preserved when they are relatively close. This process is stored in the form of a sparse matrix to reduce memory usage and improve subsequent computational efficiency. The symmetry of the matrix (i.e.,...) This has been guaranteed at this point, thus ensuring the undirectedness of the graph. This sparse adjacency matrix will serve as input data for the graph algorithm, reflecting the similarity between voyage trajectories and providing a foundation for subsequent connected subgraph partitioning and density clustering.
[0070] In S120, the trajectory set is divided into several spatially connected subsets with similar trajectory characteristics. Specifically, an undirected graph connectivity analysis algorithm is used to decompose the sparse adjacency matrix, resulting in different connected subgraphs. Each subgraph represents a set of spatially close flight trajectories with similar characteristics. The sparse adjacency matrix can be analyzed by calling graph algorithm functions (such as `connected_components`) to obtain the labels of the connected components to which each trajectory belongs. The `labels` vector records the connected component numbers corresponding to each trajectory; nodes with the same number form a connected subgraph. In this way, the original sparse adjacency matrix is divided into multiple non-overlapping submatrices, each corresponding to a connected subgraph.
[0071] In S130, density clustering is performed on each connected subgraph to identify spatially similar clusters of tracks.
[0072] Optionally, the OPTICS (Ordering Points To Identify the Clustering Structure) algorithm can be used. This is a density-based clustering algorithm that can automatically identify clustering structures at different density levels. Compared to the traditional DBSCAN algorithm, the OPTICS algorithm has better adaptability and stability when processing data with different density distributions.
[0073] In S140, after the density clustering step, each track cluster represents a group of spatially similar ship trajectories. Next, the vector trajectory of each track cluster is converted into a raster model for subsequent morphological processing and skeleton extraction.
[0074] In S150, binary skeletonization is performed on the track band in the binary raster image to extract the central ridge line, i.e., the channel centerline.
[0075] Finally, the skeleton pixel coordinates are back-projected into geographic coordinate lines according to affine / projection parameters.
[0076] The channel extraction method provided in this application constructs an undirected graph using track segments as nodes and the distance between track segments as edge weights. This preserves the geometric shape of the trajectory and reduces the data dimensionality of subsequent calculations. The undirected graph is divided into multiple disconnected undirected subgraphs. In other words, by performing connectivity analysis on the undirected graph, groups of sparsely connected track segments are automatically identified, forming multiple disconnected undirected subgraphs. This avoids the boundary effects caused by artificially pre-defined partitions, ensuring that track segments within the same channel are grouped into the same subgraph. This fundamentally eliminates channel breaks or misalignments caused by rigid partitioning, guaranteeing the global consistency and topological integrity of the extraction results. Furthermore, for any of the undirected subgraphs… Density clustering is performed to obtain multiple track clusters within the undirected subgraph. Since the size of the undirected subgraph is significantly smaller than the original undirected graph, and the internal track segments have high similarity, clustering the undirected subgraph greatly reduces the computational complexity of the clustering process. Furthermore, density clustering is relatively insensitive to parameter changes in locally high-density regions, and combined with the homogeneity of the undirected subgraph, it further improves the stability of the clustering results. Next, each track cluster is rasterized to obtain a binary raster image, which can effectively fuse the spatial coverage of multiple similar trajectories, smooth individual navigation deviations and anomaly interference, and output a geometrically continuous and semantically clear channel representation. Finally, a continuous and smooth channel centerline is extracted from the binary raster image. In summary, this application, through track segment graph modeling, adaptive graph partitioning, local density clustering, and rasterized centerline extraction, can accurately and efficiently output a globally continuous channel centerline.
[0077] In an optional embodiment, before performing density clustering for any of the undirected subgraphs to obtain multiple track clusters within the undirected subgraph, the method further includes:
[0078] If the number of neighbors of any node is k i If the number of samples is less than the preset minimum number k, then virtual adjacency edges are added between the node and other nodes based on the following steps:
[0079] Determine a set of candidate nodes, wherein the candidate nodes in the set are nodes that are not adjacent to the node;
[0080] Randomly select kk from the candidate node set. i A number of candidate nodes are used as virtual adjacent nodes of the node, and a preset distance constant is used as the weight of the edge between the node and the virtual adjacent node.
[0081] In this embodiment, to address the issue of insufficient neighbor numbers in certain undirected subgraphs and ensure the stability of subsequent clustering algorithms, neighborhood compensation is performed on connected undirected subgraphs. According to the requirements of density-based clustering algorithms, each node needs at least k neighbor nodes during the clustering process. If the number of neighbors for a node is lower than this threshold, virtual edges are added to increase its neighbor count, ensuring that the node can participate normally in the clustering algorithm. Specifically, for each subgraph... Check each node Number of neighbors k i If a node has k neighbors... i If the number of samples is less than the preset minimum number of samples k, add virtual adjacency edges between the node and other nodes so that the number of the node's neighbors meets the minimum requirement.
[0082] In the specific implementation process, the first step is to determine the set of candidate nodes that can be used to supplement the edges. These candidate nodes are potential neighbors of the current node, and are not yet adjacent to the current node; from the set of candidate nodes Randomly select a sufficient number of nodes such that the number of neighbors of node i reaches a certain threshold. If the number of candidate nodes is insufficient, all available candidate nodes are selected; for each selected node j, a virtual distance value is written to the corresponding position in the matrix, while ensuring the symmetry of the matrix, i.e. ,in This is a preset edge-filling distance constant used to represent the weak connection relationship between nodes.
[0083] The channel extraction method provided in this application triggers a compensation operation when a node lacks sufficient neighbors, without altering the original connectivity relationships, thus ensuring the stability of the overall graph structure. After supplementing virtual adjacency edges, the number of neighbors for each node will meet the minimum requirement, thereby ensuring that subsequent density clustering algorithms can run smoothly on this subgraph.
[0084] In an optional embodiment, performing density clustering for any of the undirected subgraphs to obtain multiple track clusters within the undirected subgraph includes:
[0085] For any node in the undirected subgraph, calculate the core distance of the node, which is the distance from the node to its k-th nearest neighbor.
[0086] The maximum value between the adjacency distance and the core distance is taken as the reachable distance between the node and its neighboring nodes, where the adjacency distance is the distance between the node and its neighboring nodes.
[0087] Based on the reachability distances between the nodes, a reachability distance sequence is generated;
[0088] Based on the reachability sequence and the preset threshold, multiple track clusters are identified.
[0089] In this embodiment, the OPTICS algorithm is used for density clustering. The input to the OPTICS algorithm is a pre-calculated distance matrix between trajectories; therefore, it is not necessary to recalculate the distances here, but rather to directly use the adjacency matrix constructed in the previous steps. By setting the minimum number of neighborhood samples (k, i.e., OPTICS_MIN_SAMPLES) and the maximum neighborhood radius (max_eps, i.e., OPTICS_MAX_EPS), the trajectory data can be clustered.
[0090] Understandably, the k value can be set based on empirical track segment density, and it controls the local density threshold.
[0091] Specifically, for each point Calculate the distance to its k-th nearest neighbor, i.e., the core distance. :
[0092] ;in, It is a point Distance to the k-th nearest neighbor;
[0093] Then calculate the reachable distance for any two points. and Reachable distance definition for:
[0094] ;
[0095] in, It is a point and The distance between them is usually Euclidean distance.
[0096] Furthermore, the OPTICS algorithm recursively generates a reachability sequence for samples based on local density. This sequence preserves the global density structure of the data; high-density regions exhibit low and stable reachability distances, while low-density regions or inter-cluster boundaries exhibit valleys or peaks. The sequence itself does not rely on a single density threshold but encodes multi-scale density information. Multiple trajectory clusters are identified through this sequence. For each trajectory, if its reachability distance is greater than the threshold, it is marked as a noise point (-1). Using this method, OPTICS can automatically distinguish between main channels and noisy trajectories, outputting a clustering label for each trajectory, providing foundational data for subsequent trajectory cluster processing and centerline extraction.
[0097] The channel extraction method provided in this application overcomes the dependence of traditional density clustering on a single density parameter. It can flexibly divide clusters according to the local reachability shape, adapt to the heterogeneity of channel density in complex sea areas, and provide basic data for subsequent track cluster processing and centerline extraction.
[0098] In an optional embodiment, the step of rasterizing each of the track clusters to obtain a binary raster image includes:
[0099] Based on the preset spatial resolution, the spatial range is divided into multiple pixels;
[0100] The pixels that intersect with the track cluster are assigned a first value, and the pixels that do not intersect with the track cluster are assigned a second value to obtain the track cluster image;
[0101] Based on a preset pixel width, the boundary of the track cluster image is expanded to obtain a binary raster image.
[0102] In this embodiment, the spatial range is divided into multiple small grid units, or pixels, using a preset spatial resolution, such as 50m×50m or 100m×100m, to generate a two-dimensional spatial pixel matrix. The vector lines of each track cluster... The geometric objects will be rasterized within the grid area. Specifically, using a rasterization function, it is determined pixel by pixel whether the trajectory line intersects with that pixel. If they intersect, a value of 1 or True is assigned, indicating that the pixel belongs to the track area; otherwise, a value of 0 or False is assigned, indicating that the pixel belongs to the background area. In this way, each track cluster is converted into a binary raster image, representing the track coverage area and the background area.
[0103] Furthermore, to prevent boundary cells from being truncated in subsequent morphological operations, the boundaries of the raster image are padded to extend the width by a certain number of cells, such as 3 cells.
[0104] It is understood that in this embodiment of the application, the boundary is extended after the image is rasterized. In other embodiments, the boundary of the original image may be extended first, and then the rasterization process may be performed.
[0105] The channel extraction method provided in this application ensures the integrity of the channel clusters by filling the image boundaries and ensuring that the boundaries of the channel clusters are not affected during processing.
[0106] In an optional embodiment, after rasterizing each of the track clusters to obtain a binary raster image, the method further includes:
[0107] After dilating the binary raster image using a rectangular structuring element, the binary raster image is then eroded using the same rectangular structuring element to obtain a binary raster image containing continuous track bands.
[0108] In this embodiment, a dilation operation is first applied to fill the gaps between tracks caused by missing data or discontinuous AIS signals. Dilation expands the pixels with a pixel value of 1 (i.e., the track coverage area) outwards, with the expansion range depending on the size of the rectangular structural element used. This step effectively connects adjacent but discontinuous track segments, forming a more complete track band.
[0109] Furthermore, an erosion operation is applied to eliminate the increased track width caused by dilation and remove some small noise points. The erosion operation shrinks areas with a pixel value of 1, bringing them back to a state closer to their original size, while maintaining the continuity of the tracks connected by the dilation process. Using rectangular structuring elements of the same size and shape as the dilation stage ensures that the processed result maintains continuity while avoiding over-dilation.
[0110] The channel extraction method provided in this application uses morphological operations to first dilate the raster image and then perform erosion processing. This not only enhances the connectivity of the track area and fills in local holes, but also reduces noise interference and smooths the overall structure, improving the accuracy of the geometry. This provides a more reliable data foundation for subsequent advanced analysis.
[0111] In an optional embodiment, extracting the channel centerline from the binary raster image includes:
[0112] Remove non-critical pixels from the boundary of the track, wherein the non-critical pixels are points that, when removed, do not disrupt the connectivity of the track and do not create holes in the track.
[0113] Iteratively remove non-critical pixels until no more pixels can be removed, resulting in a refined binary raster image.
[0114] Based on the preset pixel width, the thinned binary raster image is cropped to obtain a skeleton image;
[0115] After extracting continuous path segments from the skeleton graph, continuous path segments in the same track cluster are merged to obtain the channel centerline.
[0116] In this embodiment of the application, a binary skeletonization algorithm is used. The central axis information of the track is extracted by shrinking the track from a two-dimensional region into a ridge line with a width of one pixel in order to extract the main structure of the channel.
[0117] First, non-critical pixels are defined as those points whose removal will not disrupt the connectivity of the trackband or create voids within it. Identifying these non-critical pixels is based on their minimal impact on the overall trackband structure. The location of each pixel within the trackband and its influence on the surrounding environment are analyzed to determine which pixels can be safely removed. Once the non-critical pixels are identified, an iterative process begins, removing all removable non-critical pixels in each iteration until no more matching criteria can be found. This process essentially reduces the trackband width while maintaining its connectivity and integrity. Ultimately, the skeleton image forms a clear central ridge, representing the main direction of the channel.
[0118] Furthermore, in order to remove the false branches caused by the boundary filling, the skeleton image is cropped after it is generated to remove the filled outer frame area, so that the skeleton image is restored to the original spatial range.
[0119] Finally, all continuous path segments are extracted from the skeleton map, and all continuous path segments belonging to the same track cluster are merged to form a complete channel centerline. Specifically, the pixel sequence of continuous path segments is extracted using skeleton path analysis, and each pixel's row and column coordinates are mapped to geographic coordinates using affine transformation; the number of points... Path construction This serves as the centerline segment of the cluster. Segments from the same cluster are aggregated and merged, and then geometric simplification is performed with a fixed tolerance, such as 0.1, to obtain the final channel centerline vector, which is then output in a standard vector format, such as... .
[0120] It should be noted that the current implementation does not explicitly perform branch cleanup such as pruning by length threshold; if further removal of short branches is required, filtering by line length can be performed after vectorization, or secondary pruning can be performed by setting branch length / endpoint degree thresholds on the skeleton statistics results.
[0121] Preferably, after the centerline of the waterway is extracted, it needs to be simplified and smoothed to improve its geometric quality and spatial readability. This is achieved through geometric simplification methods such as the Douglas-Peucker algorithm, which aims to remove redundant nodes and smooth the shape of the centerline, thereby reducing detail noise and preserving the main direction of the waterway.
[0122] In some embodiments, the decision to delete a point is made by calculating the distance from each point to the line segment. If the point... to the straight line segment distance Less than the preset simplified tolerance If the point is not found, it is deleted. Through simplification, the channel centerline will have higher readability and stability, more accurately reflecting the main direction of the channel and providing reliable basic data for subsequent visualization, spatial analysis, and shipping network modeling.
[0123] Finally, the generated channel centerline vector data will be output and stored for subsequent visualization, spatial analysis, and data sharing. The output format is typically [format missing]. or The data is stored using a standard geographic coordinate reference system. Each channel centerline object includes its corresponding cluster identifier, path length, and cluster number, ensuring data structure consistency and scalability. During output, the channel centerline data is automatically saved to the specified path, and a corresponding attribute table is generated to record the relationship between the channel and the cluster structure. Users can load this data into a Geographic Information System (GIS) and overlay it with the original trajectory or track cluster results to visually verify the accuracy and morphological continuity of the channel extraction.
[0124] The channel extraction method provided in this application removes unnecessary details by iteratively removing non-critical pixels, while retaining the main structural information, which significantly reduces the amount of data in the image; and performs cropping based on a preset pixel width to restore the original spatial range.
[0125] In summary, such as Figure 2As shown, the channel extraction method provided in this application acquires raw data from the Automatic Identification System (AIS), segments, sorts, and filters consecutive time points of the same vessel to form a complete sequence of voyage trajectory points and generates corresponding voyage trajectory lines. Based on spatial similarity measurement methods such as the shortest distance between line segments, pairwise distances are calculated for all voyage trajectory lines. A sparse adjacency matrix is constructed based on trajectory lines as nodes and distances between trajectories as edge weights. The trajectory network is divided into multiple independent connected subgraphs. Based on the pre-calculated distance matrix, the OPTICS density clustering algorithm is executed on each connected subgraph to obtain multiple channel trajectory clusters, each trajectory cluster corresponding to a potential channel or navigation corridor. Based on the clustering results, the channel trajectory clusters are projected onto a unified geographic coordinate system and rasterized with a fixed spatial resolution. A binary skeletonization operation is performed on the processed track strip to extract the topological backbone ridge of the track strip. Finally, the skeleton pixel coordinates are back-projected to the geographic coordinate system based on raster affine transformation to obtain the vector representation of the channel centerline. This application combines the precise channel morphology capture capability of vector-based clustering methods with the speed advantage of grid-based methods, enabling accurate and robust identification of main channels for ships operating in global sea areas. This improves the adaptability of channel extraction methods in complex sea areas and large spatial scales, while also increasing extraction efficiency.
[0126] The channel extraction device provided in the embodiments of this application is described below. The channel extraction device described below and the channel extraction method described above can be referred to in correspondence.
[0127] Figure 3 This is a schematic diagram of the channel extraction device provided in this application, as shown below. Figure 3 As shown, the channel extraction device may include, but is not limited to:
[0128] Graph construction module 310 is used to: construct an undirected graph with track segments as nodes and the distance between the track segments as the edge weights, wherein the track segments are the trajectory lines of ship navigation;
[0129] Graph segmentation module 320 is used to: divide the undirected graph into multiple unconnected undirected subgraphs;
[0130] The density clustering module 330 is used to: perform density clustering on any of the undirected subgraphs to obtain multiple track clusters within the undirected subgraphs, wherein the track clusters represent a group of spatially similar ship trajectories;
[0131] The rasterization module 340 is used to: perform rasterization processing on each of the track clusters to obtain a binary raster image, wherein the two values in the binary raster image represent the track coverage area and the background area, respectively;
[0132] The centerline extraction module 350 is used to extract the channel centerline from the binary raster image.
[0133] It should be noted that the channel extraction device provided in this application embodiment can execute the channel extraction method described in any of the above embodiments during actual operation, and this embodiment will not elaborate on this.
[0134] Figure 4 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 4 As shown, the electronic device may include: a processor 410, a communications interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communications interface 420, and the memory 430 communicate with each other via the communication bus 440. The processor 410 can call logical instructions in the memory 430 to execute a waypoint extraction method, which includes:
[0135] An undirected graph is constructed using the track segments as nodes and the distance between the track segments as the edge weights. The track segments are the trajectories of the ship's navigation.
[0136] The undirected graph is divided into multiple unconnected undirected subgraphs;
[0137] For any of the undirected subgraphs, density clustering is performed to obtain multiple track clusters within the undirected subgraph, and the track clusters represent a group of spatially similar ship trajectories;
[0138] Each of the aforementioned track clusters is rasterized to obtain a binary raster image, wherein the two values in the binary raster image represent the track coverage area and the background area, respectively;
[0139] The channel centerline is extracted from the binary raster image.
[0140] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0141] On the other hand, this application also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the waypoint extraction method provided by the above methods, the method including:
[0142] An undirected graph is constructed using the track segments as nodes and the distance between the track segments as the edge weights. The track segments are the trajectories of the ship's navigation.
[0143] The undirected graph is divided into multiple unconnected undirected subgraphs;
[0144] For any of the undirected subgraphs, density clustering is performed to obtain multiple track clusters within the undirected subgraph, and the track clusters represent a group of spatially similar ship trajectories;
[0145] Each of the aforementioned track clusters is rasterized to obtain a binary raster image, wherein the two values in the binary raster image represent the track coverage area and the background area, respectively;
[0146] The channel centerline is extracted from the binary raster image.
[0147] In another aspect, this application also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the channel extraction methods provided by the above methods, the method comprising:
[0148] An undirected graph is constructed using the track segments as nodes and the distance between the track segments as the edge weights. The track segments are the trajectories of the ship's navigation.
[0149] The undirected graph is divided into multiple unconnected undirected subgraphs;
[0150] For any of the undirected subgraphs, density clustering is performed to obtain multiple track clusters within the undirected subgraph, and the track clusters represent a group of spatially similar ship trajectories;
[0151] Each of the aforementioned track clusters is rasterized to obtain a binary raster image, wherein the two values in the binary raster image represent the track coverage area and the background area, respectively;
[0152] The channel centerline is extracted from the binary raster image.
[0153] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0154] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0155] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A method for waterway extraction, characterized in that, include: An undirected graph is constructed using the track segments as nodes and the distance between the track segments as the edge weights. The track segments are the trajectories of the ship's navigation. The undirected graph is divided into multiple unconnected undirected subgraphs; For any of the undirected subgraphs, density clustering is performed to obtain multiple track clusters within the undirected subgraph, and the track clusters represent a group of spatially similar ship trajectories; Each of the aforementioned track clusters is rasterized to obtain a binary raster image, wherein the two values in the binary raster image represent the track coverage area and the background area, respectively; The channel centerline is extracted from the binary raster image; Before performing density clustering on any of the undirected subgraphs to obtain multiple track clusters within the undirected subgraph, the method further includes: If the number of neighbors of any node is k i If the number of samples is less than the preset minimum number k, then virtual adjacency edges are added between the node and other nodes based on the following steps: Determine a set of candidate nodes, wherein the candidate nodes in the set are nodes that are not adjacent to the node; Randomly select kk from the candidate node set. i Each candidate node is used as a virtual neighbor node of the node, and a preset distance constant is used as the weight of the edge between the node and the virtual neighbor node. For any of the undirected subgraphs, density clustering is performed to obtain multiple track clusters within the undirected subgraph, including: For any node in the undirected subgraph, calculate the core distance of the node, which is the distance from the node to its k-th nearest neighbor. The maximum value between the adjacency distance and the core distance is taken as the reachable distance between the node and its neighboring nodes, where the adjacency distance is the distance between the node and its neighboring nodes. Based on the reachability distances between the nodes, a reachability distance sequence is generated; Based on the reachability sequence and the preset threshold, multiple track clusters are identified.
2. The waterway extraction method according to claim 1, characterized in that, The step of rasterizing each of the track clusters to obtain a binary raster image includes: Based on the preset spatial resolution, the spatial range is divided into multiple pixels; The pixels that intersect with the track cluster are assigned a first value, and the pixels that do not intersect with the track cluster are assigned a second value to obtain the track cluster image; Based on a preset pixel width, the boundary of the track cluster image is expanded to obtain a binary raster image.
3. The waterway extraction method according to claim 2, characterized in that, After performing rasterization on each of the aforementioned track clusters to obtain a binary raster image, the method further includes: After dilating the binary raster image using a rectangular structuring element, the binary raster image is then eroded using the same rectangular structuring element to obtain a binary raster image containing continuous track bands.
4. The waterway extraction method according to claim 3, characterized in that, Extracting the channel centerline from the binary raster image includes: Remove non-critical pixels from the boundary of the track, wherein the non-critical pixels are points that, when removed, do not disrupt the connectivity of the track and do not create holes in the track. Iteratively remove non-critical pixels until no more pixels can be removed, resulting in a refined binary raster image. Based on the preset pixel width, the thinned binary raster image is cropped to obtain a skeleton image; After extracting continuous path segments from the skeleton graph, continuous path segments in the same track cluster are merged to obtain the channel centerline.
5. A channel extraction device, characterized in that, The method for extracting waterways as described in claim 1 includes: The graph construction module is used to construct an undirected graph with the track segments as nodes and the distance between the track segments as the edge weights, where the track segments are the trajectory lines of the ship's navigation. The graph segmentation module is used to: divide the undirected graph into multiple unconnected undirected subgraphs; The density clustering module is used to: perform density clustering on any of the undirected subgraphs to obtain multiple track clusters within the undirected subgraphs, wherein the track clusters represent a group of spatially similar ship trajectories; The rasterization module is used to: perform rasterization processing on each of the track clusters to obtain a binary raster image, wherein the two values in the binary raster image represent the track coverage area and the background area, respectively; The centerline extraction module is used to extract the channel centerline from the binary raster image.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the channel extraction method as described in any one of claims 1 to 4.
7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the channel extraction method as described in any one of claims 1 to 4.
8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the channel extraction method as described in any one of claims 1 to 4.