Remote sensing image high-cleanliness water body extraction method based on improved Unet

By introducing terrain-aware attention modulation and multi-scale deep supervision loss function into the terrain-adaptive UNET model, the problems of misjudgment and boundary ambiguity in the extraction of high-cleanliness water bodies in complex terrain areas by the UNET model are solved, and high-precision and high-robust water body extraction is achieved.

CN121962944APending Publication Date: 2026-05-01SOUTHWEST PETROLEUM UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511949978.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-23
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing UNET models suffer from several problems in extracting high-cleanliness water bodies in complex terrain areas, including shallow utilization of terrain information, lack of terrain-guided attention, insufficient targeting of loss functions, and weak generalization ability. These issues result in high misclassification rates, blurred boundaries, and poor connectivity.

Method used

By replacing standard convolution with a terrain-adaptive feature enhancement module, and combining terrain-aware attention modulation and multi-scale deep supervision loss function, the convolution kernel parameters are dynamically adjusted to enhance the model's terrain adaptability and boundary extraction accuracy, and optimize the connectivity of narrow water bodies.

Benefits of technology

It significantly improves the accuracy and generalization ability of extracting high-cleanliness water bodies in complex terrain areas, reduces the false shadow rate, and enhances the accuracy of boundary extraction and the connectivity of narrow water bodies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121962944A_ABST
    Figure CN121962944A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of remote sensing image processing and deep learning, and provides an improved Unet-based remote sensing image high-cleanliness water body extraction method, which comprises the following steps of: firstly, constructing a terrain embedding vector or a terrain guide map for terrain data (DEM and derived factors), and dynamically generating convolution kernel parameters through a multi-layer perceptron according to the terrain embedding vector or the terrain guide map; terrain adaptive feature extraction is realized in an encoder and a decoder through dynamic convolution; meanwhile, a terrain perception attention module is constructed, space attention and terrain guidance information are subjected to gating fusion to highlight a key area, and in the model training stage, joint loss including cross entropy, Dice and boundary weighting is adopted, and multi-scale deep supervision is introduced. Compared with a baseline network, the method provided by the invention has the advantage that the connectivity of F1, IoU and a narrow river channel is obviously improved on complex topographic data such as plateau and cross-cut mountain areas.
Need to check novelty before this filing date? Find Prior Art

Description

A method for extracting high-cleanliness water from remote sensing images based on an improved Unet Technical Field

[0001] This application relates to the fields of remote sensing image processing and deep learning technology, and in particular to a method for extracting high-cleanliness water bodies from remote sensing images based on an improved Unet. Background Technology

[0002] Water resource monitoring is a crucial foundation for ecological environmental protection and sustainable development. With the rapid development of remote sensing technology, water body extraction based on remote sensing imagery has become a primary means of dynamic water resource monitoring. However, in practical applications, especially in complex terrain areas such as mountains and plateaus, water body extraction faces numerous challenges.

[0003] High-purity water bodies (such as alpine lakes, clear water areas of reservoirs, and pristine rivers) have low suspended solids content and high transparency, making their spectral characteristics easily confused with surrounding features (such as shadows, wetlands, and certain vegetation). Furthermore, complex terrain, including topographical shadows, slope variations, and vegetation obstruction, further complicates extraction. Traditional water body index methods (such as NDWI and MNDWI) often exhibit high misclassification rates in these areas.

[0004] In recent years, deep learning has demonstrated excellent performance in remote sensing image segmentation tasks. UNET, as a classic semantic segmentation network, has been widely used in water extraction tasks due to its encoder-decoder structure and skip connection mechanism. However, deep learning methods based on UNET and its improved models still have significant limitations when extracting high-cleanliness water bodies in complex terrain areas. Specifically, when the processing area covers various landforms such as plains, hills, mountains, and canyons, the accuracy of water extraction fluctuates significantly; especially in deeply shaded areas such as canyons, the model easily misclassifies terrain shadows as water bodies, leading to a higher false detection rate; at the same time, for linear water bodies such as narrow channels, the extraction results often exhibit problems such as fragmentation, blurred boundaries, and poor connectivity. Summary of the Invention

[0005] In view of the above problems, this application provides a method for extracting high-cleanliness water bodies from remote sensing images based on an improved Unet model. The method realizes terrain-adaptive feature extraction and attention modulation in the Unet model to improve the extraction accuracy and generalization ability of high-cleanliness water bodies in complex terrain areas.

[0006] This application provides a method for extracting high-cleanliness water bodies from remote sensing images based on an improved Unet, comprising: acquiring remote sensing images and DEM data of a study area; performing a first preprocessing on the remote sensing images to obtain a first image; performing a second preprocessing on the DEM data to obtain a terrain complexity index; classifying the study area based on the terrain complexity index to generate a terrain type code spatially registered with the first image; constructing an improved Unet network model, wherein the improved Unet network model is based on the original Unet and uses a terrain adaptive feature enhancement module to replace the standard convolution module in the encoder path; the terrain adaptive feature enhancement module is configured to perform dynamic convolution and feature attention modulation based on the terrain type code to achieve terrain adaptive feature enhancement; training the improved Unet network model based on the first image and its terrain type code using a joint loss function including cross-entropy loss, Dice loss, boundary-aware loss, and deep supervision loss to obtain a trained improved Unet network model; using the trained improved Unet network model to predict water bodies in the area to be extracted to obtain a water body probability map; and post-processing the water body probability map to obtain the final water body extraction result.

[0007] In the above implementation, DEM data is preprocessed to obtain a terrain complexity index. The study area is then classified based on this index, and terrain type encoding is used to transform terrain information into a structured representation, providing complete data support for adaptive terrain extraction. Furthermore, a terrain-adaptive feature enhancement module replaces standard convolution, using dynamic convolution to extract differentiated features from different terrains. This is combined with terrain-aware attention modulation to highlight key water areas. Finally, a joint loss function incorporating cross-entropy, Dice, boundary awareness, and deep supervision is used to achieve a comprehensive improvement from category differentiation to boundary optimization, and from single-scale to multi-scale analysis. This effectively solves the problem of confusion between high-cleanliness water bodies and shadows / vegetation, significantly improves the extraction accuracy of complex terrain areas, improves connectivity of narrow water bodies, and enhances the model's cross-regional generalization ability.

[0008] In some possible implementations, the first preprocessing includes at least one of radiometric calibration, atmospheric correction, topographic correction, and geometric fine correction; the postprocessing includes at least one of thresholding, morphological processing, connected component analysis, and boundary smoothing.

[0009] In the above implementation, the first preprocessing step, through radiometric calibration and atmospheric correction, effectively eliminates interference from sensor errors, atmospheric scattering, topographic radiation distortion, and geometric shift, transforming the original image into high-fidelity data and providing a reliable spectral basis for model training and prediction. Postprocessing, through thresholding, morphological operations, connected component analysis, and boundary smoothing, fills in voids within water bodies, removes isolated noise points, deletes small misclassified patches, and optimizes boundary morphology, significantly improving the spatial integrity, geometric accuracy, and noise suppression of the extracted results.

[0010] In some possible implementations, the second preprocessing of the DEM data to obtain the terrain complexity index includes: calculating terrain factors on the DEM data to obtain slope, terrain roughness, and terrain undulation; calculating the slope variation coefficient based on the slope; and calculating the terrain complexity index based on the slope variation coefficient, the terrain roughness, and the terrain undulation.

[0011] In the above implementation method, a terrain complexity index is constructed by calculating multi-dimensional terrain parameters such as slope, terrain roughness, terrain undulation and slope variation coefficient, so as to comprehensively quantify the terrain complexity and break through the limitations of a single terrain factor.

[0012] In some possible implementations, the step of calculating terrain factors from the DEM data to obtain slope, terrain roughness, and terrain undulation includes: using the Horn algorithm to calculate the slope of each pixel in the DEM data; calculating the aspect based on the elevation gradient obtained from the slope calculation; calculating the terrain roughness based on the changes in slope and aspect; and using a sliding window to calculate the terrain undulation in the DEM data.

[0013] In the above implementation method, calculation methods such as the Horn algorithm are used to obtain key terrain factors such as slope, terrain roughness, and terrain relief, ensuring that each parameter can truly depict the detailed features of the surface terrain, which can effectively avoid terrain classification deviation caused by parameter errors.

