A single-band SAR image water body recognition method based on an improved UNet network and a local mean ratio
By using an improved UNet network and Local Mean Ratio (LMR) exponential map for adaptive threshold segmentation, combined with learnable edge enhancement, multi-scale dilated convolution, and spatial attention modules, an end-to-end water body recognition framework is constructed. This framework solves the problems of high annotation cost, high false detection rate, and loss of detail in water body recognition of single-band SAR images, and achieves high-precision and fast water body recognition.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA YANGTZE POWER
- Filing Date
- 2026-03-31
- Publication Date
- 2026-06-05
AI Technical Summary
Existing single-band SAR imagery water body identification technology is difficult to achieve high-precision, fast-response, and cross-scene adaptive water body identification in emergency response scenarios. It suffers from problems such as high annotation costs, high false detection rate of water body boundaries, and loss of detailed information.
An improved UNet network and Local Mean Ratio (LMR) exponential map adaptive thresholding are adopted, combined with a learnable edge enhancement module, multi-scale dilated convolution and spatial attention module, to build an end-to-end water body recognition framework. The model is optimized by a hybrid loss function and an early stopping mechanism.
It achieves automated initial screening of water body masks, reduces manual fine-tuning workload, improves the positioning accuracy and identification integrity of water body boundaries, meets the needs of rapid and accurate emergency response, and adapts to different terrain scenarios.
Smart Images

