A method for extracting a coastline from a SAR image
By using a weakly supervised dual-branch network guided by SAM priors to generate land-sea binarized pre-labels and combining them with multi-level deep supervision and boundary repair, the problem of scarce labeled data and cross-domain migration in SAR image coastline extraction is solved, and high-precision, geometrically consistent coastline monitoring is achieved.
Patent Information
- Application Number
- CN202610711115.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-22
- Publication Date
- 2026-08-25
- Estimated Expiration
- 2046-05-22
AI Technical Summary
Existing technologies for coastline extraction from SAR images suffer from problems such as scarce labeled data, difficulty in transferring optical image models, and failure of visual basic models in the SAR domain, making it difficult to achieve high-precision coastline monitoring.
A weakly supervised dual-branch network SAR image coastline extraction method guided by SAM prior is adopted. By generating land-sea binarized pre-labels, constructing a dual-branch fusion encoder network, and implementing multi-level deep supervision and explicit boundary repair, high-precision coastline extraction is achieved.
It breaks through the annotation bottleneck, achieves low-dependency training, cross-domain semantic alignment, improves feature fusion efficiency, enhances boundary refinement and geometric consistency, adapts to multi-source data, and provides efficient and accurate coastline monitoring support.
Smart Images

Figure CN122289964B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of remote sensing image processing and deep learning, specifically a method for extracting coastlines from SAR images. Background Technology
[0002] As the link between land and sea, the coastline is a crucial task in the field of remote sensing, and high-precision coastline monitoring is essential. Synthetic Aperture Radar (SAR) possesses all-weather, all-day imaging capabilities, giving it a unique advantage in long-term, precise coastline monitoring. However, the multiplicative speckle noise and complex backscattering mechanisms inherent in SAR imagery pose significant challenges to coastline extraction based on SAR imagery.
[0003] In the evolution of coastline extraction technology, core methods have progressed from traditional image processing techniques relying on manually designed features to utilizing machine learning for pixel or object classification, and further into the deep learning stage capable of automatically learning deep features. Early research primarily employed edge detection operators, normalized differential water index, threshold segmentation, and wavelet transform methods to extract coastlines. However, these methods typically rely on manually designed features, exhibiting significant limitations in generalization and robustness when distinguishing regions with minimal spectral differences (such as aquaculture areas versus open sea areas). With the development of machine learning, methods like support vector machines have enhanced the ability to distinguish complex scenes by utilizing the spectral and textural features of images. In recent years, deep learning methods, represented by convolutional neural networks, have achieved unprecedented accuracy breakthroughs in land-sea segmentation tasks, capable of automatically learning multi-level, high-dimensional feature representations from data.
[0004] However, the current mainstream supervised deep learning methods are severely constrained by the following three core bottlenecks: (1) Existing large-scale, high-precision SAR land-sea segmentation benchmark data are extremely scarce: The performance of supervised deep learning is highly dependent on large-scale, high-precision manually labeled data. For SAR image land-sea segmentation tasks, the cost of constructing such datasets is high and the cycle is long, which has become a key bottleneck restricting the widespread application of the technology and further improvement of model performance. Although there are globally available water products as alternative labels, their spatial resolution and accuracy often cannot meet the application requirements of high-precision coastline monitoring. (2) Optical image models are difficult to transfer directly: Most existing land-sea segmentation algorithms are designed for optical images, and their representational priors have significant domain differences from the unique scattering mechanism, complex texture and geometric distortion features of SAR images. (3) Visual basic models have a "semantic gap" failure problem in the SAR domain: In recent years, visual basic models represented by SAM (Segment Anything Model) have changed the research paradigm of image segmentation with their excellent zero-shot generalization ability. However, the semantic priors learned by such basic models on massive natural RGB images cannot directly cover the physical scattering representation unique to SAR images. When the SAM model is directly applied to coastline extraction from SAR imagery, its lack of an inherent understanding mechanism for speckle noise and geometric distortion leads to jagged boundaries and severe misclassification in low-contrast coastal areas, exhibiting a failure characteristic of "strong zero-sample capability but weak generalization in specialized domains." Therefore, directly utilizing existing visual baseline models for SAR coastline extraction still cannot meet the requirements of high-precision mapping. Summary of the Invention
[0005] To address the problems existing in the prior art, the present invention aims to provide a SAR image coastline extraction method that can effectively utilize the high-level semantic prior of the basic model, while closely combining the low-level physical scattering characteristics of the SAR image, so as to overcome the constraint of scarce labeled data and achieve high-precision, high-geometric consistency automated coastline extraction.
[0006] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0007] A method for extracting coastlines from SAR images includes the following steps: Step S1: Input the original SAR image into a pre-trained visual base model to generate a set of color masks; calculate the ocean confidence score for each mask based on its area and color diversity, and determine the mask with the highest score as an ocean area and the remaining masks as land areas; perform mask balance and geographic continuity post-processing on the obtained initial segmentation map to obtain land-sea binarized pre-labels; Step S2: Construct a dual-branch fusion encoder network, using the original SAR image and the land-sea binarized pre-labels as dual inputs; the network includes: a main visual encoder for extracting multi-scale visual features of the SAR image; a SAM prior encoder for extracting multi-scale spatial prior features of the land-sea binarized pre-labels; adaptively fuse the visual features and prior features of the same scale at multiple scales to obtain fused features; input the fused features into a decoder to generate segmentation prediction maps and edge prediction maps from coarse to fine levels; perform direction-aware boundary repair on the preliminary segmentation probability map to obtain the final segmentation map; Step S3: Input the SAR image to be tested into the trained network and output the coastline extraction result.
[0008] As a further improvement to the above technical solution:
[0009] The visual base model is the SAM2 model; the ocean confidence score in step S1 Calculate using the following formula:
[0010]
[0011] in, Let the pixel area of the k-th mask be . The maximum area among all masks. The color richness of the area covered by the k-th mask; To maximize the richness of color variety; and To control the hyperparameters of the two weights.
[0012] In step S2, the main visual encoder uses a pre-trained VGG-16 network with feedforward convolutional layers to output visual features at five scales, with the number of channels being 64, 128, 256, 512, and 512 respectively. The SAM prior encoder is a lightweight convolutional neural network consisting of five convolutional blocks. Each convolutional block includes a max pooling layer with a stride of 2 and a two-dimensional convolutional layer, outputting prior features at five scales, with the number of channels being 16, 32, 64, 64, and 64 respectively.
[0013] The adaptive fusion method described in step S2 is as follows: for the first Each scale will define visual features with prior features After concatenation along the channel dimension, dimensionality reduction is performed through a 1×1 convolutional layer, followed by batch normalization and ReLU activation to obtain the fused features. :
[0014]
[0015] in, For fusion function, It is the first Visual features output by the main visual encoder at each scale The number of channels, It is the first Prior features output by the SAM prior encoder at each scale The number of channels, and These represent batch normalization and linear activation functions, respectively. Represent a The convolutional layer.
[0016] In step S2, after generating a coarse segmentation prediction at the bottleneck layer, the decoder performs a four-level upsampling operation. At the k-th level, the features upsampled at the previous level are concatenated and convolved with the fused features at the corresponding scale to obtain the current level decoding features, where k ranges from 1 to 4. The current level decoding features are fed into the segmentation optimization head and the edge prediction head, respectively. The segmentation optimization head generates the current level segmentation prediction map by combining the upsampled results of the previous level segmentation prediction, and the edge prediction head generates the current level edge prediction map.
[0017] The direction-aware boundary repair in step S2 specifically includes: predicting the edges corresponding to the initial segmentation probability map. Figure 2 Values are used to obtain a boundary mask; a lightweight orientation head is used to predict an 8-channel orientation map corresponding to 8 discrete directions from the decoded features; a directional convolution kernel with fixed parameters is used to perform orientation-aware context aggregation on the preliminary segmentation probability map within the boundary mask area, and combined with the attention weights of the orientation map to generate a boundary optimization signal; the boundary optimization signal is fused with the original segmentation prediction outside the boundary mask area to obtain the final segmentation map.
[0018] The network training in step S2 uses a composite loss function. Optimize:
[0019]
[0020] in, The main segmentation loss, For edge detection loss, To predict the loss in the direction, This represents the loss for multi-scale depth supervision.
[0021] The edge detection loss Calculate using the following formula:
[0022]
[0023] in, This is the edge prediction map corresponding to the initial segmentation probability map. This is the edge prediction map output by the k-th decoding layer. The binary edge mask is generated from the real label distance map. The weighted binary cross-entropy loss is set to 0.85 for positive samples. This is to indicate downsampling.
[0024] The direction prediction loss Calculated only at the actual edge pixels:
[0025]
[0026] in, This is the 8-channel radiation pattern output by the direction prediction head. This is a real-world orientation label image. This represents the cross-entropy loss.
[0027] The multi-scale depth supervision loss Calculate using the following formula:
[0028]
[0029] in, For binary cross-entropy loss, This is the segmentation prediction map output by the k-th decoding layer. For downsampling operation, The label is a true binary label.
[0030] The mask balance and geographic continuity post-processing in step S2 includes: checking the connectivity of land and ocean regions through connected component analysis and calculating the area ratio; if the area ratio of any category is lower than a set threshold, merging heterogeneous connected domains adjacent to the main category region into the main category region; merging isolated land islands surrounded by major water bodies, and merging small water bodies embedded in large landmasses into land.
[0031] The beneficial effects of this invention are:
[0032] (1) Breaking through the labeling bottleneck and achieving low-dependency training. This invention proposes a new paradigm of "prior guidance-feature fusion", which utilizes the zero-sample transfer capability of the visual basic model SAM to automatically generate high-quality binary pre-labels as initial supervision signals. This method significantly reduces the dependence on manual fine labeling and effectively overcomes the constraint of the extreme scarcity of high-quality pixel-level labeled data in SAR image land-sea segmentation tasks, providing a practical and feasible technical path for large-scale, long-term automated coastline monitoring.
[0033] (2) Cross-domain semantic alignment to improve feature fusion efficiency. This invention designs a dual-branch fusion encoder network. The main branch extracts the unique depth texture features of SAR images, while the auxiliary branch encodes the global spatial prior information provided by SAM, and achieves adaptive depth fusion at multiple scales. This mechanism integrates the general high-level semantic segmentation prior with the underlying physical scattering characteristics of SAR images, effectively solving the performance degradation problem when the visual basic model is directly transferred to the SAR domain, and significantly bridging the semantic gap between the optical and SAR domains.
[0034] (3) Refining Boundaries to Enhance Geometric Consistency. This invention introduces a multi-level deep supervision and explicit boundary repair module. Through direction-aware feature learning and the physical constraints of fixed-direction convolution, pixel-level refinement is performed on the jagged boundaries introduced by the coarse SAM labels. Experimental results show that the method of this invention outperforms existing advanced semantic segmentation models in core metrics such as IoU and F1 score, and the extracted coastlines show significant improvements in geometric continuity and spatial consistency.
[0035] (4) End-to-end generalization framework, adaptable to multi-source data. This invention constructs a complete end-to-end processing flow covering automatic generation of SAM pre-labels, dual-branch feature fusion encoding, and boundary refinement output. This framework does not rely on manual parameter adjustment for specific sensors or scenarios, has strong generalization ability and robustness, and can be directly transferred to coastline extraction tasks from various SAR data sources such as GF-3 and Sentinel-1, providing efficient and accurate technical support for fields such as land resource surveys and marine disaster prevention and mitigation.
[0036] (5) Lightweight prior embedding, balancing efficiency and accuracy. This invention binarizes the SAM color mask and encodes it into compact prior features, introducing rich spatial structure information while avoiding additional high computational overhead. This processing method further improves boundary localization accuracy and segmentation integrity while maintaining model inference speed, verifying the necessity and effectiveness of binarization preprocessing in SAR coastline extraction tasks. Attached Figure Description
[0037] Figure 1 This is a schematic diagram of the method of the present invention.
[0038] Figure 2 This is a schematic diagram of the SAM color mask binarization process of the present invention.
[0039] Figure 3 This is a schematic diagram of the boundary repair method of the present invention.
[0040] Figure 4 This is a schematic diagram of the boundary repair effect according to an embodiment of the present invention, wherein (a1), (b1), and (c1) are different SAR images, (a2), (b2), and (c2) are binarized images before boundary refinement, (a3), (b3), and (c3) are binarized images after boundary refinement, (a4), (b4), and (c4) are ground truth labels, (a5), (b5), and (c5) are difference images before and after boundary refinement, and (a6), (b6), and (c6) are average directional heatmaps output by directional convolution kernels.
[0041] Figure 5 This invention is based on a publicly available dataset from Sentinel-1, where (a), (b), (c), and (d) are four different images.
[0042] Figure 6 Examples of images of Hainan Island, China, captured by the Gaofen-3 satellite (GF-3) according to this invention, where (a), (b), (c), and (d) are four different images.
[0043] Figure 7 This is a schematic diagram of the effect of SAM pre-labels on land-sea segmentation in this invention. In this diagram, (a1), (b1), (c1), (d1), and (e1) are different SAR images, (a2), (b2), (c2), (d2), and (e2) are SAM prediction images, (a3), (b3), (c3), (d3), and (e3) are SAM pre-labels, and (a4), (b4), (c4), (d4), and (e4) are ground truth labels.
[0044] Figure 8 The diagram shows the comparative experimental results of the present invention. In the diagram, (a) is a SAR image, (b1), (b2), (b3), (b4), and (b5) are the ground truth labels of the present invention, DeepLabV3+, CBRnet, Segformer, and PSPNet, respectively, (c1), (c2), (c3), (c4), and (c5) are the predicted images of the present invention, DeepLabV3+, CBRnet, Segformer, and PSPNet, respectively, and (d1), (d2), (d3), (d4), and (d5) are the land-sea boundary maps extracted by the present invention, DeepLabV3+, CBRnet, Segformer, and PSPNet, respectively.
[0045] Figure 9 This is a schematic diagram of the ablation experiment results of the present invention, wherein (a) is a SAR image, (b1), (b2), (b3), and (b4) are the true values of the labels for configurations A, B, C, and D, respectively, (c1), (c2), (c3), and (c4) are the predicted images for configurations A, B, C, and D, respectively, and (d1), (d2), (d3), and (d4) are the land-sea boundary maps extracted for configurations A, B, C, and D, respectively. Detailed Implementation
[0046] The specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.
[0047] For ease of description, spatial relative terms such as "above," "on top of," "on the upper surface of," "above," etc., are used herein to describe the spatial positional relationship of a device or feature as shown in the figures to other devices or features. It should be understood that spatial relative terms are intended to encompass different orientations in use or operation beyond the orientation of the device as described in the figures. For example, if the device in the figures were inverted, a device described as "above" or "on top of" other devices or structures would subsequently be positioned as "below" or "under" other devices or structures. Thus, the exemplary term "above" can include both "above" and "below." The device may also be positioned in other different ways (rotated 90 degrees or in other orientations), and the spatial relative descriptions used herein will be interpreted accordingly.
[0048] A method for coastline extraction from SAR images, such as Figure 1 As shown, this method is a weakly supervised dual-branch network SAR image coastline extraction method based on SAM prior guidance, named S²C-Net (SAR-SAM Coastal Segmentation Network), which includes the following steps:
[0049] Step S1: Generate land-sea binarized pre-labels based on the SAM2 model.
[0050] While the color masks generated by the visual foundation model SAM contain rich object boundary information, their output does not distinguish between the semantic categories of "land" and "ocean," and suffers from over-segmentation or region fragmentation. To address this, this step proposes an adaptive weighted land-sea discrimination strategy. This strategy determines and fuses unified land-sea binary pre-labels from multiple region masks generated by SAM2, providing initial supervision information for subsequent network training.
[0051] Specifically, step S1 includes the following sub-steps:
[0052] Step S11: Generate the initial semantic mask for SAM2.
[0053] The original SAR image is input into the pre-trained SAM-vit_l model, and the model automatically generates a set of non-binarized color masks covering different semantic regions in the image, denoted as . The SAM-vit_l model is one of the three main versions of the Segment Anything Model (SAM) released by Meta AI.
[0054] Step S12: Perform adaptive weighted land-sea discrimination.
[0055] Taking all factors into consideration Two key features of each masked region in SAR imagery are region area and color diversity. Based on prior geographical assumptions, in the color mask representation of SAR imagery, large, continuous regions with uniform internal color texture correspond to ocean; while regions with richer internal textures (mapped to color) due to topography, vegetation, or man-made structures correspond to land.
[0056] Based on the above prior knowledge, for each mask Calculate a confidence score to classify it as "ocean". The calculation formula is as follows:
[0057]
[0058] in, For mask pixel area The maximum area among all masks. For this mask in The richness of color types in the area covered (color diversity score); The maximum color variety richness (maximum diversity score); and To control the hyperparameters of the two weights.
[0059] Calculate all masks The mask with the highest score is selected as the "ocean" region. All other masked regions are classified as "land," thus initially forming a binary segmentation map. .
[0060] Step S13: Perform mask balance and geographic continuity post-processing.
[0061] To ensure the continuity and category balance of the coastal zone, mask balance and geographic continuity post-processing are introduced. Specifically, firstly, the connectivity of land and marine areas is checked through connectivity component analysis, and their area proportions are calculated. If the area proportion of any category is lower than a preset threshold (set to a certain value in this embodiment), the process is repeated. If the result is not found, then balance correction is initiated: small-area heterogeneous regions adjacent to the main category region are merged and transformed to ensure that the result contains both reasonable land and ocean categories.
[0062] Subsequently, geographic continuity enhancement processing is performed, merging small land islands surrounded by major water bodies, or incorporating small water bodies embedded in large landmasses into landmasses, resulting in the final binarized pre-labeled data. That is, SAM pre-labeling, the binarization process is as follows Figure 2 As shown.
[0063] Step S2: Construct and train a dual-branch fusion encoder network, using the original SAR image and the aforementioned land-sea binarized pre-labels as dual inputs, to output high-precision land-sea segmentation results. First, the SAR image is encoded via a pre-trained VGG-16 backbone network to extract multi-level depth features; simultaneously, the SAM pre-labels are encoded via a lightweight custom encoder (SAM prior encoder) to extract spatial prior features. Then, at five different scales, the two sets of features are adaptively fused using a dedicated fusion module (FusionBlock). The fused multi-scale features are fed into a U-Net-structured decoder for progressive upsampling and feature aggregation. Finally, a boundary repair module refines the edges of the output mask to obtain high-precision land-sea segmentation results. A schematic diagram of the boundary repair method is shown below. Figure 3 As shown.
[0064] Traditional encoder-decoder networks (such as U-Net) aggregate shallow features and deep semantics through skip connections. However, such architectures struggle to effectively integrate rich semantic information from external prior models, thus limiting performance improvement in data-scarce scenarios. To fully utilize the semantic and boundary priors inherent in SAM pre-labels, this paper proposes a dual-branch fusion encoder network. Its core design idea is to encode coarse SAM pre-labels through a dedicated branch, extracting their inherent general object segmentation priors; and then perform multi-scale, adaptive fusion of these priors with visual features extracted from raw SAR imagery, thereby guiding the network to perform refined learning even in the absence of a large number of real labels.
[0065] Step S2 includes the following sub-steps:
[0066] Step S21: Construct a dual-branch encoder.
[0067] The network uses the original SAR image and its corresponding SAM binarized pre-labels as dual inputs. The dual-branch encoder includes a main visual encoder and a SAM prior encoder.
[0068] The main visual encoder employs feedforward convolutional layers of a VGG-16 network pre-trained on the ImageNet dataset. Given an input SAR image... .in Represents the set of real numbers, indicating that all pixel values in the image are real numbers; Indicates the height (number of pixel rows) of the input SAR image; Indicates the width (number of pixel columns) of the input SAR image; This indicates a single channel, meaning the SAR image is a grayscale image (with only one brightness channel), unlike the three channels of an RGB image. In other words, the input is an image of size [size missing]. The single-channel real-valued grayscale SAR image. It should be noted that the number of output channels mentioned later (64, 128, 256, 512, 512) corresponds to the channel dimension of the feature map extracted by the VGG-16 convolutional layer.
[0069] The main visual encoder extracts multi-level visual features at five scales through a series of convolution and pooling operations. The number of output channels for each layer are 64, 128, 256, 512, and 512, respectively. Since 512 channels have already extracted sufficiently high-level semantic features, downsampling is not performed after the fifth layer to maintain computational efficiency.
[0070] The SAM prior encoder is a lightweight convolutional neural network whose input is a single-channel SAM pre-labeled binary map:
[0071]
[0072] The SAM prior encoder consists of five convolutional blocks. Each convolutional block contains a max-pooling layer with a stride of 2 for downsampling, followed by a 2D convolutional layer and a ReLU activation function. This structure aims to simulate the downsampling rhythm of the primary visual encoder, ensuring a one-to-one correspondence between the two sets of features in spatial scale. The number of output channels for each layer of the SAM prior encoder is set to 16, 32, 64, 64, and 64, respectively. The proportion of the input channels of the SAM prior encoder to the output channels of each primary visual encoder is approximately 25%, 25%, 25%, 12.5%, and 12.5%, respectively. This design effectively extracts the prior features of the SAM prior encoder while ensuring that the SAR image visual features extracted by the primary visual encoder dominate the network.
[0073] Although the boundaries of the SAM pre-labels are relatively coarse, the encoding process encodes them into a set of multi-scale semantic features that contain the spatial layout and rough shape of the "sea" and "land" regions, providing the network with key class distribution and boundary prior information.
[0074] Step S22: Perform adaptive feature fusion at multiple scales.
[0075] Multi-scale feature fusion is the key to achieving prior knowledge injection in this invention. To achieve deep fusion of visual features and semantic priors at multiple semantic levels, a lightweight fusion module (FusionBlock) is introduced at five corresponding scales.
[0076] For the At each scale, the fusion module receives visual features from the main visual encoder. and prior features from the SAM prior encoder The fusion process is defined as follows:
[0077]
[0078] in, It is the first Fusion features at various scales; This is the fusion function; It is the first Visual features output by the main visual encoder at each scale The number of channels; It is the first Prior features output by the SAM prior encoder at each scale The number of channels; This indicates a splicing operation along the channel dimension, which concatenates visual features with prior features along the feature dimension. It is the first The height of the feature map at each scale, and the stitched feature map. Space height and input and Highly consistent; It is the first The width of the feature map at each scale; Represent a Convolutional layers, Indicates the number of input channels ,through Convolution dimensionality reduction to the number of output channels ; and These represent batch normalization and linear activation functions, respectively, used to stabilize the training process.
[0079] The core function of this operation is to adaptively fuse information from both branches and maintain the same number of channels as the original visual features through dimensionality reduction, enabling seamless integration with subsequent decoders. Through this design, FusionBlock can dynamically calibrate and enhance visual features. Middle and prior features Highly correlated components. The final output's fusion features. It is a multi-scale feature map that not only preserves the details and textures of the original image, but also deeply integrates pixel-level semantic priors.
[0080] Step S23: Perform multi-level feature upsampling and prediction using the decoder.
[0081] The decoder adopts an encoder-decoder (U-Net) architecture, which gradually integrates the fused multi-scale features through multi-level upsampling and skip connections. The original input resolution is restored, and intensive prediction and optimization are performed in the process.
[0082] The specific decoding process is as follows:
[0083] First, the network generates a coarse segmentation prediction at the bottleneck layer using a classification head. .
[0084] Subsequently, the decoder performs a four-stage upsampling operation. In the... class( From 1 to 4), the process includes the following steps:
[0085] (1) Feature upsampling and fusion: After upsampling features from deeper layers, they are combined with features from the encoder at the same level. The features are concatenated and convolved to generate the decoding features at the current scale.
[0086] (2) Edge and segmentation prediction: The decoded features are simultaneously fed into two parallel 1×1 convolution heads: one edge prediction head outputs an edge activation map. A segmentation optimization head is used to predict segmentation based on upsampling in the previous stage. To guide the output, and based on current features, a more refined segmentation map at the current scale is generated. This design creates a gradual optimization mechanism from coarse to fine.
[0087] (3) Iterative propagation: Optimized It will be upsampled to guide the segmentation optimization of the next level (shallower layer).
[0088] Finally, the decoder outputs the preliminary segmentation probability map with the highest fine-scale resolution. and its corresponding edge prediction .
[0089] Step S24: Perform boundary repair on the preliminary segmentation results.
[0090] To smooth the output land-sea boundary and improve geometric consistency, boundary repair processing is performed on the initial segmentation results.
[0091] Specifically, it receives three inputs: a segmented image before boundary refinement, an edge segmentation heatmap, and an 8-channel orientation map predicted from the decoded features by a lightweight orientation head.
[0092] The boundary repair mechanism is as follows: First, the edge segmentation thermal... Figure 2 The image is valued and masked to focus on the boundary regions. Then, a set of directional convolutional kernels with fixed parameters is used to perform orientation-aware context aggregation on the segmented image before boundary refinement. The result is combined with the orientation prediction heatmap to generate a boundary optimization signal. Finally, this optimized signal is applied only to the edge masked regions and smoothly fused with the original predictions for non-boundary regions, resulting in a final segmentation image with clear boundaries and high detail preservation. (i.e., the segmented image after boundary restoration).
[0093] like Figure 3 As shown, the final step utilizes eight convolution kernels with different directions (the convolution kernels in the figure). The number 8 represents 8 convolutional kernels. These eight kernels are 3×3 translation filters with fixed weights. Each kernel has only one element with a value of 1, and the rest are 0. They correspond to the eight directions in the 3×3 neighborhood: left, top left, top, top right, right, bottom right, bottom, and bottom left. After the input mask (i.e., the preliminary segmentation probability map output by the decoder) passes through these eight kernels, it will produce eight mask images that are each translated by one pixel in their corresponding direction.
[0094] Additionally, the orientation prediction head outputs an 8-channel orientation map, representing the probability that each location belongs to one of the eight directions mentioned above. The orientation prediction head is a small module in the network (after the decoder and before the final output). It doesn't directly predict whether it's land or sea, but rather specifically analyzes the local orientation of each boundary pixel along the coastline (e.g., whether the boundary is to the left, right, or diagonally). The orientation prediction head outputs an 8-channel orientation map. This refers to the network generating an 8-dimensional probability distribution for each location in an image (especially near the coastline), representing the most likely local geometric orientation of the land-sea boundary at that location (one or more of eight directions). This provides crucial geometric prior information for subsequent refined boundary repair.
[0095] Subsequently, the translated mask image is multiplied channel-by-channel by the orientation probability and then summed. This allows the correct category value to be dynamically extracted from neighboring pixels based on the predicted boundary orientation, thereby repairing the rough segmentation edges. Finally, the orientation aggregation result is used only in regions predicted as edges by the network, while the original mask is retained in non-edge regions, achieving orientation-aware edge refinement.
[0096] like Figure 4 The diagram shown is a schematic representation of the boundary repair effect according to an embodiment of the present invention.
[0097] Step S25: Optimize and train the network based on the composite loss function.
[0098] To optimize the final segmentation accuracy, boundary quality, and accelerate convergence, a composite loss function was designed. It integrates the main segmentation loss, edge detection loss, orientation prediction loss, and multi-scale depth supervision loss to jointly guide network training.
[0099] The primary segmentation loss aims to ensure that both the initial and final refined segmentation maps output by the network accurately approximate the real land-sea distribution. Binary cross-entropy loss is used to measure the pixel-level difference between the prediction and the ground truth label. For a batch of samples, this loss is calculated as follows:
[0100]
[0101] in, The main segmentation loss, This is the initial segmentation probability map output by the decoder. This is the final output after boundary repair processing, i.e., the final segmentation map. For true binary labels, This represents the sigmoid activation function. This is the binary cross-entropy loss. The third term encourages consistency between the initial segmentation and the final output, acting as an internal regularization mechanism.
[0102] The edge detection loss is designed to explicitly guide the network to learn the features of the land-sea boundary. Therefore, it is necessary to supervise the output of the edge prediction head to make it tend to predict the correct land-sea boundary. Since the number of edge pixels is much smaller than that of non-edge pixels in the land-sea segmentation task, there is a serious class imbalance problem between the boundary and non-boundary. The edge detection loss specifically uses the weighted binary cross-entropy loss (BCE loss) to alleviate the class imbalance problem. As shown in Table 1, the positive sample weights and global scaling coefficients of the binary cross-entropy (BCE) for each loss are summarized.
[0103] Table 1. Weight Configuration Table for Composite Loss Function
[0104]
[0105] The edge detection loss is broken down into "primary edge scale edge1" and "auxiliary edge scale edge1" according to the supervision scale in Table 1. 2~4 "Two terms. The positive sample weights for both terms are set to 0.85 to alleviate the class imbalance caused by the fact that there are far fewer pixels at the land-sea boundary than at the non-boundary, forcing the network to focus on sparse edge regions. Among them, the main edge scale term directly affects the edge prediction at the finest scale, with a global scaling factor set to 1.0; the auxiliary edge scale term affects the deep, low-resolution edge prediction as an auxiliary supervision signal, with a global scaling factor set to 0.25 to avoid interfering with the main supervision target."
[0106] The formula for calculating edge detection loss is as follows:
[0107]
[0108] in, This is the edge detection loss, where edge1~edge4 represent edge prediction maps at different scales. It is a binary edge mask generated from the real label distance map. This indicates a binary cross-entropy loss with a positive sample weight set to 0.85. For deep edge outputs, a downsampled true edge mask is used for supervision, with a weight coefficient of 0.25 to ensure focus on major edges. This indicates downsampling, which involves downsampling the real labels to the same spatial resolution as the prediction maps at each layer through progressive downsampling, thereby calculating pixel-level loss.
[0109] The design basis for the direction prediction loss is as follows: the boundary repair module relies on the direction prediction map to perform anisotropic boundary smoothing. This invention constructs the direction prediction task as an 8-class classification problem (corresponding to 8 discrete directions) and uses cross-entropy loss (CE) as the direction prediction loss to supervise the output of the direction prediction head.
[0110]
[0111] in, For the orientation prediction loss, an 8-direction classification loss is calculated only at the real edge pixels, specifically used to train the orientation prediction branch in the network so that it can accurately infer the local orientation of the land-sea boundary. It is the 8-channel radiation pattern output by the direction prediction head. It is a true orientation label map. The loss is calculated only at true edge pixels; labels in non-edge regions are ignored, ensuring that the network learns meaningful geometric context only in boundary regions. This refers to cross-entropy loss. Direction prediction is modeled as an 8-class classification problem, thus imposing a high gradient penalty on incorrect predictions and forcing the network to learn the correspondence between edge texture and direction.
[0112] The design purpose of multi-scale deep supervision loss is to alleviate the gradient vanishing problem and promote the learning of meaningful representations by intermediate layers of the network. To this end, this invention introduces deep supervision at multiple layers of the decoder, specifically through low-resolution segmentation prediction (segmentation prediction). 2~5 This multi-scale depth supervision loss is achieved by applying an auxiliary binary cross-entropy loss to the input.
[0113]
[0114] in, To achieve multi-scale deep supervision loss, auxiliary segmentation supervision is applied at different resolution levels of the decoder to alleviate gradient vanishing and promote feature learning. Corresponding to the Layer segmentation prediction ( (for the bottleneck layer) This indicates that the real label will be downsampled to the same level as the actual label. Same spatial dimensions. All auxiliary losses are weighted at 0.25 and included in the total loss to ensure the main output layer ( ) still dominates.
[0115] The multi-scale depth supervision loss is described in Table 1 as "Multi-scale Supervision". The function is applied to the segmentation prediction map output by the intermediate layer of the decoder. The positive sample weight is 1.0, and the global scaling factor is set to 0.25 to alleviate the gradient vanishing problem while ensuring that the supervision signal of the main output layer dominates.
[0116] Ultimately, the overall objective function for model training is the weighted sum of all the loss terms mentioned above.
[0117]
[0118] in, The total loss is calculated by adding the four losses mentioned above (including marginal losses). (The coefficient of 0.25 is already included, so no additional weighting is needed).
[0119] Step S3: Input the SAR image to be tested into the trained network model to obtain the final coastline extraction result.
[0120] After the model training is complete, the SAR image of the coastline to be extracted and the corresponding generated SAM binarized pre-labels are input into the trained model. In the network, a high-precision land-sea segmentation probability map is output through forward propagation calculation, and then the coastline vector is extracted.
[0121] To verify the effectiveness and advancement of the present invention, the technical effects of the present invention will be described in detail below with reference to specific experimental data.
[0122] For the experimental data, the dataset used in this experiment consists of 4194 image patches. The data sources include the Sea-Land Segmentation v1.1 dataset from the Sentinel-1 public dataset, such as... Figure 5 As shown, and images of Hainan Island, China captured by the Gaofen-3 satellite (GF-3), such as... Figure 6 As shown in Table 2, 2935 image patches were used for model training, 839 for model validation, and 420 for model testing. Detailed parameters of the dataset are shown in Table 2.
[0123] Table 2 Data Sources
[0124]
[0125] For the experimental design, all experiments in this section were conducted in the same hardware and software environment, and all models to be evaluated used the same data partitioning and preprocessing procedures. The main evaluation metrics include: precision, recall, F1 score, overall accuracy, intersection-over-union ratio (IoU), and mean intersection-over-union ratio (mIoU).
[0126] First, to verify the feasibility of using the binarized pre-labels generated and post-processed by the SAM2 model as supervisory signals, a SAM pre-label accuracy verification experiment was set up. The experimental method was as follows: the binary pre-labels directly generated and post-processed by SAM2 were compared with all ground truth labels on the dataset, and the accuracy of the pre-labels was quantitatively evaluated by calculating the difference in indicators between the two.
[0127] Secondly, to demonstrate the superior overall performance of this invention, comparative experiments were conducted. The complete S²C-Net method proposed in this invention was compared with current mainstream and advanced semantic segmentation models, including DeepLabV3+, PSPNet, Segformer, and CBRnet.
[0128] Finally, to explore the most significant improvement in model performance from introducing SAM prior features and to verify the necessity of the SAM color mask binarization step, ablation experiments were conducted. To investigate the optimal way to introduce SAM prior features and verify the necessity of binarizing the SAM color mask, we designed four ablation experiment configurations, comparing input types during training and testing: Configuration A: During training, binarized SAM pre-labels are input to the SAM encoder; no SAM features are input during testing. Configuration B: During training, a color mask directly generated by SAM (without binarization) is input to the SAM encoder; no SAM features are input during testing. Configuration C: During training, binarized SAM pre-labels are input to the SAM encoder; binarized labels are also input during testing—this is the complete scheme proposed in this paper. Configuration D: Input the SAM color mask into the SAM encoder during training, and continue inputting the color mask during testing.
[0129] By comparing the performance differences of these four configurations under the same test conditions, the optimal input form of SAM features can be determined, and the contribution of binarization preprocessing to the final segmentation accuracy can be evaluated.
[0130] Regarding the setting of experimental parameters, this invention The model was trained on hardware equipped with an RTX 5080 GPU. The initial training epochs were set to 150, and the initial learning rate was set to... Using the Adam optimizer, the minimum learning rate is set to The batch size is set to 4. The training process employs a dynamic learning rate adjustment and early stopping strategy: if the model performance does not improve for 5 consecutive training epochs, the learning rate is adjusted to 0.7 times the current value; if the performance does not improve for 20 consecutive training epochs, training is terminated early.
[0131] The quantitative comparison results of the SAM pre-label accuracy verification results and the pre-labels obtained by binarizing the SAM color mask with the manually labeled true labels are shown in Table 3.
[0132] Table 3 Quantitative Analysis of SAM Color Mask Binarization Effect
[0133]
[0134] Experimental results show that the post-processed SAM pre-labels (SAM color mask binarized pre-labels) achieve over 83% accuracy across all evaluation metrics, with recall and precision both exceeding 92%. This result validates that SAM pre-labels have good initial segmentation performance for land and sea regions, providing effective initial supervision information for subsequent network training. The labeling effect is as follows: Figure 7As shown.
[0135] For comparative experimental results, the Hainan Island dataset and the Sea-Land Segmentation v1.1 dataset were used to demonstrate the results of this invention. A comparative experiment was conducted with mainstream semantic segmentation methods such as DeepLabV3+, PSPNet, Segformer, and CBRnet. The results are shown in Table 4.
[0136] Table 4 Comparative experimental results with advanced methods
[0137]
[0138] Experimental results show that the invention proposed It achieved optimal performance across all six evaluation metrics, comprehensively validating its superiority as a new paradigm for land-sea segmentation using SAR imagery. Specifically, The method achieved 95.63% and 95.80% respectively in IoU and mIoU, the core metrics for measuring segmentation overlap accuracy. These figures represent improvements of 1.94% and 1.54% compared to the second-best performing DeepLabV3+ model, indicating a higher degree of spatial agreement between the segmentation results and real-world features. Furthermore, the F1 score, which comprehensively measures accuracy and recall, also showed improvement. With a success rate of 97.55%, it outperforms other comparative models, demonstrating a better balance between "comprehensive search" and "accurate search".
[0139] It is particularly noteworthy that While maintaining a high precision (97.79%), its recall (97.69%) was also the highest among all models. This indicates that, thanks to the strong semantic prior guidance provided by SAM pre-labels and the enhanced extraction of SAR features by the dual-branch fusion encoder, the model of this invention can more completely identify land and sea areas in the image, effectively reducing missed detections, which is crucial for ensuring the continuity and integrity of the coastline. Although the Segformer model is closest to this invention in terms of precision (97.05%), its recall and IoU are significantly different, further highlighting the limitations of models that rely solely on the Transformer architecture without incorporating domain prior knowledge when dealing with complex scattering features of SAR images.
[0140] In summary, the comparative experiments strongly demonstrate that S²C-Net achieves more accurate and robust land-sea segmentation performance by synergistically utilizing prior visual models and domain-adaptive design. The comparative experimental results are as follows: Figure 8 As shown.
[0141] For the ablation experiment results, the ablation experiment was carried out according to the four control configurations mentioned above, and the quantitative results are shown in Table 5.
[0142] Table 5. Quantitative comparison of ablation experiments with different input feature forms.
[0143]
[0144] To explore which form of SAM prior is most effective, we compared two training methods: directly inputting the original SAM color mask and inputting a post-processed binary mask. Experimental results show that inputting the SAM binary mask (i.e., SAM pre-labels) instead of the color mask during testing yields higher recall. When training without inputting the SAM binary map, inputting the SAM color mask into the SAM prior encoder achieves higher accuracy. On one hand, the RGBA format of the SAM color mask contains richer geographic information; on the other hand, while some information is lost during SAM binarization, this binarization is still considered necessary. Redundant and noisy information contained in the color mask may interfere with network learning; introducing it additionally during testing has limited accuracy improvement. The binary mask provides a clearer, more geographically constrained semantic region segmentation prior, which is more conducive to the network focusing on learning land-sea boundaries.
[0145] The top-performing model (trained with SAM binary maps + prediction) showed a slight decrease in precision compared to the version trained solely with SAM binary maps but not used during testing, but achieved a more significant improvement in recall. Introducing the SAM prior during testing tends to detect more true positive samples, although it introduces a small number of additional false positives. However, from an application perspective, avoiding false negatives is more important than false positives in land-sea segmentation tasks, as the former helps maintain the integrity of the coastline structure. Therefore, this trade-off of slightly reduced precision for significantly improved recall and other metrics is positive and acceptable, reflecting an enhanced overall reliability of the model's segmentation.
[0146] In the optimal configuration using SAM binary input during testing, the IoU improved by 1.49% and the F1 score improved by 1.09% compared to not using SAM. This demonstrates that utilizing the zero-shot prior knowledge of SAM as additional semantic guidance can effectively compensate for the lack of SAR image annotation data, giving the model stronger feature representation and generalization capabilities.
[0147] Ablation test results as follows Figure 9 As shown.
[0148] When both training and prediction use SAM pre-labels, the model achieves the best results in extracting land-sea boundaries (as shown in the first row). Without the guidance of SAM binary maps, the lack of boundary awareness leads to a large number of false detections (as shown in the second, third, and fourth rows). Comparing the third and fourth rows, as well as the first and second rows, inputting each type of SAM feature into the SAM prior encoder reduces the false detection rate. It should be noted that the structure of the SAM encoder remains unchanged; only the SAM pre-labels use grayscale (single-channel) input, while the input SAM raw features use four channels (RGBA), and subsequent 1x1 convolutions maintain consistent output dimensions. This further verifies the effectiveness of introducing SAM prior semantics and designing the SAM prior encoder. It is observed that after dual optimization through SAM prior knowledge injection and boundary refinement modules, the precision is improved compared to manually labeled ground truth labels.
[0149] In summary, the system's experiments have demonstrated from multiple dimensions that: using SAM for pre-training or feature injection can effectively improve model performance; the designed SAM prior encoder and fusion module can efficiently utilize prior information; the binarized SAM prior is superior to the original color mask; and the complete S²C-Net framework has a significant effect on label optimization and is superior to existing state-of-the-art methods.
[0150] Finally, it is necessary to state that the above embodiments are only used to further illustrate the technical solution of the present invention in detail, and should not be construed as limiting the scope of protection of the present invention. Any non-essential improvements and adjustments made by those skilled in the art based on the above content of the present invention shall fall within the scope of protection of the present invention.
Claims
1. A method for extracting coastlines from SAR images, characterized in that, Includes the following steps: Step S1: Input the original SAR image into the pre-trained visual base model to generate a set of color masks; For each mask, an ocean confidence score is calculated based on its area and color diversity. The mask with the highest score is identified as an ocean region, and the remaining masks are identified as land regions. The resulting initial segmentation map is post-processed to ensure mask balance and geographic continuity, resulting in a land-sea binarized pre-label. Step S2: Construct a dual-branch fusion encoder network, using the original SAR image and the land-sea binarized pre-labels as dual inputs; the network includes: a main visual encoder for extracting multi-scale visual features of the SAR image; a SAM prior encoder for extracting multi-scale spatial prior features of the land-sea binarized pre-labels; adaptively fusing visual features and prior features at the same scale at multiple scales to obtain fused features; inputting the fused features into the decoder to generate segmentation prediction maps and edge prediction maps from coarse to fine; performing direction-aware boundary repair on the preliminary segmentation probability map to obtain the final segmentation map; Step S3: Input the SAR image to be tested into the trained network, and output the coastline extraction result; the visual base model is the SAM2 model; the ocean confidence score mentioned in step S1 Calculate using the following formula: ; in, Let the pixel area of the k-th mask be . The maximum area among all masks. The color richness of the area covered by the k-th mask; To maximize the richness of color variety; and To control the hyperparameters of the two weights.
2. The extraction method according to claim 1, characterized in that: In step S2, the main visual encoder uses a pre-trained VGG-16 network with feedforward convolutional layers to output visual features at five scales, with the number of channels being 64, 128, 256, 512, and 512 respectively. The SAM prior encoder is a lightweight convolutional neural network consisting of five convolutional blocks. Each convolutional block includes a max pooling layer with a stride of 2 and a two-dimensional convolutional layer, outputting prior features at five scales, with the number of channels being 16, 32, 64, 64, and 64 respectively.
3. The extraction method according to claim 1, characterized in that: The adaptive fusion method described in step S2 is as follows: for the first Each scale will define visual features with prior features After concatenation along the channel dimension, dimensionality reduction is performed through a 1×1 convolutional layer, followed by batch normalization and ReLU activation to obtain the fused features. : ; in, For fusion function, It is the first Visual features output by the main visual encoder at each scale The number of channels, It is the first Prior features output by the SAM prior encoder at each scale The number of channels, and These represent batch normalization and linear activation functions, respectively. Represent a The convolutional layer.
4. The extraction method according to claim 1, characterized in that: In step S2, after generating a coarse segmentation prediction at the bottleneck layer, the decoder performs a four-level upsampling operation. At the k-th level, the features upsampled at the previous level are concatenated and convolved with the fused features at the corresponding scale to obtain the current level decoding features, where k ranges from 1 to 4. The current level decoding features are fed into the segmentation optimization head and the edge prediction head, respectively. The segmentation optimization head generates the current level segmentation prediction map by combining the upsampled results of the previous level segmentation prediction, and the edge prediction head generates the current level edge prediction map.
5. The extraction method according to claim 1, characterized in that: The direction-aware boundary repair in step S2 specifically includes: binarizing the edge prediction map corresponding to the preliminary segmentation probability map to obtain a boundary mask; using a lightweight direction head to predict an 8-channel direction map corresponding to 8 discrete directions from the decoded features; using a directional convolution kernel with fixed parameters to perform direction-aware context aggregation on the preliminary segmentation probability map within the boundary mask area, and combining it with the attention weights of the direction map to generate a boundary optimization signal; fusing the boundary optimization signal with the original segmentation prediction outside the boundary mask area to obtain the final segmentation map.
6. The extraction method according to claim 1, characterized in that: The network training in step S2 uses a composite loss function. Optimize: ; in, The main segmentation loss, For edge detection loss, To predict the loss in the direction, This represents the loss for multi-scale depth supervision.
7. The extraction method according to claim 6, characterized in that: The edge detection loss Calculate using the following formula: ; in, This is the edge prediction map corresponding to the initial segmentation probability map. This is the edge prediction map output by the k-th decoding layer. The binary edge mask is generated from the real label distance map. The weighted binary cross-entropy loss is set to 0.85 for positive samples. This is to indicate downsampling.
8. The extraction method according to claim 6, characterized in that: The direction prediction loss Calculated only at the actual edge pixels: ; in, This is the 8-channel radiation pattern output by the direction prediction head. This is a real-world orientation label image. Cross-entropy loss; The multi-scale depth supervision loss Calculate using the following formula: ; in, For binary cross-entropy loss, This is the segmentation prediction map output by the k-th decoding layer. For downsampling operation, The label is a true binary label.
9. The extraction method according to claim 1, characterized in that: The mask balance and geographic continuity post-processing in step S2 includes: checking the connectivity of land and ocean regions through connected component analysis and calculating the area ratio; if the area ratio of any category is lower than a set threshold, merging heterogeneous connected domains adjacent to the main category region into the main category region; merging isolated land islands surrounded by major water bodies, and merging small water bodies embedded in large landmasses into land.
Citation Information
Patent Citations
DEM-based small-scale tidal flat image processing method
CN117423002A
Variable window sliding segmentation driven SAR water depth inversion method
CN119644329A