[0014] In some possible implementations, the terrain adaptive feature enhancement module includes: a terrain encoding submodule configured to encode a terrain feature vector based on the terrain type; an adaptive convolution kernel generation submodule configured to generate a first set of convolution kernel parameters and a second set of convolution kernel parameters based on the terrain feature vector using a multilayer perceptron, each set of convolution kernel parameters including weights and bias terms; a first dynamic convolution submodule configured to convolve the input feature map using the first set of convolution kernel parameters, and process it with batch normalization and ReLU activation function to output a first feature map; a second dynamic convolution submodule configured to convolve the first feature map using the second set of convolution kernel parameters, and process it with batch normalization to output a second feature map; and a terrain-aware attention submodule configured to perform terrain-aware attention extraction and feature modulation based on the second feature map and the terrain feature vector to output a terrain-enhanced feature map.

[0015] In the above implementation, the terrain adaptive feature enhancement module encodes the terrain type into a high-dimensional feature vector through the terrain encoding submodule. Then, the adaptive convolutional kernel generation submodule dynamically generates convolutional kernel parameters adapted to different terrains. Two levels of dynamic convolution extract and enhance water features adapted to the terrain. Finally, the terrain-aware attention submodule modulates the features, highlighting water features and suppressing interference information. This entire module significantly enhances the model's terrain adaptability and effectively improves water extraction in complex terrain areas.

[0016] In some possible implementations, the terrain-aware attention submodule includes: a spatial attention branch for extracting a spatial attention map based on the second feature map; a terrain guidance branch for upsampling the terrain feature vector to obtain a terrain guidance map; a gated fusion component for weighted fusion of the spatial attention map and the terrain guidance map to obtain an attention feature map; and a feature modulation component for calculating a terrain enhancement feature map based on the second feature map and the attention feature map.

[0017] In the above implementation, the spatial attention branch extracts water spectral features based on the feature map, the terrain guidance branch transforms the terrain feature vector into a spatially matched terrain guidance map, and the gated fusion component dynamically adjusts the fusion weights of the two based on the feature map content and terrain conditions. Increasing the terrain guidance weight in complex terrain areas to suppress shadow interference and increasing the spatial attention weight in flat terrain areas to rely on spectral features can effectively improve boundary extraction accuracy and significantly reduce the risk of shadow misjudgment.

[0018] In some possible implementations, the spatial attention branch, used to extract a spatial attention map based on the second feature map, includes: performing global average pooling and global max pooling on the second feature map respectively, concatenating them and then performing convolution processing, and finally generating a spatial attention map through the Sigmoid activation function.

[0019] In the above implementation, the spatial attention branch employs a dual-pooling strategy combining global average pooling and global max pooling. This captures both the overall statistical distribution of the feature map and highlights local peak information, comprehensively covering the global trends and detailed characteristics of water features. After channel concatenation, convolution processing, and sigmoid activation, the generated spatial attention map can accurately locate key water features and effectively suppress redundant information in non-water regions.

[0020] In some possible implementations, the method also includes acquiring thermal infrared data of the study area; the terrain-aware attention submodule further includes a thermal infrared information fusion branch for calculating the surface temperature based on the thermal infrared data; the gated fusion component further performs a correction calculation on the result of weighted fusion of the spatial attention map and the terrain guidance map based on the surface temperature to obtain an attention feature map.

[0021] In the above implementation, by introducing thermal infrared data and utilizing the surface temperature differences between water bodies, shadows, and other land features, a new dimension for water body identification is added, compensating for the insufficient distinguishing ability of multispectral data in deep shadow areas. The thermal infrared information fusion branch converts surface temperature into a feature correction factor. Based on the fusion of spatial attention map and terrain guidance map, the gated fusion component further optimizes the attention feature map by incorporating this factor, which can accurately identify real water bodies in deep shadow areas and significantly reduce the shadow misclassification rate.

[0022] In some possible implementations, the improved Unet network model includes an encoder, a decoder, and a skip connection between the encoder and the decoder. A channel attention submodule is provided on the path of the skip connection. The channel attention submodule is configured to perform channel-level weighted modulation on the feature map output by the encoder, and then pass the modulated feature map to the decoder through the skip connection to concatenate it with the feature map of the corresponding stage of the decoder.

[0023] In the above implementation, a channel attention module is introduced into the skip connection path between the encoder and decoder. This module dynamically adjusts the channel weights of the encoder's output feature map, assigning high weights to channels containing key water features and low weights to redundant channels containing interference information such as shadows and vegetation. This channel-level modulation makes the features passed to the decoder more targeted, improves the fusion efficiency of shallow detail features from the encoder and upsampled features from the decoder, enhances the model's ability to capture details such as water body boundaries and narrow river channel textures, and effectively improves the completeness of narrow water body extraction.

[0024] In some possible implementations, the method for calculating the boundary-aware loss includes: obtaining binary ground truth labels for the study area; performing edge processing on the binary ground truth labels to obtain a binary water boundary mask; generating a boundary weighting matrix based on the water boundary mask; and calculating the boundary-aware loss based on the boundary weighting matrix and the cross-entropy loss function.

[0025] In the above implementation, the boundary-aware loss generates a weighted matrix by extracting the water body boundary mask, giving greater attention to the classification error of the boundary region, forcing the model to focus on learning boundary features, significantly improving the accuracy of water body boundary extraction, and avoiding the boundary blurring problem caused by traditional loss functions.

[0026] In some possible implementations, the method for calculating the deep supervised loss includes: acquiring multiple intermediate feature maps output from multiple intermediate stages of the decoder; mapping each intermediate feature map to an auxiliary prediction map through an auxiliary classification head, calculating an auxiliary loss for the auxiliary prediction map; and performing weighted fusion of all the auxiliary losses to obtain the deep supervised loss.

[0027] In the above implementation, deep supervised loss sets auxiliary classification heads in multiple intermediate stages of the decoder, so that the model can obtain supervision signals at different levels of feature extraction, guide the network to learn low-dimensional basic features and high-dimensional semantic features in a hierarchical manner, and enhance its adaptability to water bodies of different sizes.

[0028] The aforementioned technical features can be combined in various suitable ways or replaced by equivalent technical features, as long as the purpose of this application can be achieved.

[0029] Compared with existing technologies, this application addresses the core pain points in the extraction of high-cleanliness water bodies in complex terrain areas, such as shallow utilization of terrain information, lack of attention guidance based on terrain, insufficient targeting of loss functions, and weak generalization ability. It proposes a high-cleanliness water body extraction method based on improved UNET remote sensing images, which significantly improves extraction accuracy and generalization ability. Specifically: (1) The terrain information is converted into feature vectors through terrain encoding, and then the convolution kernel parameters are dynamically generated by a multilayer perceptron. This enables the model to adaptively adjust the filtering strategy according to different terrain conditions such as plains, hills, and canyons, and "customize" a special feature extraction scheme for each terrain. This effectively solves the problem of poor adaptability of fixed convolution kernels in feature extraction in complex terrain areas and significantly improves the accuracy of feature extraction in complex terrain areas.

[0030] (2) Spatial attention and terrain guidance information are dynamically fused through a gating function. In areas with complex terrain such as steep slopes and canyons, the terrain guidance weight is increased to suppress shadow interference. In areas with flat terrain, spatial attention is strengthened to rely on spectral features. By incorporating prior knowledge of terrain, the probability of confusion between high-cleanliness water bodies and shadows and vegetation is greatly reduced, and the accuracy of boundary extraction is improved.

[0031] (3) Construct a joint loss function of boundary weighting and multi-scale deep supervision. For slender targets such as narrow river channels and canyon water bodies, a boundary mask is generated by edge detection and given a higher loss weight. At the same time, an auxiliary classification head is set in the middle layer of the decoder to provide multi-scale supervision signals. This effectively solves the problems of incomplete extraction of narrow water bodies, blurred boundaries and poor connectivity caused by traditional loss functions, and enhances the model's adaptability to water bodies of different scales.

[0032] (4) By strengthening the transmission of effective features through channel attention modulation of skip connections, and combined with standardized data preprocessing and postprocessing processes, the completeness and reliability of the extraction results are further optimized. Attached Figure Description