Figure CN122156997A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of remote sensing image processing and computer vision technology, specifically to a method for water body identification based on a single-band SAR image using an improved UNet network and local mean ratio. Background Technology
[0002] Synthetic Aperture Radar (SAR), with its all-weather, day-and-night imaging capabilities, plays an irreplaceable role in emergency response scenarios such as flood disaster assessment, water resource management, and land mapping. Single-band SAR imagery, as the most widely acquired remote sensing data source, forms the core foundation for water body identification in these applications. In practical engineering, when sudden floods strike and emergency management departments require the submission of water inundation maps of key areas within half an hour to deploy rescue forces, engineers often only have access to the single-band SAR imagery of the day. Lacking readily available pixel-level water body labels and with no time to organize a professional team for manual interpretation, they must rely on automated models for identification. This scenario reveals the core requirement of single-band SAR water body identification technology in engineering applications: achieving high-precision, fast-response, and cross-scenario adaptive water body identification under conditions of lacking real-time annotation and inability to rely on multi-source data.
[0003] Existing single-band SAR image water body identification technologies are mainly divided into two categories: traditional thresholding methods and deep learning methods. However, both methods have insurmountable engineering limitations.
[0004] Traditional thresholding methods, such as the Otsu method, set segmentation thresholds based on the physical characteristic of low backscattering in water bodies. While fast, their accuracy is limited. The literature "Research on Water Body Extraction from SAR Images Based on Laplacian Edge Enhancement" points out that traditional thresholding methods in urban areas easily misidentify low-backscattering features such as asphalt roads and dry bare soil as water bodies. Furthermore, they are sensitive to speckle noise, making it difficult to balance noise suppression and edge preservation, resulting in severely jagged water body boundaries. While such methods can meet timeliness requirements in emergency scenarios, their recognition accuracy is insufficient to support rescue decision-making.
[0005] Deep learning methods, exemplified by the U-Net encoder-decoder structure, have achieved higher recognition accuracy. The paper "MAFUNet: water body segmentation algorithm for SAR images combining attention mechanisms and active contour loss" (Acta Geodaetica et Cartographica Sinica) discloses a scheme integrating spatial attention modules and multi-scale convolutional pooling modules into U-Net, aiming to improve the continuity of water body boundaries. However, this type of method relies on a large number of pixel-level labeled samples for fully supervised training. Single-band SAR images are affected by speckle noise, making manual visual interpretation difficult, time-consuming, and labor-intensive, and the labeling cost increases linearly with region. The paper "A point-supervised SAR image water body extraction method based on prior selection region loss" (CN121074702A) attempts to reduce labeling costs by using weak point label supervision, but the initial mask generated still relies on manual refinement, and the representativeness of the point labels is difficult to guarantee in complex terrain. The aforementioned deep learning methods have led to a dilemma in engineering practice: each scene requires a separate training process. Every time a new SAR image of a scene is processed, several hours or even days are needed to re-label samples and retrain the model, which cannot meet the timeliness requirements of emergency response.
[0006] At the model structure level, existing research has attempted to improve the accuracy of water body boundaries through edge enhancement. The paper "Research on Water Extraction from SAR Images Based on Laplacian Edge Enhancement" discloses a scheme using a fixed Laplacian operator for edge enhancement. However, its disclosed technical difficulties indicate that while the fixed operator enhances water body edges, it simultaneously amplifies interference such as shadows and building edges, leading to an increased false detection rate. The paper "Enhancing Water Extraction for Dual-Polarization SAR Images Based on Adaptive Feature Fusion and Hybrid MLPNetwork" (Song et al., IEEE J-STARS, 2025) further reveals that single-band SAR images lack polarization information, making it difficult to distinguish water bodies from low-backscattering features in terms of grayscale distribution. Simple edge enhancement cannot fundamentally solve the false detection problem in urban areas. This indicates that existing edge enhancement methods lack "selectivity" and cannot distinguish between water body edges and interference edges.
[0007] In multi-scale feature extraction, existing techniques expand the receptive field through dilated convolution to ensure the continuity of recognition for large water bodies. However, the active contour loss function optimization scheme disclosed in the paper "MAFUNet" suggests that the inherent "mesh effect" of dilated convolution can lead to the loss of local detail information, especially in small rivers and water body edge regions, where detail recovery is difficult. Furthermore, existing methods treat sample construction, network training, and model deployment as a linear pipeline, with each stage optimized independently. They lack a closed-loop mechanism to feed back prior knowledge generated during sample construction (such as statistical information and area distribution patterns in the LMR index) to the training stage. This results in engineers having to re-label and retrain the model if it performs poorly in a new region, trapped in a cycle of labeling-training-deployment-re-labeling, failing to achieve the "ready-to-use" engineering goal.
[0008] In summary, existing technologies face three major engineering challenges: the disconnect between automatic sample generation and model training leads to high annotation costs; the coexistence of water body boundary enhancement and interference edge amplification results in high false detection rates in urban areas; and the mutual exclusion between multi-scale feature extraction and local detail preservation makes small water bodies prone to missed detection. Therefore, there is an urgent need for an end-to-end framework that can bridge the "sample-model-deployment" closed loop, enabling cross-scenario adaptive and low-human-intervention engineered water body identification while ensuring accuracy. Summary of the Invention
[0009] The purpose of this invention is to provide a method for water body identification in single-band SAR images based on an improved UNet network and local mean ratio, so as to solve the problems mentioned in the background art.
[0010] To achieve the above objectives, the present invention provides the following technical solution:
[0011] A method for water body identification based on a single-band SAR image using an improved UNet network and local mean ratio includes the following steps: Step S1: Acquire the single-band SAR image to be identified and calculate the local mean ratio (LMR) index map of the image; Step S2: Based on the statistical characteristics of the LMR index map, adaptive threshold segmentation is performed to obtain a preliminary binary image; the preliminary binary image is processed by adaptive morphological filtering based on weighted average area to extract the main water bodies and fill the holes, and then combined with manual interactive refinement to generate a ground truth mask for water bodies and construct a training dataset. Step S3: Construct an improved SARUNet network model; the SARUNet network model is an encoder-decoder structure, with an edge enhancement module at the input end, a multi-scale dilated convolution module at the bottleneck layer connecting the encoder and decoder, and a spatial attention module at the decoder output. Step S4: Train the SARUNet network model using the training dataset, calculate the loss using a hybrid loss function, and backpropagate to update the parameters; Step S5: Input the single-band SAR image to be tested into the trained SARUNet network model, output the water body prediction probability map, and obtain the final water body identification result after binarization processing.
[0012] Furthermore, the specific formula for calculating the local mean ratio (LMR) index in step S1 is as follows: in, This represents the global pixel mean of the entire single-band SAR image. This represents the local pixel mean within a sliding window centered on the current pixel. To prevent the use of tiny constants in division by zero, a block-based calculation strategy is adopted for large-size images. The image is cropped into fixed-size blocks, LMR is calculated separately for each block, and then the images are stitched back to the original size.
[0013] Furthermore, the specific steps of adaptive threshold segmentation based on the statistical characteristics of the LMR exponential graph in step S2 include: Calculate the pixel mean of the LMR index map of the entire image. and standard deviation ; Using formula
[0014] Calculate the segmentation threshold ,in The preset adjustable coefficient is preferably set to 1.5~2.5, and can be adjusted according to the image noise level. Using the threshold The LMR index map is binarized to obtain a preliminary binary image.
[0015] Furthermore, the specific steps of processing using adaptive morphological filtering based on weighted average area described in step S2 include: The main water body adaptive extraction stage involves: identifying all independent connected water body regions in the preliminary binary image and calculating the area of each region; calculating a first weighted average area threshold based on the area of all water body regions, where the first weighted average area threshold is the sum of the products of the area of each region and its area ratio; dynamically retaining water body regions with an area greater than or equal to the first weighted average area threshold and filtering out regions with an area less than the threshold, so as to adaptively retain the main water bodies and remove noise patches. Adaptive Hole Filling Stage: Identify all closed holes inside the water area in the image after the above processing, and calculate the area of each hole; calculate a second weighted average area threshold based on the area of all holes; dynamically fill holes with areas smaller than the second weighted average area threshold to adaptively fill fine voids and preserve large real holes.
[0016] Furthermore, the calculation formulas for the first weighted average area threshold and the second weighted average area threshold are both: in, The weighted average area threshold is calculated as follows. This represents the total number of target regions in the current image. For the first The area of each target region For all The sum of the areas of each target region.
[0017] Furthermore, the edge enhancement module described in step S3 includes a convolutional layer whose kernel weights are initialized to Sobel operators and set to be learnable and update during training to adaptively optimize edge detection parameters through training data; the edge enhancement module performs convolution operations on the input image to extract edge features and adds the edge features to the original input image, so that the enhanced image retains both the original grayscale information and the optimized edge information, which is then used as the input to the subsequent encoder.
[0018] Furthermore, the multi-scale dilated convolution module described in step S3 includes four parallel branches: The first branch is a 1×1 convolution; The second branch is a 3×3 dilated convolution with a dilation rate of 3; The third branch is a 3×3 dilated convolution with a dilation rate of 5; The fourth branch is a 3×3 dilated convolution with a dilation rate of 7; The parallel dilated convolutional branches with dilation rates of 3, 5, and 7, together with the 1×1 convolutional branch, constitute a multi-scale receptive field extraction structure. The outputs of the four branches are concatenated in the channel dimension and feature fusion is performed through a 1×1 convolutional layer to expand the receptive field while preserving the local details of the feature map.
[0019] Furthermore, the specific operation of the spatial attention module described in step S3 is as follows: The input feature map is subjected to global max pooling and global average pooling in the channel dimension to obtain two single-channel feature maps. The two single-channel feature maps are concatenated, passed through a 7×7 convolutional layer and a Sigmoid activation function, to generate a spatial attention weight map; The spatial attention weight map is multiplied element-wise with the input feature map.
[0020] Furthermore, the hybrid loss function described in step S4 Due to binary cross-entropy loss and Dice loss The weighted composition is calculated using the following formula: in and These are the weight coefficients; the output layer of the network model outputs Logits values through 1×1 convolutions, directly participating without Sigmoid activation. The calculation, and the Sigmoid activation process, are then involved. calculate.
[0021] Furthermore, the training process in step S4 also includes: Calculate the global mean and global standard deviation of the training data, and perform global normalization on the image data before inputting it into the network; During training, the F1 score on the validation set is monitored. If the F1 score does not improve or shows a downward trend within a preset number of rounds, the early stopping mechanism is triggered to terminate training and save the best model parameters.
[0022] Furthermore, the edge enhancement module, the multi-scale dilated convolution module, and the spatial attention module work together, wherein: the edge enhancement module is used to enhance the water body edge features to improve the boundary positioning accuracy; the multi-scale dilated convolution module is used to expand the receptive field to maintain the continuity of large water body identification; and the spatial attention module is used to suppress speckle noise to focus on the water body area. Together, the three achieve refined water body identification of single-band SAR images.
[0023] Furthermore, the LMR index map and the weighted average area adaptive morphological filter form a collaborative mechanism for automated sample construction, wherein: the LMR index map is used to enhance the contrast between the water body and the background to improve the quality of the initial binary image, and the weighted average area filter is used to adaptively filter the water body connected regions and fill holes based on the image content. The two work together to generate a high-quality water body ground truth mask, reducing the amount of manual retouching work.
[0024] Compared with the prior art, the beneficial effects of the present invention are: 1. This invention achieves automated initial screening of water body masks through LMR index calculation, adaptive threshold segmentation, and innovative weighted average area adaptive morphological filtering. The LMR index map significantly enhances the contrast between water and background, resulting in higher quality preliminary binary images. The weighted average area filtering adaptively calculates area thresholds based on image content, dynamically selecting connected regions in the water body and filling holes, eliminating the need for preset fixed area thresholds. This adapts to SAR images of different resolutions and terrains, significantly reducing manual retouching workload. Combined with interactive annotation tools, it ensures high accuracy and consistency of the final samples.
[0025] 2. The improved SARUNet network constructed in this invention effectively suppresses speckle noise in single-band SAR images through the synergistic effect of learnable Sobel edge enhancement, multi-scale dilated convolution, and spatial attention mechanisms. Specifically, the learnable Sobel edge enhancement module strengthens water body boundary features at the input, the multi-scale dilated convolution module expands the receptive field at the bottleneck layer to maintain the continuity of large water bodies, and the spatial attention module focuses on the water body region and suppresses background noise at the decoder output. These three components form a complete processing chain of "edge perception - context perception - region focusing," significantly improving the localization accuracy and recognition completeness of water body boundaries.
[0026] 3. This invention combines global normalization, a hybrid loss function (a weighted combination of binary cross-entropy loss and Dice loss), and a strict early stopping mechanism with multiple indicators during training. This effectively prevents model overfitting and improves the model's generalization ability and stability on different SAR data. By monitoring the F1 score on the validation set, training is automatically terminated, ensuring that the model is saved when its performance is optimal, thus avoiding the blindness of manual intervention.
[0027] 4. This invention, through the collaborative sample construction mechanism of LMR exponent and weighted average area filtering, as well as the collaborative design of network modules, enables the model to maintain stable recognition performance in different terrain scenarios such as urban areas, mountains, and plains, achieving the engineering goal of "ready to use" and meeting the urgent need for rapid and accurate water body identification in emergency response scenarios. Attached Figure Description
[0028] Figure 1 This is a flowchart illustrating the overall technical process of the SAR water body identification method of the present invention.
[0029] Figure 2 Comparison of the original SAR image and the mask image generated by LMR.
[0030] Figure 3 A schematic diagram of the improved SARUNet network structure.
[0031] Figure 4 This is a detailed diagram of the internal structure of the edge enhancement module and the multi-scale dilated convolution module.
[0032] Figure 5 This is an example of the water extraction results of the method of the present invention on a single-band SAR image. Detailed Implementation
[0033] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0034] The method in this embodiment is executed by a terminal, which can be a mobile phone, computer, PDA, laptop or desktop computer, etc. Of course, it can also be other devices with similar functions, and this embodiment does not limit them.
[0035] Example 1 This embodiment provides a method for water body identification based on a single-band SAR image using an improved UNet network and local mean ratio.
[0036] See Figure 1 The above is a flowchart of the overall technical process of the SAR water body identification method of the present invention. The method mainly includes the following steps: Step S1: Acquire the single-band SAR image to be identified and calculate the LMR index map; Step S2: Construct a training dataset based on the LMR exponential graph; Step S3: Construct the improved SARUNet network model; Step S4: Train the SARUNet network model using the training dataset; Step S5: Input the single-band SAR image to be tested into the trained SARUNet network model to output the water body identification result.
[0037] Step S1: LMR index calculation Acquire the single-band SAR image to be identified; this image is a single-channel grayscale image. Calculate the global pixel mean of the entire image. For large images, a block-based calculation strategy is adopted, cropping the image into fixed-size (e.g., 256×256 pixels) tiles. For each tile, a sliding window (e.g., a 3×3 or 5×5 window) is used to calculate the pixel mean within the local window of each pixel. The LMR index graph is calculated using the following formula:
[0038] in, To prevent the use of tiny constants that divide by zero, the LMR index maps calculated from each patch are stitched back to their original dimensions to obtain a complete LMR index map, as shown below. Figure 2 As shown, the original SAR image is compared with the LMR-generated mask image. It can be seen that the LMR index image significantly enhances the contrast between the water body and the background.
[0039] Step S2: Training Dataset Construction The training dataset is constructed based on the LMR exponential map. First, the pixel mean of the LMR exponential map of the entire image is calculated. and standard deviation Using the formula Calculate the segmentation threshold T, where k is a preset adjustable coefficient, for example, k=1.5. Use this threshold T to binarize the LMR exponential map to obtain a preliminary binary image.
[0040] Subsequently, the preliminary binary image undergoes adaptive morphological filtering based on weighted average area. Specifically, this includes: The main water body adaptive extraction stage involves identifying all independent connected water body regions in the preliminary binary image and calculating the area of each region. The first weighted average area threshold is calculated based on the area of all water bodies. The calculation formula is as follows:
[0041] Where N represents the total number of interconnected water regions. The sum of the areas of all water bodies, with a dynamically retained area greater than or equal to... In water bodies, areas smaller than a certain threshold are filtered out to adaptively retain the main water body and remove noise patches.
[0042] Adaptive hole filling stage: Identify all closed holes within the water area in the image after the above processing, calculate the area of each hole, and calculate the second weighted average area threshold using the same formula. The dynamic filling area is smaller than The holes are designed to adaptively fill tiny voids while preserving large, realistic holes.
[0043] Interactive tools, such as annotation tools developed based on the Napari framework, are used to manually refine the processed binary images, generating ground truth masks for water bodies. The original single-band SAR images and the corresponding ground truth masks together form a training dataset. Based on the water body ratio of each tile, stratified sampling is performed to divide the dataset into training and validation sets, for example, an 8:2 ratio.
[0044] Step S3: SARUNet Network Model Construction An improved SARUNet network model is constructed, which is an encoder-decoder structure. For example... Figure 3 The diagram shown is a schematic of the improved SARUNet network structure.
[0045] Edge Enhancement Module: An edge enhancement module is set at the input. This module contains a convolutional layer whose kernel weights are initialized with Sobel operators and configured to be learnable and update during training to adaptively optimize edge detection parameters using training data. This module performs convolution operations on the input image to extract edge features and adds these features to the original input image. This results in an enhanced image that retains both the original grayscale information and the optimized edge information, serving as the input for the subsequent encoder. Figure 4 The image shows the internal structural details of the edge enhancement module.
[0046] Encoder: The encoder contains multiple downsampling modules, each consisting of two 3×3 convolutional layers and one 2×2 max pooling layer, with the number of channels doubling layer by layer (e.g., 32→64→128→256).
[0047] Multi-scale dilated convolution module: A multi-scale dilated convolution module is set at the bottleneck layer connecting the encoder and decoder. This module contains four parallel branches: the first branch is a 1×1 convolution; the second branch is a 3×3 dilated convolution with a dilation rate of 3; the third branch is a 3×3 dilated convolution with a dilation rate of 5; and the fourth branch is a 3×3 dilated convolution with a dilation rate of 7. The parallel dilated convolution branches with dilation rates of 3, 5, and 7, together with the 1×1 convolution branch, constitute the multi-scale receptive field extraction structure. The outputs of the four branches are concatenated along the channel dimension and fused through a 1×1 convolutional layer to expand the receptive field while preserving the local details of the feature map, such as... Figure 4 The image shows the internal structural details of a multi-scale dilated convolution module.
[0048] Decoder: The decoder contains multiple upsampling modules. Each module enlarges the feature map size by 2 times through deconvolution (transposed convolution), and performs skip connections and splicing with the feature maps of the corresponding layers of the encoder. The features are then fused through two 3×3 convolutional layers.
[0049] Spatial Attention Module: A spatial attention module is set at the decoder output. This module performs global max pooling and global average pooling on the input feature map along the channel dimension to obtain two single-channel feature maps; the two single-channel feature maps are concatenated and passed through a 7×7 convolutional layer and a sigmoid activation function to generate a spatial attention weight map; the spatial attention weight map is then multiplied element-wise with the input feature map.
[0050] Output layer: The number of channels is reduced to 1 through 1×1 convolution, and the predicted Logits value is output.
[0051] Step S4: Model Training The SARUNet network model was trained using the constructed training dataset. During training, the global mean and global standard deviation of the training data were calculated, and the image data was globally normalized before being input into the network.
[0052] Employing binary cross-entropy loss and Dice loss The weighted mixed loss function is used to calculate the loss, and the calculation formula is as follows:
[0053] in and The weighting coefficient is usually taken as... =0.5. The output layer of the network model outputs Logits values through 1×1 convolutions, directly participating in the network without Sigmoid activation. The calculation, and the Sigmoid activation process, are then involved. calculate.
[0054] Use an optimizer, such as AdamW, to update network parameters, setting an initial learning rate, such as 1e-4, and weight decay. Monitor the F1 score on the validation set during training. If the F1 score does not improve or shows a downward trend within a preset number of epochs, such as 25 epochs, trigger an early stopping mechanism to terminate training and save the optimal model parameters.
[0055] Step S5: Output of water body identification results The single-band SAR image to be tested is input into the trained SARUNet network model, which outputs a water body prediction probability map. After sigmoid activation, it is binarized with a threshold of 0.5 to obtain the final water body identification result, as shown below. Figure 5 The figure shows an example of water body extraction results of the method of the present invention on a single-band SAR image. The F1 score is 0.9460, the precision is 0.9360, the recall is 0.9562, the intersection-over-union ratio is 0.8976, and the overall precision is 0.9817. In the figure, green areas represent correctly identified water bodies, red areas represent false positives, and yellow areas represent missed positives. This demonstrates that the method of the present invention can achieve high-precision water body identification.
[0056] Example 2 This embodiment, based on Embodiment 1, further explains the synergistic effect of the network structure and the synergistic mechanism of sample construction, and provides preferred parameter configurations.
[0057] Regarding the synergistic effect of network modules In this embodiment, the edge enhancement module, the multi-scale dilated convolution module, and the spatial attention module work together to achieve refined water body identification in single-band SAR imagery. Specifically: The edge enhancement module extracts edge features through learnable Sobel convolution kernels and adds the edge features to the original image, enabling the network to obtain enhanced water body boundary information in the initial stage of the encoder, which helps to accurately locate the water body outline.
[0058] The multi-scale dilated convolution module adopts a combination structure of parallel dilated convolution with dilation rates of 3, 5, and 7 and 1×1 convolution in the bottleneck layer. Through multi-scale receptive field extraction, the network can capture rich information from local details to global context, effectively maintaining the recognition continuity of large water bodies, while avoiding the loss of details caused by the dilated convolution mesh effect.
[0059] The spatial attention module generates a spatial attention weight map at the decoder output, which weights the feature map element by element, so that the network focuses on the target water area and suppresses speckle noise and non-water background response.
[0060] The three modules mentioned above form a complete processing chain from "edge perception", "context perception" to "region focusing", working together to improve the boundary accuracy, completeness and noise resistance of water body identification.
[0061] Collaborative mechanisms for sample construction In this embodiment, the LMR exponential map and weighted average area adaptive morphological filtering form a collaborative mechanism for automated sample construction. Specifically: The LMR index map, calculated by the ratio of the global mean to the local mean, significantly enhances the contrast between the water body and the background, resulting in a higher quality preliminary binary image and laying the foundation for subsequent morphological processing.
[0062] Weighted average area filtering adaptively calculates an area threshold based on image content, dynamically filtering connected water regions in the initial binary image to remove noise patches; simultaneously, it dynamically fills closed holes within water regions, filling in minute voids. This filtering method does not require a preset fixed area threshold and can adapt to SAR images of different resolutions and terrains.
[0063] The combined effect of LMR index plot and weighted average area filtering results in higher quality automatically generated samples, significantly reducing the workload of manual refinement while ensuring sample consistency and objectivity.
[0064] Preferred parameter configuration In this embodiment, the following parameter configuration is preferred: LMR index calculation: The preferred sliding window size is 5×5, and the preferred block size is 256×256 pixels; Adaptive threshold segmentation: The adjustable coefficient k is preferably 1.5~2.5, and is adjusted according to the image noise level; Weighted average area filtering: Connected region identification uses 8-connected neighborhoods; Encoder channel count: 32, 64, 128, 256 respectively; Decoder channel counts: 256, 128, 64, and 32 respectively; Weights of the hybrid loss function: =0.5, =0.5; Optimizer: AdamW, initial learning rate 1e-4, weight decay 1e-5; Early stop mechanism: Monitor the F1 score on the validation set, with a patience value of 25 rounds. If there is no improvement for 25 consecutive rounds, training is terminated.
[0065] The above parameters can be adjusted according to the resolution, imaging mode, and application scenario of the actual SAR image, and all can achieve good water body identification results.
[0066] Example 3 The difference between this embodiment and Embodiment 1 is that in the edge enhancement module, the convolution kernel weights are initialized with Prewitt operators instead of Sobel operators. Both the Prewitt and Sobel operators are first-order differential edge detection operators, capable of extracting gradient information from the image. Initializing the convolution kernel with Prewitt operators and setting it to be learnable and update during training also enables edge feature extraction and optimization. The other steps in this embodiment are the same as in Embodiment 1 and will not be repeated here.
[0067] Example 4 The difference between this embodiment and Embodiment 1 is that, in the hybrid loss function, a weighted combination of Dice loss and Focal loss is used instead of the combination of Dice loss and binary cross-entropy loss. Focal loss, by introducing a modulation factor, makes the model pay more attention to hard-to-classify samples, further alleviating the class imbalance problem between water and non-water bodies. The other steps in this embodiment are the same as in Embodiment 1 and will not be repeated here.
[0068] Example 5 The difference between this embodiment and Embodiment 1 is that, during model training, a cosine annealing learning rate scheduler is used instead of a fixed learning rate. This causes the learning rate to decay periodically during training, which helps the model escape local optima and improves final convergence performance. The other steps in this embodiment are the same as in Embodiment 1 and will not be repeated here.
[0069] This embodiment provides a single-band SAR imagery water body identification system, which includes: Memory, used to store computer programs; A processor, connected to the memory, is used to execute the computer program to implement the single-band SAR image water body identification method based on the improved UNet network and local mean ratio as described in any of the above embodiments.
[0070] This embodiment also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the single-band SAR image water body identification method based on an improved UNet network and local mean ratio as described in any of the above embodiments. Based on the above embodiments, the present invention also provides a computer-readable storage medium storing a computer program that is implemented when executed by a processor.
[0071] Those skilled in the art will recognize that the modules and method steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0072] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the devices, equipment, and modules described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0073] In addition, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.
[0074] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion 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 invention. The aforementioned storage medium includes various media capable of storing program instructions, such as USB flash drives, portable hard drives, read-only storage servers, random access storage servers, magnetic disks, or optical disks.
[0075] Furthermore, it should be noted that the combination of the various technical features in this case is not limited to the combination methods described in the claims of this case or the combination methods described in the specific embodiments. All technical features described in this case can be freely combined or combined in any way, unless they contradict each other.
[0076] It should be noted that the above examples are merely specific embodiments of the present invention, and the present invention is obviously not limited to the above embodiments, with many similar variations. All modifications that can be directly derived or conceived by those skilled in the art from the content disclosed in this invention should fall within the protection scope of this invention.
[0077] The above are merely preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for water body identification based on a modified UNet network and local mean ratio in single-band SAR imagery, characterized in that, Includes the following steps: Step S1: Acquire the single-band SAR image to be identified and calculate the local mean ratio (LMR) index map of the image; Step S2: Based on the statistical characteristics of the LMR index map, adaptive threshold segmentation is performed to obtain a preliminary binary image; the preliminary binary image is processed by adaptive morphological filtering based on weighted average area to extract the main water bodies and fill the holes, and then combined with manual interactive refinement to generate a ground truth mask for water bodies and construct a training dataset. Step S3: Construct an improved SARUNet network model; the SARUNet network model is an encoder-decoder structure, with an edge enhancement module at the input end, a multi-scale dilated convolution module at the bottleneck layer connecting the encoder and decoder, and a spatial attention module at the decoder output. Step S4: Train the SARUNet network model using the training dataset, calculate the loss using a hybrid loss function, and backpropagate to update the parameters; Step S5: Input the single-band SAR image to be tested into the trained SARUNet network model, output the water body prediction probability map, and obtain the final water body identification result after binarization processing.
2. The method for water body identification based on an improved UNet network and local mean ratio in single-band SAR imagery according to claim 1, characterized in that, The specific formula for calculating the Local Mean Ratio (LMR) index in step S1 is as follows: in, This represents the global pixel mean of the entire single-band SAR image. This represents the local pixel mean within a sliding window centered on the current pixel. To prevent the use of tiny constants in division by zero, a block-based calculation strategy is adopted for large-size images. The image is cropped into fixed-size blocks, LMR is calculated separately, and then the blocks are stitched back to the original size.
3. The method for water body identification based on an improved UNet network and local mean ratio in single-band SAR imagery according to claim 1, characterized in that, The specific steps of adaptive threshold segmentation based on the statistical characteristics of the LMR exponential graph in step S2 include: Calculate the pixel mean of the LMR index map of the entire image. and standard deviation ; Using formula Calculate the segmentation threshold ,in This is a preset adjustable coefficient; Using threshold The LMR index map is binarized to obtain a preliminary binary image.
4. The method for water body identification based on an improved UNet network and local mean ratio in single-band SAR imagery according to claim 1, characterized in that, The specific steps of processing using adaptive morphological filtering based on weighted average area in step S2 include: The main water body adaptive extraction stage: identify all independent water body connected regions in the preliminary binary image and calculate the area of each region; calculate the first weighted average area threshold based on the area of all water body regions, where the first weighted average area threshold is the sum of the products of the area of each region and its area ratio; dynamically retain water body regions with an area greater than or equal to the first weighted average area threshold and filter out regions with an area less than the threshold, so as to adaptively retain the main water bodies and remove noise patches; Adaptive Hole Filling Stage: Identify all closed holes inside the water area in the image after the above processing, and calculate the area of each hole; calculate a second weighted average area threshold based on the area of all holes; dynamically fill holes with areas smaller than the second weighted average area threshold to adaptively fill fine voids and preserve large real holes.
5. The method for water body identification based on an improved UNet network and local mean ratio in single-band SAR imagery according to claim 4, characterized in that, The formulas for calculating the first weighted average area threshold and the second weighted average area threshold are both: in, The weighted average area threshold is calculated as follows. This represents the total number of target regions in the current image. For the first The area of each target region For all The sum of the areas of each target region.
6. The method for water body identification based on an improved UNet network and local mean ratio in single-band SAR imagery according to claim 1, characterized in that, The edge enhancement module described in step S3 includes a convolutional layer whose kernel weights are initialized to Sobel operators and set to be learnable and update during training to adaptively optimize edge detection parameters through training data. The edge enhancement module performs convolution operations on the input image to extract edge features and adds the edge features to the original input image, so that the enhanced image retains both the original grayscale information and the optimized edge information, which is then used as the input of the subsequent encoder.
7. The method for water body identification based on an improved UNet network and local mean ratio in single-band SAR imagery according to claim 1, characterized in that, The multi-scale dilated convolution module described in step S3 includes four parallel branches: The first branch is a 1×1 convolution; The second branch is a 3×3 dilated convolution with a dilation rate of 3; The third branch is a 3×3 dilated convolution with a dilation rate of 5; The fourth branch is a 3×3 dilated convolution with a dilation rate of 7; Parallel dilated convolutional branches with dilation rates of 3, 5, and 7, together with 1×1 convolutional branches, constitute a multi-scale receptive field extraction structure. The outputs of the four branches are concatenated in the channel dimension and feature fusion is performed through a 1×1 convolutional layer to expand the receptive field while preserving the local details of the feature map.
8. The method for water body identification based on an improved UNet network and local mean ratio in single-band SAR imagery according to claim 1, characterized in that, The specific operation of the spatial attention module described in step S3 is as follows: The input feature map is subjected to global max pooling and global average pooling in the channel dimension to obtain two single-channel feature maps. Two single-channel feature maps are concatenated, passed through a 7×7 convolutional layer and a sigmoid activation function, to generate a spatial attention weight map. The spatial attention weight map is multiplied element-wise with the input feature map.
9. The method for water body identification based on an improved UNet network and local mean ratio in single-band SAR imagery according to claim 1, characterized in that, The hybrid loss function described in step S4 By binary cross-entropy loss and Dice loss The weighted composition is calculated using the following formula: in and These are the weight coefficients; the output layer of the network model outputs Logits values through 1×1 convolutions, directly participating without Sigmoid activation. The calculation, and the Sigmoid activation process, are then involved. calculate.
10. The method for water body identification based on an improved UNet network and local mean ratio in single-band SAR imagery according to claim 1, characterized in that, The training process in step S4 also includes: Calculate the global mean and global standard deviation of the training data, and perform global normalization on the image data before inputting it into the network; During training, the F1 score on the validation set is monitored. If the F1 score does not improve or shows a downward trend within a preset number of rounds, the early stopping mechanism is triggered to terminate training and save the best model parameters.
11. The method for water body identification based on an improved UNet network and local mean ratio in single-band SAR imagery according to claim 1, characterized in that, The edge enhancement module, multi-scale dilated convolution module, and spatial attention module work together. The edge enhancement module enhances the water body edge features to improve boundary positioning accuracy, the multi-scale dilated convolution module expands the receptive field to maintain the continuity of large water body identification, and the spatial attention module suppresses speckle noise to focus on the water body area. Together, they achieve refined water body identification of single-band SAR images.
12. The method for water body identification in single-band SAR images based on an improved UNet network and local mean ratio as described in claim 1, characterized in that, The LMR index map and the weighted average area adaptive morphological filter form a collaborative mechanism for automated sample construction. The LMR index map is used to enhance the contrast between the water body and the background to improve the quality of the initial binary image, while the weighted average area filter is used to adaptively filter the water body connected regions and fill holes based on the image content. The two work together to generate a high-quality water body ground truth mask, reducing the amount of manual retouching work.