[0033] The present application will be described in more detail below based on embodiments and with reference to the accompanying drawings. Figure 1 is a general flowchart of a method for extracting high-cleanliness water from remote sensing images based on an improved Unet, according to an embodiment of the present application.

[0034] Figure 2 is an architecture diagram of the terrain adaptive feature extraction module (TAFEM) provided in an embodiment of this application.

[0035] Figure 3 is an architecture diagram of the adaptive convolution kernel generator provided in an embodiment of this application.

[0036] Figure 4 is an architecture diagram of the terrain-adaptive Unet network model provided in an embodiment of this application.

[0037] Figure 5 is a schematic flowchart of a method for extracting high-purity water from remote sensing images based on an improved Unet, provided in an embodiment of this application. Detailed Implementation

[0038] To make the above-mentioned objectives, features, and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art are within the scope of protection of this application.

[0039] The terminology used in the implementation section of this application is for the purpose of explaining specific embodiments of this application only, and is not intended to limit this application.

[0040] In recent years, deep learning methods have shown excellent performance in remote sensing image segmentation tasks. UNET, as a classic semantic segmentation network, has been widely used in water extraction tasks due to its encoder-decoder structure and skip connection mechanism. However, existing UNET models and their improved methods have the following technical defects in the extraction of high-cleanliness water bodies in complex terrain areas: (1) The utilization of terrain information is superficial. Existing methods often use DEM data as an additional input channel and simply stitch it with multispectral images. This method cannot dynamically adjust the convolution kernel parameters according to terrain features, making it difficult to achieve differentiated feature extraction for different terrain areas (plains, hills, mountains, canyons, etc.). When terrain conditions change (such as from a flat area to a steep slope canyon), the fixed convolution kernel weights cannot adaptively change the filtering strategy, resulting in poor feature extraction performance in complex terrain areas.

[0041] (2) The attention mechanism lacks terrain prior guidance. Existing channel attention (such as the SE module) or spatial attention (such as CBAM) only generate attention weights based on the statistical information of the feature map itself, failing to explicitly incorporate the spatial distribution of terrain factors (slope, aspect, roughness, etc.) into the attention calculation process. This results in the model being unable to effectively utilize terrain prior knowledge to highlight real water areas and suppress terrain shadow interference, especially in deep shadow areas of canyons, where the model often misclassifies shadows as water.

[0042] (3) Insufficient targeting of loss function design. When dealing with linear or slender targets such as narrow river channels and canyon water bodies, existing methods often only use cross-entropy loss or Dice loss, lacking special attention to the boundary region and failing to combine multi-scale deep supervision mechanisms. This leads to problems such as incomplete extraction of narrow water bodies, low boundary accuracy, and poor river connectivity.

[0043] (4) The model structure lacks explicit modeling for terrain changes. Although existing improvement methods introduce various attention modules or multi-scale fusion strategies, the parameters of these modules are implicitly learned during training, without explicitly establishing a mapping relationship between "terrain conditions → feature extraction strategies". This makes the model have insufficient generalization ability when facing terrain types not fully covered in the training set, and often requires a lot of retraining when applied across regions.

[0044] In view of this, in order to solve at least some of the technical problems existing in the prior art, referring to the overall flowchart of the high-cleanliness water body extraction method based on improved Unet in Figure 1, this application discloses a high-cleanliness water body extraction method based on improved Unet in remote sensing images. Through three major innovations, such as terrain-driven dynamic convolution kernel generation, terrain-aware spatial attention gating fusion mechanism, and joint loss of boundary weighting and multi-scale deep supervision, it achieves high-precision and high-robust extraction of high-cleanliness water bodies in complex terrain areas.

[0045] Terrain-driven dynamic convolution kernel generation mechanism This application maps terrain information (discrete terrain category labels or continuous terrain factors) into terrain feature vectors through embedding layers or encoding networks, and then uses the hypernetwork concept to dynamically generate the weight parameters and bias parameters of the convolutional layers through a multilayer perceptron (MLP). Unlike existing technologies that simply stitch together DEMs as additional channels, this application achieves terrain adaptation at the core parameter level of the convolution operation, enabling the model to automatically adjust the filtering characteristics of the convolution kernel according to the terrain conditions (plains, hills, mountains, canyons, etc.) of the current pixel, thereby adopting differentiated feature extraction strategies in different terrain regions. This mechanism supports two terrain input modes: (1) discrete terrain categories, mapped into high-dimensional feature vectors through learnable embedding layers; (2) continuous terrain factors, mapped into feature representations through convolutional encoders or Transformer encoders.

[0046] Gating fusion mechanism for terrain perception attention This application designs a terrain-aware spatial attention mechanism, the core of which lies in adaptively fusing traditional spatial attention with terrain guidance information through a gating method. Specifically, the model first generates spatial attention based on global average pooling and global max pooling of the feature map, while simultaneously generating a terrain guidance map with the same spatial size as the feature map by upsampling or convolution mapping of the terrain feature vector; then, the fusion weights are calculated through a learnable gating function to finally obtain the terrain-aware attention weights. This gating fusion mechanism enables the model to dynamically adjust the attention allocation strategy according to the feature map content and terrain conditions: in areas with prominent terrain features (such as steep slopes and canyons), the weight of terrain guidance is increased to suppress shadow interference; in flat terrain areas, the weight of spatial attention is increased to rely more on spectral features.

[0047] Joint loss of boundary weighting and multi-scale deep supervision To address the challenge of extracting slender targets such as narrow river channels and canyon water bodies in complex terrain, this application designs a joint loss function that includes a boundary weighting term and optimizes it using a multi-scale deep supervision mechanism. Boundary weighting extracts water body boundary masks using edge detection operators such as Sobel, assigning higher weights to classification errors in boundary regions. Multi-scale deep supervision adds an auxiliary classification head to the intermediate layer of the decoder, enabling the model to obtain supervision signals at different stages of feature extraction, thus enhancing its adaptability to multi-scale water bodies (from large lakes to narrow river channels). For extremely narrow river channels (e.g., width < 3 pixels), this application further proposes introducing an anisotropic strategy into the boundary weighting: based on the water body direction (through morphological skeleton extraction or directional filtering estimation), the boundary error weights along the river channel extension direction are further increased, thereby enhancing the connectivity and integrity of the narrow river channel.

[0048] Example 1: Water extraction from alpine lakes in plateau regions This embodiment takes a typical area of ​​the plateau as the research object. This area contains multiple alpine lakes at an altitude of 4,000-5,500 meters, with complex terrain and a wide distribution of high-purity water bodies.

[0049] Step 1: Data Acquisition and Preprocessing 1. Remote Sensing Data Acquisition: Acquire Sentinel-2 satellite multispectral remote sensing images with a spatial resolution of 10 meters, containing 13 spectral bands, and select 15 scenes of cloudless or low-cloud images.

[0050] 2. DEM Data Acquisition: Acquire SRTM 30-meter resolution DEM data, resample to 10-meter resolution using bilinear interpolation, and spatially register with remote sensing imagery.

[0051] 3. Remote sensing image preprocessing: (1) Radiometric calibration: Convert DN values ​​to top atmospheric reflectance to eliminate the influence of sensor and solar irradiance; (2) Atmospheric correction: Use the 6S atmospheric correction model to convert top atmospheric reflectance to surface reflectance to remove the influence of atmospheric scattering and absorption; (3) Topographic correction: Based on DEM data and solar zenith angle and azimuth information, use the C correction model to eliminate the radiation difference caused by topographic undulation; (4) Geometric fine correction: Use a 1:10000 topographic map as a reference and use a polynomial correction method to make the geometric accuracy better than 1 pixel.

[0052] 4. Calculation of topographic factors: (1) Slope calculation: The slope value of each pixel is calculated using the Horn algorithm, in degrees; (2) Aspect calculation: The orientation of the slope is calculated, 0-360 degrees, with 0 degrees for due north; (3) Topographic relief calculation: The elevation range is calculated as the topographic relief within a 5×5 pixel window; (4) Surface roughness calculation: The degree of surface micro-topographic relief is calculated based on the changes in slope and aspect.

[0053] Step 2: Terrain Classification and Coding 1. Calculation of Terrain Complexity Index: For each pixel in the study area, calculate the Terrain Complexity Index (TCI): TCI = 0.4 × TRD + 0.35 × CV(Slope) + 0.25 × SR where TRD is the normalized terrain relief, CV(Slope) is the coefficient of variation of slope within a 3×3 window, and SR is the surface roughness.

[0054] 2. Topographic Classification: Based on the TCI value, the study area was divided into 5 topographic types: Plateau Plain (Type 0): TCI < 8, mainly flat plateau areas; Plateau Hilly Area (Type 1): 8 ≤ TCI < 25, with relatively small topographic relief; Low Mountain Area (Type 2): 25 ≤ TCI < 45, with moderate topographic relief; Medium Mountain Area (Type 3): 45 ≤ TCI < 70, with relatively large topographic relief; High Mountain Canyon Area (Type 4): TCI ≥ 70, with extremely complex topography.

[0055] 3. Terrain type label map generation: Assign a unique code (0-4) to each terrain type and generate a terrain type label map that is spatially registered with the remote sensing image, which will serve as the input for subsequent model training.

[0056] Step 3: Constructing a sample dataset 1. Sample area selection: Within the study area, select typical sample areas based on terrain type and water body distribution characteristics to ensure coverage of various terrain types and water bodies of different sizes.

[0057] 2. Water body annotation: (1) Preliminary extraction: The improved Normalized Difference Water Index (MNDWI) is used for preliminary water body extraction; (2) Visual interpretation: The preliminary extraction results are checked and corrected pixel by pixel, with reference to high-resolution images; (3) Annotation refinement: Special attention is paid to the accurate delineation of water body boundaries to ensure that the boundary error does not exceed 2 pixels.

[0058] 3. Dataset Construction: The data from the sample area were randomly divided into training, validation, and test sets in a ratio of 7:2:1. Each data sample included remote sensing image multispectral data, DEM and topographic factor data, topographic type labels, and binary annotations of water bodies.

[0059] Step 4: Constructing the Terrain-Adaptive UNET Model 1. Terrain Encoder Design: Preferably, the terrain type label (an integer from 0 to 4) is converted into a terrain feature vector through an embedding layer. The embedding dimension d is preferably 32-256; in this embodiment, 64 dimensions are selected: T = Embedding(terrain_label) ∈ R^d. The embedding layer parameters are automatically learned during model training, making feature vectors of similar terrain types more similar in semantic space. In other implementations, higher dimensions (such as 128 or 256) can be chosen to enhance expressive power, or lower dimensions (such as 32) can be chosen to reduce the number of parameters.

[0060] 2. Adaptive convolutional kernel generator design: Referring to Figure 3, for each convolutional layer, the convolutional kernel parameters of the layer are dynamically generated according to the input terrain feature vector T: (1) First layer MLP: T_hidden=ReLU(Linear1(T)), preferably mapping the feature to the hidden dimension d_hidden. In this embodiment, d_hidden=128, and in other embodiments, it can also be in the range of 64-512; (2) Second layer MLP_w: W_adapt=Reshape(Linear2_w(T_hidden)), generating convolutional kernel weights; (3) The second layer MLP_b: b_adapt=Linear2_b(T_hidden), generates the bias term; for example, for a 3×3 convolutional layer, with 64 input channels and 128 output channels: W_adapt∈R^(128×64×3×3), b_adapt∈R^128. 3. Implementation of dynamic convolutional layer: standard convolution operation is replaced with dynamic convolution: F_out=DynamicConv(F_in, W_adapt, b_adapt) where F_in is the input feature map, and W_adapt and b_adapt are dynamically generated parameters.

[0061] 4. Terrain-aware attention mechanism design: (1) Spatial attention branch: F_avg=GlobalAvgPool(F) F_max=GlobalMaxPool(F) A_spatial=Sigmoid(Conv1×1([F_avg, F_max])) (2) Terrain guidance branch: T_guide=Upsample(Embedding(terrain_label), size=F.size()) Upsamples the terrain feature vector to the same spatial size as the feature map F.

[0062] (3) Attention Fusion: Gate = Sigmoid(Conv1×1([A_spatial, T_guide])) A_terrain = Gate × A_spatial + (1-Gate) × Normalize(T_guide) (4) Feature Modulation: F_enhanced = F × A_terrain 5. Complete Structure of TAFEM Module: Referring to Figure 2, each TAFEM module includes the following components: Input → Dynamic Convolutional Layer 1 (3×3) → BatchNorm → ReLU → Dynamic Convolutional Layer 2 (3×3) → BatchNorm rm→Terrain Awareness Attention→Output6. Terrain Adaptive UNET Overall Architecture (refer to Figure 4): (1) Encoder Path: Stage 1: Input Channel 13 (Multispectral Band), Output Channel 64, TAFEM×2, MaxPool Downsampling; Stage 2: Input Channel 64, Output Channel 128, TAFEM×2, MaxPool Downsampling; Stage 3: Input Channel 128, Output Channel 256, TAFEM×2, MaxPool Downsampling; Stage 4: Input Channel 256, Output Channel 512, TAFEM×2, MaxPool Downsampling.

[0063] (2) Bridging layer: Input channel 512, output channel 1024, TAFEM×2.

[0064] (3) Decoder path: Stage 1: Upsampling, splicing Stage 4 encoded features, input channel 1536, output channel 512, Conv×2; Stage 2: Upsampling, splicing Stage 3 encoded features, input channel 768, output channel 256, Conv×2; Stage 3: Upsampling, splicing Stage 2 encoded features, input channel 384, output channel 128, Conv×2; Stage 4: Upsampling, splicing Stage 1 encoded features, input channel 192, output channel 64, Conv×2.

[0065] (4) Output layer: 1×1 convolution, output channel 2 (water body / non-water body), Softmax activation.

[0066] (5) Skip connection enhancement: Add a channel attention module (SE) at each skip connection: F_enc_att=SE(F_enc)=F_enc×Sigmoid(FC2(ReLU(FC1(GlobalAvgPool(F_enc)))))(6) Deep supervision: Add an auxiliary classification head at the Stage2 and Stage3 outputs of the decoder to output the prediction results at intermediate scales and participate in the loss calculation.

[0067] Step 5: Model Training and Optimization 1. Loss Function Design: (1) Cross-entropy Loss: L_CE=-Σ[y_i×log(p_i)+(1-y_i)×log(1-p_i)] where y_i is the ground truth label (0 or 1) of pixel i, and p_i is the probability of water body predicted by the model.

[0068] (2) Dice loss: L_Dice=1-(2×Σ(p_i×y_i)+smooth) / (Σp_i+Σy_i+smooth) where smooth is the smoothing term, preferably in the range of 1e-6 to 1e-4, and in this embodiment the value is 1e-5.

[0069] (3) Boundary-aware loss: First, extract the water body boundary: preferably use the Sobel operator, Canny operator, or morphological methods to perform edge detection on the ground truth labels to generate a boundary mask B, with boundary pixels marked as 1 and the rest as 0. This embodiment uses the Sobel operator.

[0070] L_Boundary = -Σ(w_i × [y_i × log(p_i) + (1 - y_i) × log(1 - p_i)]), where the weight w_i is defined as: w_i = 1 + α × B_i. The preferred range for the boundary weight coefficient α is 3-10. For high-cleanliness water bodies in complex terrain areas, α is preferably 5-8. In this embodiment, α = 5. In narrow river scenarios, α can be further increased to 8-10 to enhance connectivity.

[0071] (4) Deep Supervision Loss: For two or more auxiliary classification heads in the intermediate output, calculate the auxiliary loss L_aux using the same loss function form. The number of auxiliary losses can be adjusted according to the network depth, preferably 2-3.

[0072] (5) Total loss: L_total = λ1 × L_CE + λ2 × L_Dice + λ3 × L_Boundary + Σ(λ_aux_i × L_aux_i). The preferred range of weight coefficients is: λ1 ∈ [0.5, 2.0], λ2 ∈ [0.5, 2.0], λ3 ∈ [1.0, 5.0], λ_aux ∈ [0.1, 0.5]. In this embodiment, λ1 = 1.0, λ2 = 1.0, λ3 = 2.0, λ_aux1 = 0.3, λ_aux2 = 0.3. In other application scenarios, the values ​​can be adjusted according to the data characteristics: increase λ3 when the boundary accuracy requirement is high, and increase λ2 when the class imbalance is severe.

[0073] 2. Optimizer Settings: AdamW or Adam optimizer is preferred. The parameters in this embodiment are set as follows: Optimizer: AdamW; weight decay coefficient is preferably 1e-5 to 5e-4, 1e-4 in this embodiment; initial learning rate: preferably 5e-5 to 5e-4, 1e-4 in this embodiment; learning rate scheduling strategy: preferably CosineAnnealing or StepLR, CosineAnnealing is used in this embodiment; minimum learning rate is preferably 1 / 100 to 1 / 10 of the initial learning rate, 1e-6 in this embodiment; gradient clipping: preferably maximum gradient norm 0.5-2.0, 1.0 in this embodiment, to prevent gradient explosion.

[0074] 3. Data Augmentation Strategies: During training, the following combination of data augmentation methods is preferred. The specific parameters can be adjusted according to the characteristics of the data: random horizontal flipping; random vertical flipping; random rotation in multiples of 90 degrees; random brightness adjustment; random contrast adjustment; Gaussian noise addition.

[0075] 4. Training Results: After training, the model achieved excellent performance on the validation set: Overall accuracy (OA): 95.5%-97.5%; Kappa coefficient: 0.91-0.94; F1 score: 94.0%-96.5%; IoU: 90.0%-93.0%.

[0076] Step 6: Water body extraction and post-processing 1. Model prediction: Input the remote sensing image, DEM data and terrain type label of the area to be extracted into the trained model: (1) Image block: Divide the large image into image blocks of preferred size (such as 128×128, 256×256 or 512×512 pixels). The overlapping area is preferably 1 / 4 to 1 / 2 of the block size. In this embodiment, a 256×256 pixel image block is used with an overlap of 64 pixels; (2) Batch prediction: The batch size is adjusted according to the GPU memory, preferably 8-32. In this embodiment, 16 image blocks are processed in each batch, and the water body probability map is output; (3) Result stitching: Take the average or weighted average of the overlapping areas and merge them into a complete probability map; (4) Binarization: Set the threshold τ, preferably in the range of 0.4-0.6. In this embodiment, τ=0.5, and convert the probability map into a binary water body mask.

[0077] 2. Post-processing optimization: (1) Morphological closing operation: Use circular or square structural elements with a preferred size of 3×3 to 7×7 pixels. In this embodiment, a circular structural element with a size of 5×5 pixels is used to fill the small cavities inside the water body and eliminate "salt and pepper noise".

[0078] (2) Morphological opening operation: Using square or circular structural elements with a preferred size of 3×3 pixels, isolated misjudged points and small noise blocks are removed.

[0079] (3) Connected domain analysis: Mark all connected water areas; calculate the area (number of pixels) of each connected domain; set a minimum area threshold: preferably 5-20 pixels (equivalent to an actual area of ​​500-2000 square meters, depending on the image resolution), in this embodiment it is set to 10 pixels (about 1000 square meters); delete connected domains with an area smaller than the threshold to reduce fragmented patches.

[0080] (4) Boundary smoothing: Extract the vector polygon of the water body boundary; preferably use the Douglas-Peucker algorithm or Savitzky-Golay filter to simplify or smooth the polygon, and the tolerance parameter is preferably 1-2 pixels, which is set to 1.5 pixels in this embodiment; convert the smoothed boundary back to raster format.

[0081] 3. Output of extraction results: (1) Raster results: output water body distribution map, retain geographic coordinates and projection information; (2) Vector results: output water body polygons, including attributes such as area, perimeter, and terrain type; (3) Statistical information: calculate statistical indicators such as total water area, number of water bodies, average water body area, and water body distribution in different terrain types in the study area.

[0082] Accuracy Verification 1. To objectively evaluate the performance of the method in this application, a quantitative evaluation was performed on an independent test dataset. The index ranges are as follows: Overall accuracy (OA): 95.8%-98.0%; Kappa coefficient: 0.92-0.95; F1 score: 94.5%-97.0%; IoU: 91.0%-94.0%.

[0083] 2. Furthermore, on the same test set, comparisons were made with other mainstream methods: (1) Traditional UNET: OA=91.5%-94.0%, Kappa=0.82-0.86, F1=90.0%-93.5%; (2) DeepLabV3+: OA=92.8%-95.5%, Kappa=0.85-0.89, F1=91.5%-94.5%; (3) HRNet: OA=93.5% %-96.0%, Kappa=0.87-0.91, F1=92.8%-95.8%; (4) DEM as UNET for additional channels: OA=92.0%-94.8%, Kappa=0.84-0.88, F1=90.5%-93.8%; (5) Example 1: OA=95.8%-98.0%, Kappa=0.92-0.95, F1=94.5%-97.0%.

[0084] The results show that the method of this application is superior to the comparative method in all indicators.

[0085] 3. Accuracy Analysis of Different Terrain Types: The extraction accuracy (F1 score) of different terrain types is statistically analyzed, and the range and representative values ​​are given: Plateau Plain Area (TCI<10): F1=97.5%-98.8%, the highest accuracy; Plateau Hilly Area (10≤TCI<30): F1=96.5%-98.0%; Low Mountain Area (30≤TCI<50): F1=95.5%-97.2%; Medium Mountain Area (50≤TCI<80): F1=94.0%-96.2%; High Mountain Canyon Area (TCI≥80): F1=92.5%-95.0%, the accuracy is relatively low but still remains at a high level.

[0086] It is evident that the extraction accuracy decreases with increasing terrain complexity, which is reasonable. However, the terrain adaptation mechanism of this application effectively alleviates this problem. Even in the most complex mountain and canyon areas, the F1 score still reaches 92.5%-95.0%, which is far higher than the performance of traditional UNET in this type of terrain (approximately 85%-90%) and the performance of DEM channel fusion methods (approximately 87%-91%).

[0087] Example 2: Water extraction from canyon rivers in the Hengduan Mountains This embodiment focuses on a typical river basin in the Hengduan Mountains. The terrain in this area is extremely complex, with the river flowing through deep canyons and steep mountains on both sides. The severe shadow interference poses a great challenge to water extraction.

[0088] The study area is located in the heart of the Hengduan Mountains, with a drainage area of ​​approximately 3,000 square kilometers and a river length of about 150 kilometers, with an elevation difference of over 2,000 meters. Key characteristics include: V-shaped canyon landforms, with depths ranging from 500 to 1,500 meters and slopes generally exceeding 45 degrees; high vegetation cover, with dense subtropical evergreen broad-leaved forests and mixed coniferous and broad-leaved forests; significant variations in river width, ranging from 50 to 200 meters in wide sections to only 5 to 20 meters in canyon sections; and severe topographic shading, with the bottom of deep valleys receiving less than 4 hours of direct sunlight per day.

[0089] Data and Model Configuration 1. Data Acquisition: Remote Sensing Data: Sentinel-2 imagery (10-meter resolution), selecting 8 images from spring (March-May); DEM Data: ALOS PALSAR 12.5-meter resolution DEM, resampled to 10 meters; Auxiliary Data: Landsat-8 thermal infrared data (30 meters), used to help distinguish water bodies and shadows.

[0090] 2. Topographical Classification: Based on the characteristics of the canyon topography, a more detailed classification scheme is adopted: Flat area at the bottom of the valley (Type 0): TCI<15; Gentle slope area of ​​the valley (Type 1): 15≤TCI<40; Steep slope area of ​​the mountain (Type 2): 40≤TCI<70; Deeply incised area of ​​the canyon (Type 3): 70≤TCI<100; Extreme canyon area (Type 4): TCI≥100.

[0091] 3. Model fine-tuning: Based on the basic model trained on the plateau, transfer learning is performed using sample data from the Hengduan Mountains: the parameters of the first two layers of the encoder are frozen; only the last two layers of the encoder, decoder and TAFEM module are fine-tuned; the learning rate is reduced to 5e-5.

[0092] Special Strategy 1, Shadow-Water Separation Enhancement: To address the deep shadow problem in canyons, a thermal infrared information fusion branch is added to the TAFEM module: (1) The Landsat-8 thermal infrared band (TIRS1) is resampled to 10 meters; (2) The surface temperature is calculated, and the water temperature is usually lower than that of the surrounding land features; (3) In the terrain perception attention mechanism, temperature difference features are introduced: T_diff=Normalize(T_surrounding-T_water)A_terrain_enhanced=A_terrain×(1+β×T_diff) where β is the temperature weighting coefficient, with a value of 0.3.

[0093] 2. Narrow channel enhancement: In response to the narrow width of the river in the canyon section (5-20 meters): (1) When enhancing the training data, increase the weight of narrow and long water samples; (2) In the boundary perception loss, increase the weight coefficient of the narrow channel area to α=8; (3) In post-processing, use anisotropic morphological operations to make the structural elements along the river direction longer.

[0094] Extraction Results and Analysis 1. Quantitative Accuracy: Overall accuracy: 95.8%; Kappa coefficient: 0.908; F1 score: 94.7%; Channel integrity: 98.2% (river connectivity index).

[0095] 2. Comparative analysis: Traditional UNET: a large number of shadows were falsely extracted, F1=87.3%; MNDWI thresholding method: a large number of narrow channels were missed, F1=82.6%; Example 2: taking into account both shadow suppression and narrow channel extraction, F1=94.7%.

[0096] 3. Typical scene effects: (1) Deep canyon section: The river is 8-15 meters wide and 800 meters deep, with the shadow coverage area of ​​the steep slopes on both sides accounting for more than 60%. The method of this application correctly extracts the main body of the river, with only a small amount of shadow misextracted (area <5%), while the traditional UNET misextracts shadow area up to 35%.

[0097] (2) Wide river section: The river is 100-150 meters wide, with alternating shallows and deep pools. The method in this application accurately identifies high-cleanliness water bodies in deep pool areas, and the boundary extraction accuracy is 2-3 pixels better than traditional methods.

[0098] (3) Vegetation Occlusion Section: The vegetation coverage rate above the river is 30 - 50%, and there are a large number of mixed pixels. The method of this application effectively identifies the water body components in the mixed pixels through the terrain adaptive mechanism and multi-scale feature fusion.

[0099] Example 3: Water extraction from reservoirs in basin and hilly areas This embodiment is for large and medium-sized reservoirs in basin and hilly areas. The terrain is relatively flat but the surface coverage is complex. There are dense farmlands and towns around the reservoirs, which is another typical scenario for water body extraction. The research area includes 15 large and medium-sized reservoirs, with the main characteristics: the terrain has small undulations, and the slope is mostly between 5 - 25 degrees; there are diverse land use types around the reservoirs: paddy fields, dry lands, orchards, urban construction land; the water quality of the reservoirs varies greatly: some reservoirs are drinking water sources with high cleanliness; some are affected by agricultural non-point source pollution and have high turbidity; the seasonal water level changes greatly, and the area of the water-level fluctuation zone can reach 10 - 30% of the reservoir area.

[0100] Targeted Strategies: 1. Simplification of terrain classification: Since the terrain is relatively simple, 3 types of terrain classification are adopted: Flat area (Type 0): TCI < 10; Gentle slope area (Type 1): 10 ≤ TCI < 30; Hilly area (Type 2): TCI ≥ 30.

[0101] 2. Adaptation to water level changes: (1) The training samples cover three periods: high water period, normal water period, and low water period; (2) Distinguish between perennial water bodies and seasonal water bodies during annotation; (3) The model output includes the probability of water body type (perennial / seasonal). [[ID=ll]]

[0102] 3. Identification of the water-level fluctuation zone: Use multi-temporal images to identify the water-level fluctuation zone of the reservoir: (1) Extract the water body range of each time phase; (2) Calculate the water body frequency: Frequency = (Number of times the water body appears) / (Total number of images); (3) Definition of the water-level fluctuation zone: The area where 0 < Frequency < 1.

[0103] Extraction Results: 1. Precision indicators: Overall accuracy: 98.1%; Kappa coefficient: 0.957; F1 score: 97.8%; Extraction accuracy of perennial water bodies: 98.9%; Extraction accuracy of seasonal water bodies: 95.3%.

[0104] 2. Application effects: (1) Water resources monitoring: Accurately calculate the water storage area of each reservoir, with an error < 2%; (2) Management of the water-level fluctuation zone: Accurately identify the range of the water-level fluctuation zone, providing a basis for ecological restoration; (3) Water quality assessment: Combine spectral characteristics to distinguish between high-cleanliness water bodies and turbid water bodies, with an accuracy rate of 93.5%.

[0105] Verification of Model Generalization Ability To verify the generalization ability of the method of this application, tests were carried out in other areas not involved in training: 1. Alpine lakes in the Tianshan area of Xinjiang: Directly apply the plateau training model without fine-tuning; F1 score: 92.6%, showing good performance, proving that the model has cross-regional generalization ability.

[0106] 2. Dianchi Lake Basin, Yunnan: a large, shallow lake with a high degree of urbanization in the surrounding area; after fine-tuning with a small number of samples (200 image patches), the F1 score was improved to 96.2%.

[0107] 3. River network in the middle and lower reaches of the Yangtze River Plain: The terrain is flat, the river network is dense, and the river channels are narrow; after transfer learning, the integrity of the extracted river channels reached 97.8%.

[0108] As can be seen from the detailed description of the above three embodiments, the embodiments of this application can achieve the following technical effects: 1. Enhanced terrain adaptability. Through the terrain-driven dynamic convolution kernel generation mechanism, terrain-adaptive adjustment of convolution layer parameters is achieved. First, in different terrain regions (plains, hills, mountains, canyons), the model automatically uses different convolution kernel weights for feature extraction, which is equivalent to "customizing" a special filter for each terrain. Second, this dynamic adaptation mechanism enables the model to rely more on spectral features in flat areas and pay more attention to the joint features of terrain and spectrum in complex terrain areas, thereby effectively reducing the false positive rate in areas with severe terrain shadows such as steep slopes and canyons. Finally, compared with the fixed convolution kernel method, the method of this application has significantly improved water extraction accuracy in complex terrain areas and greatly improved water extraction accuracy in extremely complex terrain.

[0109] 2. Explicit Integration of Terrain Priors into Attention Mechanism. The terrain-aware attention-gated fusion mechanism proposed in this application explicitly incorporates the spatial distribution of terrain factors into the calculation of attention weights, rather than relying on the model's implicit learning of the terrain-water relationship. First, in the deep shadow region of a canyon, the model can identify the prior information that "the area has a large slope and is located at the bottom of the valley" through the terrain-guided branch, thereby increasing attention to real water bodies and suppressing the interference of shadows. Second, in mixed pixel regions obscured by vegetation, terrain-guided information helps the model distinguish between "mixed pixels located in the valley (more likely to contain water)" and "mixed pixels located on the hillside (more likely to be pure vegetation)," significantly improving boundary extraction accuracy (in pixels). Finally, the gating mechanism enables the model to dynamically adjust the fusion ratio of spatial attention and terrain guidance according to the content of the feature map, resulting in a significant improvement in the F1 score compared to fixed-weight fusion or using only spatial attention.

[0110] 3. Significantly improved accuracy in extracting narrow water bodies and boundaries, excellent model generalization and robustness, and enhanced accuracy in identifying high-cleanliness water bodies. First, through joint optimization of boundary weighting and multi-scale deep supervision, as well as an anisotropic enhancement strategy for narrow channels, this application demonstrates excellent performance in extracting elongated water body targets. Second, because this application uses terrain information as an explicit input rather than relying entirely on data-driven learning, the model exhibits good generalization ability in unfamiliar terrain types and cross-regional applications. Finally, addressing the issue of high-cleanliness water bodies being easily confused with terrain shadows, wetlands, and other features, this application significantly improves the accuracy of identifying high-cleanliness lakes through a combination of terrain-aware attention and boundary weighting optimization, significantly reduces the area of ​​shadow mis-extracted, and significantly improves the accuracy of distinguishing between seasonal and perennial water bodies.

[0111] 4. Significantly improved overall performance in quantitative evaluation. On representative test datasets containing various terrain types (plains, hills, mountains, and high mountain valleys) and water body types (lakes, reservoirs, rivers, and wetlands), the method in this application shows a significant performance improvement compared to mainstream baseline methods. In summary, the high-cleanliness water body extraction method based on improved UNET remote sensing imagery proposed in this application provides an effective technical means for remote sensing monitoring of water resources in complex terrain areas such as mountains and plateaus.

[0112] Specifically, as shown in Figure 5, the high-cleanliness water body extraction method based on improved UNET remote sensing images of this application includes the following steps: S10, acquiring remote sensing images and DEM data of the study area.

[0113] Optionally, the remote sensing images include Sentinel-2 multispectral images (spatial resolution 10-20 meters), Landsat series multispectral images (spatial resolution 15-30 meters), Gaofen series satellite images (spatial resolution 0.8-16 meters), Planet satellite images (spatial resolution 3-5 meters), UAV remote sensing images (spatial resolution 0.05-1 meter), and other commercial satellite multispectral or hyperspectral images with a spatial resolution range of 0.05-30 meters.

[0114] S20. Perform the first preprocessing on the remote sensing image to obtain the first image.

[0115] In some embodiments, the first preprocessing includes at least one of radiometric calibration, atmospheric correction, topographic correction, and geometric fine correction.

[0116] S30. Perform a second preprocessing on the DEM data to obtain the terrain complexity index.

[0117] In some embodiments, a second preprocessing is performed on the DEM data to obtain a terrain complexity index, including: calculating terrain factors on the DEM data to obtain slope, terrain roughness, and terrain undulation; calculating the slope variation coefficient based on the slope; and calculating the terrain complexity index based on the slope variation coefficient, terrain roughness, and terrain undulation.

[0118] Optionally, terrain factors are calculated on the DEM data to obtain slope, terrain roughness, and terrain undulation, including: using the Horn algorithm to calculate the slope of each pixel on the DEM data; calculating the aspect based on the elevation gradient obtained from the slope calculation; calculating the terrain roughness based on the changes in slope and aspect; and calculating the terrain undulation on the DEM data using a sliding window.

[0119] S40. Classify the study area based on the terrain complexity index and generate terrain type codes that are spatially registered with the first image.

[0120] S50. Construct an improved Unet network model. The improved Unet network model is based on the original Unet, and replaces the standard convolutional module with a terrain-adaptive feature enhancement module in the encoder path. The terrain-adaptive feature enhancement module is configured to encode based on terrain type, perform dynamic convolution and feature attention modulation to achieve terrain-adaptive feature enhancement.

[0121] Optionally, the deployment locations of dynamic convolutional layers in the network include at least one combination of the following: (a) applying dynamic convolution in all convolutional layers of the encoder; (b) applying dynamic convolution in some convolutional layers (preferably deep layers) and bridging layers of the encoder; and (c) applying dynamic convolution at key locations (preferably bottleneck layers and multi-scale fusion points) of the encoder, bridging layers, and decoder.

[0122] In some embodiments, the terrain adaptive feature enhancement module includes: a terrain encoding submodule configured to encode and map terrain feature vectors based on terrain type; an adaptive convolution kernel generation submodule configured to generate a first set of convolution kernel parameters and a second set of convolution kernel parameters based on the terrain feature vectors using a multilayer perceptron, each set of convolution kernel parameters including weights and bias terms; a first dynamic convolution submodule configured to convolve the input feature map using the first set of convolution kernel parameters, and process it through batch normalization and ReLU activation function to output a first feature map; a second dynamic convolution submodule configured to convolve the first feature map using the second set of convolution kernel parameters, and process it through batch normalization to output a second feature map; and a terrain-aware attention submodule configured to perform terrain-aware attention extraction and feature modulation based on the second feature map and the terrain feature vectors to output a terrain-enhanced feature map.

[0123] Alternatively, the terrain feature vector can also be obtained by mapping continuous terrain factors. Specific mapping methods include: taking normalized terrain factors such as slope, aspect, roughness, and undulation as multi-channel inputs, and mapping them into a terrain guidance map that matches the spatial size of the input feature map through an encoder containing 1-3 convolutional layers or a Transformer encoder containing a multi-head self-attention mechanism.

[0124] Optionally, the terrain-aware attention submodule includes: a spatial attention branch for extracting a spatial attention map based on the second feature map; a terrain guidance branch for upsampling the terrain feature vector to obtain a terrain guidance map; a gated fusion component for weighted fusion of the spatial attention map and the terrain guidance map to obtain an attention feature map; and a feature modulation component for calculating a terrain enhancement feature map based on the second feature map and the attention feature map.

[0125] Optionally, the spatial attention branch is used to extract a spatial attention map based on the second feature map, including: performing global average pooling and global max pooling on the second feature map respectively, concatenating them and then performing convolution processing, and then generating a spatial attention map through the Sigmoid activation function.

[0126] Optionally, it also includes acquiring thermal infrared data of the study area; the terrain-aware attention submodule further includes: a thermal infrared information fusion branch for calculating surface temperature based on thermal infrared data; the gated fusion component further performs correction calculations on the results of weighted fusion of the spatial attention map and the terrain guidance map based on the surface temperature to obtain an attention feature map.

[0127] In some embodiments, the improved Unet network model includes an encoder, a decoder, and a skip connection between the encoder and the decoder. A channel attention submodule is provided on the path of the skip connection. The channel attention submodule is configured to perform channel-level weighted modulation on the feature map output by the encoder, and then pass the modulated feature map to the decoder through the skip connection to be concatenated with the feature map of the corresponding stage of the decoder.

[0128] S60. Based on the first image and its terrain type encoding, the improved Unet network model is trained using a joint loss function to obtain the trained improved Unet network model. The joint loss function includes cross-entropy loss, Dice loss, boundary-aware loss, and deep supervision loss.

[0129] Optionally, the joint loss function is calculated using L_total = λ1 × L_CE + λ2 × L_Dice + λ3 × L_Boundary + Σλ_aux × L_aux, where L_CE is the cross-entropy loss; L_Dice is the Dice loss; L_Boundary is the boundary-aware loss, which is achieved by assigning a boundary weight coefficient α (α>1) to the classification error of the water boundary region; L_aux is the deep supervision loss, which is calculated by outputting auxiliary prediction results in at least one intermediate layer of the decoder and calculating the loss; λ1, λ2, λ3, and λ_aux are loss weight coefficients; Optionally, in the joint loss function, the weight coefficients of the cross-entropy loss λ1∈[0.5, 2.0], the weight coefficients of the Dice loss λ2∈[0.5, 2.0], the weight coefficients of the boundary-aware loss λ3∈[1.0, 5.0], and the weight coefficients of the deep supervision loss λ_aux∈[0.1, 0.5]; the boundary weight coefficient α∈[3, 10], and for narrow river scenarios, α is preferably 5-8.

[0130] In some embodiments, the method for calculating boundary-aware loss includes: obtaining binary ground truth labels for the study area; performing edge processing on the binary ground truth labels to obtain a binary water body boundary mask; generating a boundary weighting matrix based on the water body boundary mask; and calculating the boundary-aware loss based on the boundary weighting matrix and the cross-entropy loss function.

[0131] Alternatively, edge processing can be performed by using the Sobel operator, the Canny operator, or a morphological dilation-erosion operation to extract water body boundaries.

[0132] Optionally, for narrow river channels with a width of less than 3 pixels, an anisotropic enhancement strategy is introduced into the boundary perception loss: (a) the main direction of the water body is estimated by morphological skeleton extraction or directional filtering; (b) the weight coefficients of boundary pixels extending along the main direction of the water body are further multiplied by a gain factor β∈[1.5, 3.0]; (c) in the post-processing stage, anisotropic morphological structural elements are used, whose major axis direction is consistent with the main direction of the water body, and the ratio of the major axis to the minor axis is preferably 3:1 to 7:1.

[0133] In some embodiments, the method for calculating deep supervised loss includes: acquiring multiple intermediate feature maps output from multiple intermediate stages of the decoder; mapping each intermediate feature map to an auxiliary prediction map through an auxiliary classification head, calculating an auxiliary loss for the auxiliary prediction map; and performing weighted fusion of all auxiliary losses to obtain the deep supervised loss.

[0134] Optionally, the deep supervision loss calculation method includes: adding an independent auxiliary classification head after each of the 2-3 different upsampling stages in the decoder path. The auxiliary classification head contains a 1×1 convolutional layer and an upsampling layer, mapping the intermediate feature map to a prediction result with the same spatial size as the final output; calculating the loss L_aux=λ1_aux×L_CE_aux+λ2_aux×L_Dice_aux for each auxiliary output, where λ1_aux and λ2_aux are the internal weights of the auxiliary loss; and adding all auxiliary losses to the total deep supervision loss function with decreasing weights (preferably a combination of 0.5, 0.3 or 0.4, 0.3, 0.2).

[0135] Optionally, training the improved Unet network model using the joint loss function also includes data augmentation strategies, which include one or more combinations of: random horizontal flipping, random vertical flipping, random rotation (preferably an integer multiple of 90 degrees), random brightness adjustment (preferably within ±5% to ±15%), random contrast adjustment (preferably within ±5% to ±15%), and Gaussian noise addition (preferably with a standard deviation of 0.005-0.02).

[0136] S70. Using the trained improved Unet network model, perform water body prediction in the area to be extracted to obtain a water body probability map.

[0137] S80. Post-process the water body probability map to obtain the final water body extraction result.

[0138] In some embodiments, post-processing includes at least one of thresholding, morphological processing, connected component analysis, and boundary smoothing.

[0139] Optionally, post-processing includes: (a) binarizing the probability map with thresholds τ∈0.4 and 0.6; (b) performing morphological closing operations with structuring element sizes of 3×3 to 7×7 pixels to fill small voids inside the water body; (c) performing morphological opening operations with structuring element sizes of 3×3 pixels to remove isolated noise points; (d) performing connected component analysis to delete small patches with areas smaller than the threshold T_area (T_area is preferably 5-20 pixels, corresponding to an actual area of ​​500-2000 square meters); and (e) performing boundary smoothing using the Douglas-Peucker algorithm or Gaussian filtering, with a tolerance parameter preferably of 1-2 pixels.

[0140] While this application has been described herein with reference to specific embodiments, it should be understood that these embodiments are merely examples of the principles and applications of this application. Therefore, it should be understood that many modifications can be made to the exemplary embodiments, and other arrangements can be designed without departing from the spirit and scope of this application as defined by the appended claims. It should be understood that different dependent claims and features described herein can be combined in ways different from those described in the original claims. It is also understood that features described in conjunction with individual embodiments can be used in other described embodiments.

Claims

1. A method for extracting high-cleanliness water bodies from remote sensing images based on an improved Unet, characterized in that, include: Acquire remote sensing images and DEM data of the study area; The remote sensing image is subjected to a first preprocessing step to obtain a first image; The DEM data is preprocessed a second time to obtain a terrain complexity index; the study area is classified based on the terrain complexity index to generate a terrain type code that is spatially registered with the first image. An improved Unet network model is constructed. Based on the original Unet, the improved Unet network model replaces the standard convolutional module with a terrain-adaptive feature enhancement module in the encoder path. The terrain-adaptive feature enhancement module is configured to perform dynamic convolution and feature attention modulation based on the terrain type encoding to achieve terrain-adaptive feature enhancement. Based on the first image and its terrain type encoding, the improved Unet network model is trained using a joint loss function including cross-entropy loss, Dice loss, boundary-aware loss, and deep supervision loss to obtain a trained improved Unet network model. Using the trained improved Unet network model, water body prediction is performed on the region to be extracted to obtain a water body probability map. The water body probability map is post-processed to obtain the final water body extraction result.

2. The method for extracting high-cleanliness water from remote sensing images based on the improved Unet according to claim 1, characterized in that, The first preprocessing includes at least one of radiometric calibration, atmospheric correction, topographic correction and geometric fine correction; the postprocessing includes at least one of thresholding, morphological processing, connected component analysis and boundary smoothing.

3. The method for extracting high-cleanliness water from remote sensing images based on the improved Unet according to claim 1, characterized in that, The second preprocessing of the DEM data to obtain the terrain complexity index includes: calculating terrain factors on the DEM data to obtain slope, terrain roughness, and terrain undulation; calculating the slope variation coefficient based on the slope; and calculating the terrain complexity index based on the slope variation coefficient, the terrain roughness, and the terrain undulation.

4. The method for extracting high-cleanliness water from remote sensing images based on the improved Unet according to claim 3, characterized in that, The step of calculating terrain factors from the DEM data to obtain slope, terrain roughness, and terrain undulation includes: using the Horn algorithm to calculate the slope of each pixel in the DEM data; calculating the aspect based on the elevation gradient obtained from the slope calculation; calculating the terrain roughness based on the changes in slope and aspect; and using a sliding window to calculate the terrain undulation in the DEM data.

5. The method for extracting high-cleanliness water from remote sensing images based on the improved Unet according to claim 1, characterized in that, The terrain adaptive feature enhancement module includes: a terrain encoding submodule, configured to encode and map terrain feature vectors based on the terrain type; an adaptive convolution kernel generation submodule, configured to generate a first set of convolution kernel parameters and a second set of convolution kernel parameters based on the terrain feature vectors using a multilayer perceptron, each set of convolution kernel parameters including weights and bias terms; a first dynamic convolution submodule, configured to convolve the input feature map using the first set of convolution kernel parameters, and process it with batch normalization and ReLU activation function to output a first feature map; a second dynamic convolution submodule, configured to convolve the first feature map using the second set of convolution kernel parameters, and process it with batch normalization to output a second feature map; and a terrain-aware attention submodule, configured to perform terrain-aware attention extraction and feature modulation based on the second feature map and the terrain feature vectors, and output a terrain-enhanced feature map.

6. The method for extracting high-cleanliness water from remote sensing images based on the improved Unet according to claim 5, characterized in that, The terrain-aware attention submodule includes: a spatial attention branch for extracting a spatial attention map based on the second feature map; a terrain guidance branch for upsampling the terrain feature vector to obtain a terrain guidance map; a gated fusion component for weighted fusion of the spatial attention map and the terrain guidance map to obtain an attention feature map; and a feature modulation component for calculating a terrain enhancement feature map based on the second feature map and the attention feature map.

7. The method for extracting high-cleanliness water from remote sensing images based on the improved Unet according to claim 6, characterized in that, The spatial attention branch is used to extract a spatial attention map based on the second feature map, including: performing global average pooling and global max pooling on the second feature map respectively, concatenating them and then performing convolution processing, and then generating a spatial attention map through the Sigmoid activation function.

8. The method for extracting high-cleanliness water from remote sensing images based on the improved Unet according to claim 6, characterized in that, This also includes acquiring thermal infrared data of the study area; The terrain perception attention submodule further includes a thermal infrared information fusion branch, used to calculate the surface temperature based on the thermal infrared data; the gated fusion component further performs a correction calculation on the result of weighted fusion of the spatial attention map and the terrain guidance map based on the surface temperature to obtain an attention feature map.

9. The method for extracting high-cleanliness water from remote sensing images based on the improved Unet according to claim 1, characterized in that, The improved Unet network model includes an encoder, a decoder, and a hop connection between the encoder and the decoder, wherein a channel attention submodule is provided on the path of the hop connection. The channel attention submodule is configured to perform channel-level weighted modulation on the feature map output by the encoder, and then pass the modulated feature map to the decoder through a skip connection, and concatenate it with the feature map of the corresponding stage of the decoder.

10. The method for extracting high-cleanliness water from remote sensing images based on the improved Unet according to claim 1, characterized in that, The method for calculating the boundary-aware loss includes: obtaining binary ground truth labels for the study area; performing edge processing on the binary ground truth labels to obtain a binary water boundary mask; generating a boundary weighting matrix based on the water boundary mask; and calculating the boundary-aware loss based on the boundary weighting matrix and the cross-entropy loss function. The method for calculating the deep supervision loss includes: obtaining multiple intermediate feature maps output from multiple intermediate stages of the decoder; mapping each intermediate feature map to an auxiliary prediction map through an auxiliary classification head; calculating an auxiliary loss on the auxiliary prediction map; and weighting and fusing all the auxiliary losses to obtain the deep supervision loss.