Water body boundary extraction method based on progressive attention mechanism
Patent Information
- Application Number
- CN202610548452.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-23
- Publication Date
- 2026-10-20
- Estimated Expiration
- 2046-04-23
AI Technical Summary
[0003]在高分辨率遥感影像的水体自动化提取中,湖泊、河流、湿地及季节性水位变动区域普遍存在水体与陆地过渡带,该区域光谱呈渐变特征,传统深度学习模型易出现边缘分类置信度波动,造成提取边界锯齿化、碎片化、连续性差等问题
[0022]该基于渐进式注意力机制的水体边界提取方法,通过渐进式注意力与门控调制机制,实现不同层级特征的差异化增强,高层聚焦全局水体形态,低层精修局部边缘,有效缓解多尺度语义冲突,显著提升边界连续性与几何保真度。采用层级深度编码向量引导动态权重分配,使模型关注逻辑清晰,大幅提高可解释性。引入边界导向损失函数,利用Sobel梯度场实现预测边界与真值边界的方向对齐约束,有效抑制过渡带分类置信度抖动,明显改善边界锯齿与断裂现象。跨层自适应加权融合充分整合多尺度优势,兼顾整体轮廓完整性与细微边缘准确性。在湿地、水位变动区等复杂场面场景下,边界F1分数较传统U-Net+注意力方案明显提升,边界更平滑完整。本发明方法计算高效、泛化性强,可直接用于高分辨率遥感水体监测、水资源调查、生态湿地保护等工程应用,具备较高实用价值与推广前景。
Smart Images

Figure CN122416052B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of water body boundary extraction technology, and more specifically to a water body boundary extraction method based on a progressive attention mechanism. Background Technology
[0002] Existing water boundary extraction methods based on progressive attention mechanisms still have the following drawbacks in practical applications:
[0003] In the automated extraction of water bodies from high-resolution remote sensing images, lakes, rivers, wetlands, and areas with seasonal water level fluctuations commonly exhibit transition zones between water and land. These zones exhibit gradual spectral changes, making traditional deep learning models prone to fluctuations in edge classification confidence, leading to jagged, fragmented, and poorly continuous extraction boundaries. Existing methods based on U-Net and attention mechanisms often employ a one-time global feature recalibration strategy, which struggles to achieve differentiated boundary enhancement for different resolution levels. Single-scale feature extraction easily misses fine water body edges, and semantic conflicts arise between multi-scale features, causing model instability in transition zone regions. Furthermore, conventional loss functions only focus on overall classification accuracy, lacking specific constraints on boundary orientation and gradient consistency, failing to effectively suppress edge jitter. In addition, the traditional attention weight allocation logic is unclear, resulting in weak model interpretability and difficulty meeting the requirements for high-precision and robust water body boundary extraction, especially in complex scenarios such as shallow water areas and wetland edges, where boundary geometric fidelity and continuity remain significantly deficient. Summary of the Invention
[0004] The purpose of this invention is to provide a water boundary extraction method based on a progressive attention mechanism to solve the above-mentioned problems.
[0005] To achieve the above objectives, the present invention provides the following technical solution: a water boundary extraction method based on a progressive attention mechanism, applied to the automated extraction of water boundaries from high-resolution remote sensing images, specifically including the following steps:
[0006] Step 1: Acquire high-resolution remote sensing multispectral ground scene images. The images cover water bodies such as lakes, reservoirs, and rivers, as well as transition zones between water and land. The transition zones include shallow water areas, wetland edges, and areas with seasonal water level fluctuations. The images also retain subtle feature information of water body boundaries.
[0007] Step 2: Perform multi-level downsampling processing on the input image obtained in Step 1 to construct an encoder feature pyramid. The encoder feature pyramid contains multiple feature maps at different resolution levels. Each level of feature map corresponds to water features at different scales. Among them, the high-level feature maps focus on global water body morphological semantic information, while the low-level feature maps focus on local water body edge detail information.
[0008] Step 3: Set up an independent gated modulation progressive attention gating unit at each decoding level of the decoder. The gated modulation progressive attention gating unit is connected to the features of each level of the encoder feature pyramid. Figure 1 One-to-one correspondence is used to achieve differentiated enhancement of water body boundary features at different resolution levels;
[0009] Step 4: The gated modulation progressive attention gating unit receives three input signals, namely the encoder feature map corresponding to the current decoding level, the feature map output from the previous decoding level, and the layer depth encoding vector. The attention weight contribution of the three input signals is dynamically adjusted through learnable gating parameters to achieve progressive boundary focusing from coarse to fine. The gating unit corresponding to the higher-level decoding focuses on global water body morphology perception, while the gating unit corresponding to the lower-level decoding focuses on local edge fine localization.
[0010] Step 5: After outputting feature maps at each decoding level, a boundary-guided loss function is introduced. The boundary-guided loss function extracts the gradient field of the current level prediction mask and the gradient field of the labeled ground truth through the Sobel operator, performs orientation alignment constraints on the two gradient fields, and suppresses the jitter of classification confidence in the edge region, thereby improving the uniformity of classification confidence in the edge region.
[0011] Step 6: Fuse the output feature maps of all decoding layers using a cross-layer weighted fusion strategy to generate a water boundary extraction mask with high continuity and high geometric fidelity.
[0012] Furthermore, the spatial resolution of the high-resolution remote sensing multispectral ground scene imagery described in step 1 is no less than 10 meters, and the spectral bands include at least the blue band, green band, red band, and near-infrared band, which are used to accurately distinguish the spectral gradient characteristics of the transition zone between water and land.
[0013] Furthermore, the multi-level downsampling process in step 2 adopts a convolutional downsampling method, with a step size of 2 for each level of downsampling. The encoder feature pyramid contains at least 4 different resolution levels, and the feature maps of each level are optimized through batch normalization and activation functions to enhance the distinguishability of water features.
[0014] Furthermore, the gated modulation progressive attention gating unit in step 3 includes a gated modulation module and an attention recalibration module. The gated modulation module is used to perform dimensional unification and feature preprocessing on the three input signals, and the attention recalibration module is used to dynamically allocate attention weights according to the hierarchical depth coding vector.
[0015] Furthermore, the hierarchical depth encoding vector mentioned in step 4 is a one-dimensional vector with the same dimension as the number of decoding levels. It is generated by one-hot encoding and is used to distinguish the feature priorities of different decoding levels. The encoding vector corresponding to higher-level decoding has a higher weight than that of lower-level decoding, ensuring the dominant role of global morphological features.
[0016] Furthermore, the learnable gating parameters mentioned in step 4 include the weight matrix and the bias vector, which are iteratively optimized during model training using the stochastic gradient descent algorithm. The optimization objective is to minimize the semantic conflict of features at each level and improve the synergy of boundary features.
[0017] Furthermore, the calculation process of the boundary-guided loss function in step 5 is as follows: First, the gradient magnitude and gradient direction of the predicted mask and the labeled ground truth are calculated using the Sobel operator; then, the cosine similarity of the gradient directions of the two is calculated, and higher loss weights are applied to regions with lower similarity; finally, the gradient magnitude loss and the gradient direction loss are weighted and summed to obtain the total boundary-guided loss.
[0018] Furthermore, the cross-layer weighted fusion strategy described in step 6 adopts an adaptive weight allocation method, which learns the weight coefficients of the output feature maps of each decoding layer through a fully connected layer. The weight coefficients of the low-level feature maps are used to compensate for the loss of fine edge information, while the weight coefficients of the high-level feature maps are used to ensure the integrity of the water body morphology.
[0019] Furthermore, the method also includes a model training step: constructing a training dataset containing high-resolution remote sensing multispectral ground scene images and corresponding ground truth values of water body boundary annotations, inputting the training dataset into the model, using the weighted sum of the boundary-guided loss function and the cross-entropy loss function as the total loss function, iteratively training until the model converges, ensuring the model's boundary extraction accuracy in the transition zone region.
[0020] Furthermore, the water boundary mask extracted by the method improves the boundary F1 score by no less than 5% compared with the traditional U-Net+attention scheme in complex ground scenes such as wetland transition zones and seasonal water level fluctuation areas. It also significantly reduces edge jaggedness and breakage, improves model interpretability compared with traditional methods, and meets the practical application requirements of high-resolution remote sensing water body extraction in terms of boundary continuity and geometric fidelity.
[0021] Compared with existing technologies, the water boundary extraction method based on a progressive attention mechanism provided by this invention has the following advantages:
[0022] This method for water body boundary extraction, based on a progressive attention mechanism, achieves differentiated enhancement of features at different levels through progressive attention and gating modulation. Higher levels focus on the overall water body morphology, while lower levels refine local edges, effectively mitigating multi-scale semantic conflicts and significantly improving boundary continuity and geometric fidelity. Hierarchical deep encoding vectors guide dynamic weight allocation, making the model's focus logic clear and greatly improving interpretability. A boundary-guided loss function is introduced, utilizing a Sobel gradient field to achieve directional alignment constraints between the predicted and ground truth boundaries, effectively suppressing classification confidence fluctuations in transition zones and significantly improving boundary jaggedness and breakage phenomena. Cross-layer adaptive weighted fusion fully integrates multi-scale advantages, balancing overall contour integrity with the accuracy of subtle edges. In complex scenarios such as wetlands and areas with fluctuating water levels, the boundary F1 score is significantly improved compared to the traditional U-Net+attention scheme, resulting in smoother and more complete boundaries. This method is computationally efficient and has strong generalization capabilities, making it directly applicable to engineering applications such as high-resolution remote sensing water monitoring, water resource surveys, and ecological wetland protection, demonstrating high practical value and promising prospects for wider application. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those skilled in the art, other drawings can be obtained based on these drawings.
[0024] Figure 1 This is a flowchart illustrating the overall process of the present invention. Detailed Implementation
[0025] To enable those skilled in the art to better understand the technical solution of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings.
[0026] Please see Figure 1 A water boundary extraction method based on a progressive attention mechanism is applied to the automated extraction of water boundaries from high-resolution remote sensing images. The method includes the following steps:
[0027] Step 1: Acquire high-resolution remote sensing multispectral ground scene images. The images cover water bodies such as lakes, reservoirs, and rivers, as well as transitional zones between water and land. These transitional zones include shallow water areas, wetland edges, and areas with seasonal water level fluctuations. The images also retain subtle feature information about the boundaries of water bodies.
[0028] Specifically, Step 1 provides high-quality raw data for the entire water body boundary extraction process, serving as the foundation for all subsequent processing steps. "High-resolution remote sensing" refers to remote sensing technology with a spatial resolution of at least 10 meters, capable of clearly capturing subtle spectral changes in the transition zone between water and land, unlike low-resolution remote sensing images which cannot distinguish between shallow water and land. "Multispectral ground scene imagery" refers to a large-scale surface image containing multiple spectral bands. Here, "ground scene" specifically refers to the complete surface coverage scene encompassing the water body and its surrounding transition zone, not a single local area. This imagery can be acquired through a satellite remote sensing platform. After acquisition, no additional preprocessing is required; only the original spectral information and spatial details need to be preserved to ensure that subsequent feature extraction accurately captures subtle changes in the water body boundary, providing data support for resolving the issues of "jagged" or "fragmented" boundaries.
[0029] Step 2: Perform multi-level downsampling processing on the input image obtained in Step 1 to construct the encoder feature pyramid. The encoder feature pyramid contains feature maps at multiple resolution levels. Each level of feature map corresponds to water features at different scales. Among them, the high-level feature maps focus on global water morphology semantic information, while the low-level feature maps focus on local water edge details.
[0030] It should be noted that step 2 transforms the original high-resolution image into feature representations at different scales, achieving full coverage of "global + local" features. This is achieved by progressively reducing image resolution and increasing feature abstraction through downsampling, while preserving key information at different levels. Specifically, "multi-level downsampling" employs convolutional downsampling with a step size of 2 for each level. This method reduces computational cost while preserving the spatial correlation of features. The "encoder feature pyramid" is a collection of feature maps at different resolutions, containing at least four levels. This can be likened to "observing a body of water from high altitude to ground level"—high-level feature maps, like a high-altitude perspective, clearly present the overall shape of the water body, but with blurred details; low-level feature maps, like a ground perspective, accurately capture the subtle details at the water's edges, but lack a global view. This solves the problem of traditional single-scale feature extraction "either losing details or lacking a global perspective," providing a multi-scale feature foundation for subsequent progressive attention focusing. Simultaneously, each level of feature map undergoes batch normalization and activation function optimization, further improving the distinguishability between water and land features.
[0031] Step 3: Set up independent gated modulation progressive attention gating units at each decoding level of the decoder. These gated modulation progressive attention gating units are integrated with the features of each level of the encoder feature pyramid. Figure 1 One-to-one correspondence is used to achieve differentiated enhancement of water body boundary features at different resolution levels;
[0032] Here, it's crucial to explain that step 3 involves differentiated attention enhancement for feature maps at different scales, addressing the shortcomings of traditional attention mechanisms' "one-time global recalibration" which cannot adapt to multi-scale features. The "decoder" is the model structure corresponding to the encoder, used to restore the downsampled low-resolution feature map to a high-resolution boundary mask. Each decoding level corresponds to a feature level in the encoder, ensuring accurate feature matching. "Gated modulation" refers to adjusting the contribution of different input signals like a "switch" through learnable gating parameters. "Progressive attention" refers to gradually focusing on water boundary details from high to low levels, rather than focusing on all features at once. This unit corresponds one-to-one with the encoder's feature pyramid, meaning each scale of feature map has a dedicated attention adjustment module, achieving differentiated enhancement of water boundary features at different resolution levels—high-level features emphasize global morphology, so global semantic features are enhanced; low-level features emphasize local edges, so detailed edge features are enhanced, laying the foundation for subsequent progressive boundary focusing. In addition, "attention enhancement" is a mature deep learning technique. Essentially, it involves assigning different attention weights to make the model focus on features that are useful for the task and ignore useless background features.
[0033] Step 4: The gated modulation progressive attention gating unit receives three input signals: the encoder feature map corresponding to the current decoding level, the feature map output from the previous decoding level, and the layer depth encoding vector. The attention weight contribution of the three input signals is dynamically adjusted through learnable gating parameters to achieve progressive boundary focusing from coarse to fine. The gating unit corresponding to the higher decoding level focuses on global water body morphology perception, while the gating unit corresponding to the lower decoding level focuses on local edge fine localization.
[0034] This step is the main implementation process of the progressive attention mechanism. Further refining step 3, by dynamically adjusting the attention weights, boundary focusing is achieved "from coarse to fine." The three input signals each play a specific role: the current level encoder feature map provides the original water features at that scale; the previous level decoder output feature map provides global features at a coarser scale; and the hierarchical depth encoding vector is used to distinguish the priority of different decoding levels. The "hierarchical depth encoding vector" is a one-dimensional vector with the same dimension as the number of decoding levels. It is generated using one-hot encoding, with higher-level decoding vectors having higher weights than lower-level vectors, ensuring the dominant role of global morphological features and avoiding interference from local details with the global contour. The "learnable gating parameters" include the weight matrix. and bias vector The model is iteratively optimized during training using the stochastic gradient descent algorithm. The optimization objective is to minimize the semantic conflict of features at each level. The attention weights can be calculated using the following formula:
[0035]
[0036] In the formula, This is the final attention weight vector, used to adjust the contribution of the three input signals; For activation functions; It is a learnable weight matrix used to weight the input signal; This is the feature vector of the current level encoder feature map; This is the feature vector output from the previous level of decoding; This is a layer-by-layer depth encoding vector; This is a learnable bias vector used to adjust the offset of the output. It achieves progressive boundary focusing from coarse to fine: higher-level decoding gating units use higher global feature weights to focus on perceiving the overall morphology of the water body, ensuring the integrity of the boundaries; lower-level decoding gating units use higher local feature weights to focus on accurately locating edge details, compensating for the loss of fine edge information, effectively solving the problem of multi-scale feature semantic conflict in traditional methods, while improving the interpretability of the model—the attention allocation logic of each level is clear, and the type of features the model focuses on can be clearly traced.
[0037] Step 5: After outputting feature maps at each decoding level, a boundary-guided loss function is introduced. The boundary-guided loss function extracts the gradient field of the current level prediction mask and the gradient field of the labeled ground truth through the Sobel operator, respectively, and performs orientation alignment constraints on the two gradient fields. At the same time, it suppresses the jitter of classification confidence in edge regions and improves the uniformity of classification confidence in edge regions.
[0038] Step 5 is a crucial step in resolving the "jagged" boundary problem. Its purpose is to use the loss function constraint to make the model's predicted boundary more closely match the true boundary. The "loss function" is the parameter used in training the deep learning model.
[0039] The tool is used to measure the difference between the model's predicted results and the actual results; the smaller the difference, the better the model's performance. The "boundary-oriented loss function" is a proprietary loss function designed in this application, primarily constraining water body boundaries, unlike traditional loss functions that only focus on overall classification accuracy and ignore boundary details. The "Sobel operator" is a mature edge detection tool, essentially extracting gradient information from images through convolution operations. The Sobel operator can obtain the gradient fields of the predicted mask and the labeled ground truth, each containing gradient magnitude and gradient direction. This loss function ensures that the boundary direction predicted by the model is consistent with the actual boundary by constraining the orientation of the two gradient fields, while suppressing classification confidence jitter in edge regions—"classification confidence jitter" refers to the model's uncertainty in judging whether something is "water" or "land" in transition zones, leading to "sawtooth" fluctuations in the predicted boundary. By constraining the gradient direction, the model's judgment of boundary regions becomes more stable. The specific calculation process of the boundary-oriented loss function is as follows: the total loss is obtained by a weighted sum of the gradient magnitude loss and the gradient direction loss.
[0040]
[0041] In the formula, Total loss for boundary-oriented purposes; and These are the weighting coefficients; The gradient magnitude loss is used to constrain the consistency of the boundary clarity between the predicted mask and the labeled ground truth. The gradient direction loss is used to ensure that the boundary directions of both are consistent.
[0042] Among them, gradient magnitude loss The calculation method is as follows:
[0043]
[0044] In the formula, The total number of pixels in the image; To predict the mask number The gradient magnitude of each pixel; To label the truth value of the first The gradient magnitude of each pixel; This represents the absolute value operation, used to calculate the difference between the two. The smaller the difference, the closer the predicted boundary is to the true boundary.
[0045] Gradient direction loss The calculation method is as follows:
[0046]
[0047] In the formula, To predict the mask number The gradient direction of the nth pixel is related to the ground truth value. The angle between the gradient directions of each pixel; Let be the cosine of the included angle, and its value ranges from [-1, 1]. When =0°, =1, =0 indicates that the directions are completely consistent; when The larger, The smaller, The larger the value, the greater the penalty the model will suffer, thus forcing the model to adjust the orientation of the predicted boundary to align with the true boundary. This significantly suppresses classification confidence fluctuations in edge regions, reduces the "jagged" boundary phenomenon, and improves the geometric fidelity of the boundary, making the predicted boundary more closely match the orientation of the real water body boundary.
[0048] Step 6: Fuse the output feature maps of all decoding layers using a cross-layer weighted fusion strategy to generate a water boundary extraction mask with high continuity and high geometric fidelity.
[0049] Step 6 integrates feature information from all levels to generate the final water body boundary result. The principle behind this is weighted fusion, which balances the global morphology at higher levels with the local details at lower levels, avoiding the limitations of single-level features. The "cross-layer weighted fusion strategy" employs an adaptive weight allocation method, unlike traditional fixed-weight fusion. This method automatically learns the weights of the output feature maps at each decoding level through fully connected layers, eliminating the need for manual setting. Specifically, the weight coefficients of lower-level feature maps compensate for the loss of fine edge information, while the weight coefficients of higher-level feature maps ensure the integrity of the water body morphology. The learning process of the weight coefficients is synchronized with model training, gradually optimizing by minimizing the total loss function. The "water body boundary extraction mask" is the final output, essentially a binary image with the same size as the original image, clearly presenting the complete boundary of the water body. By combining the advantages of multi-scale features, a boundary mask with high continuity and high geometric fidelity is generated, completely solving the technical pain points of "jagged" and "fragmented" boundaries in traditional methods, while ensuring the integrity and detail accuracy of the boundary, meeting the practical application needs of high-resolution remote sensing water body extraction.
[0050] In step 1, the spatial resolution of the high-resolution remote sensing multispectral ground scene image is no less than 10 meters, and the spectral bands include at least the blue band, green band, red band, and near-infrared band, which are used to accurately distinguish the spectral gradient characteristics of the transition zone between water and land.
[0051] It should be explained that this section further defines the image parameters in step 1. Its purpose is to clarify the specific indicators of the original image, ensuring that the image can accurately capture the spectral gradient characteristics of the transition zone between water and land. The principle is as follows: "Spatial resolution of not less than 10 meters" means that the actual distance between a pixel on the image and the ground does not exceed 10 meters. This resolution can clearly distinguish the subtle differences between shallow water and land. If the spatial resolution is too low, it will lead to confusion in the spectral information of shallow water and land, making it impossible to capture boundary details. "The spectral bands must include at least the blue, green, red, and near-infrared bands." This is because water and land have different reflectance in different spectral bands—water has extremely low reflectance in the near-infrared band, while land has high reflectance. The blue and green bands can help distinguish the spectral differences between shallow and deep water. The four bands work together to accurately capture the spectral gradient characteristics of the transition zone, avoiding boundary misjudgments due to insufficient spectral information. This further improves the quality of the original data, providing a more accurate foundation for subsequent feature extraction and boundary focusing, ensuring the model's extraction accuracy in the transition zone region.
[0052] In step 2, the multi-level downsampling process adopts convolutional downsampling. The step size of each downsampling level is 2. The encoder feature pyramid contains at least 4 different resolution levels. The feature maps of each level are optimized by batch normalization and activation functions to enhance the discriminativeness of water features.
[0053] This section further defines the downsampling method and feature pyramid in step 2. Its purpose is to clarify the specific implementation of feature extraction and ensure the effectiveness of multi-scale features. "Convolutional downsampling" is a commonly used downsampling method in deep learning. It performs convolution operations on the image using convolution kernels, simultaneously reducing the image size. Compared to traditional pooling downsampling, convolutional downsampling better preserves the spatial correlation of features and avoids the loss of feature information. "Downsampling stride of 2" means that with each convolutional downsampling operation, the width and height of the image are reduced to half their original values. This stride setting reduces the computational cost of the model. This approach balances computational cost with ensuring a gradual increase in feature abstraction, achieving a feature progression "from detail to global." The requirement of "at least four different resolution levels" is crucial because four levels effectively cover the full scale of features, from subtle details to local edges, region morphology, and global contours. Insufficient levels would lead to incomplete feature scale coverage, hindering effective progressive focusing. Batch normalization, a mature model optimization technique, standardizes pixel values in feature maps at each level, preventing model training instability due to excessive feature value fluctuations. The activation function uses the ReLU function, expressed as follows: In the formula This function introduces nonlinear features as input feature values, filters out invalid negative feature values, and enhances the distinguishability between water and land features. This constraint ensures the stability and effectiveness of the encoder feature pyramid, providing high-quality multi-scale features for subsequent progressive attention tuning, and further improving the model's boundary extraction accuracy.
[0054] In step 3, the gated modulation progressive attention gating unit includes a gated modulation module and an attention recalibration module. The gated modulation module is used to unify the dimensions and preprocess the features of the three input signals, and the attention recalibration module is used to dynamically allocate attention weights according to the hierarchical depth encoding vector.
[0055] This gating unit consists of two modules that work together to achieve differentiated attention enhancement. The "gating modulation module" addresses the issue of inconsistent dimensions among the three input signals. Since the three input signals come from different model levels, their feature dimensions may differ. Direct input would prevent the model from calculating. The gating modulation module adjusts the three input signals to the same dimension through convolution operations and normalization, and performs feature preprocessing to ensure the feasibility of subsequent attention calculations. The "attention recalibration module" is the core of this unit. Its function is to dynamically allocate attention weights to the three input signals based on the hierarchical depth encoding vector. The principle is consistent with the calculation of attention weights in step 4: using learnable gating parameters combined with the priority information of the hierarchical depth encoding vector, it differentiates the weights for global and local features, with higher levels emphasizing global features and lower levels emphasizing local features. This constraint further clarifies the implementation of the main modules, ensuring that the unit can stably achieve progressive attention focusing, while improving the model's interpretability—clearly tracing the logic of attention weight allocation and avoiding the drawbacks of the "black box operation" of traditional attention mechanisms.
[0056] In step 4, the hierarchical depth encoding vector is a one-dimensional vector with the same dimension as the number of decoding layers. It is generated by one-hot encoding and is used to distinguish the feature priorities of different decoding layers. The encoding vector corresponding to higher-level decoding has a higher weight than that of lower-level decoding, ensuring the dominant role of global morphological features.
[0057] This section further defines the hierarchical depth coding vector, clarifying its specific form, generation method, and function to facilitate understanding how it achieves priority differentiation of multi-scale features. The principle is as follows: a "one-dimensional vector" means that the vector contains only one dimension of value. For example, if there are 4 decoding levels, the dimension of the vector is 4, and its form can be represented as [w1, w2, w3, ...]. [w4], where wi is the weight coefficient of the i-th decoding level; "Generated by one-hot encoding", one-hot encoding is a simple and efficient encoding method. In essence, it uses a vector with only one element as 1 and the rest as 0 to distinguish different levels. For example, the encoding vectors of the four decoding levels can be represented as [1,0,0,0] (1st level), [0,1,0,0] (2nd level), [0,0,1,0] (3rd level), [0,0,0,1] (4th level). This encoding method can clearly distinguish different levels and avoid level confusion; "The dimension is consistent with the number of decoding levels", ensuring that each decoding level has its own exclusive encoding vector to achieve one-to-one priority distinction; "The weight of the encoding vector corresponding to the higher level of decoding is higher than that of the lower level", that is, the wi value of the higher level is greater than the wi value of the lower level. The purpose is to ensure the dominant role of global morphological features and avoid excessive interference from local detail features, which would cause the boundary to deviate from the overall contour. This constraint clarifies the priority of multi-scale features, effectively avoids semantic conflicts between features at different levels, ensures the orderly progress of progressive boundary focusing, and further improves the stability of the model's boundary extraction.
[0058] The learnable gating parameters in step 4 include the weight matrix and the bias vector, which are iteratively optimized during model training using the stochastic gradient descent algorithm. The optimization objective is to minimize the semantic conflict of features at each level and improve the synergy of boundary features.
[0059] This section further defines the learnable gating parameters, clarifying their specific type, optimization method, and optimization objective. The "learnable gating parameters" are the core of the gating unit's dynamic attention adjustment, including the weight matrix W and the bias vector b. The weight matrix W is used to weight the three input signals, and the bias vector b is used to adjust the output offset, preventing abnormal attention weights due to minor fluctuations in the input signals. "Optimized using stochastic gradient descent" refers to the fact that stochastic gradient descent is a mature parameter optimization algorithm in deep learning. Its principle is to calculate the gradient of the loss function and gradually adjust the parameter values to minimize the loss function. The parameter update formula for each iteration is:
[0060]
[0061]
[0062] In the formula, , These are the updated weight matrix and bias vector after iteration; , These are the parameters before the iteration; The learning rate; , These represent the gradients of the loss function with respect to the weight matrix and the bias vector, respectively. The optimization objective is to minimize semantic conflicts between features at different levels. Semantic conflict refers to inconsistencies in the indications provided by features at different levels for boundary extraction. Through parameter optimization, features at different levels can work together, with higher levels providing global guidance and lower levels supplementing details, thus improving the synergy of boundary features. This constraint ensures that the gating parameters can be progressively optimized, making the allocation of attention weights more reasonable, further improving the progressive attention mechanism, and reducing errors in boundary extraction.
[0063] The calculation process of the boundary-guided loss function in step 5 is as follows: First, the gradient magnitude and gradient direction of the predicted mask and the labeled ground truth are calculated using the Sobel operator; then, the cosine similarity of the gradient directions of the two is calculated, and higher loss weights are applied to regions with low similarity; finally, the gradient magnitude loss and the gradient direction loss are weighted and summed to obtain the total boundary-guided loss.
[0064] This section further details the calculation process of the boundary-guided loss function, clarifying its specific implementation steps and explaining how it constrains boundary prediction results. The principle is as follows: The calculation process consists of three steps, progressively implementing boundary constraints. The first step, "calculating the gradient magnitude and direction using the Sobel operator," involves using two convolution kernels, one horizontal and one vertical. Convolution operations are used to calculate the gradients of the image in the horizontal and vertical directions, respectively. The gradient magnitude and direction are then calculated using the following formulas:
[0065] gradient magnitude In the formula The gradient is in the horizontal direction. The gradient is in the vertical direction. The larger the gradient magnitude, the more likely the pixel is to be a boundary region.
[0066] gradient direction In the formula The arctangent function is used to calculate the specific direction of the gradient, i.e., the direction of the boundary extension.
[0067] The second step is to "calculate the cosine similarity of the gradient directions and apply higher loss weights to regions with low similarity." Cosine similarity measures the consistency between two gradient directions, with a value range of [-1, 1]. The closer the similarity is to 1, the more consistent the two directions are; the closer the similarity is to -1, the more opposite the two directions are. In this case, the boundary prediction deviation of the region is relatively large, and a higher loss weight needs to be applied. The weight allocation can be achieved through the following formula:
[0068]
[0069] In the formula, For the first Loss weights for each pixel, To predict the angle between the gradient and the true gradient, this formula ensures that the larger the deviation, the greater the weight and the stronger the correction.
[0070] The third step is to "weightedly sum the gradient magnitude loss and the gradient direction loss," which combines the clarity of the boundary and the consistency of the direction to obtain the total loss. The specific formula is shown in step 5 and will not be repeated here. This constraint clarifies the calculation logic of the loss function, ensuring that it can effectively constrain the boundary prediction results, further suppress edge jitter, reduce "jagged" boundaries, and improve the geometric fidelity of the boundary.
[0071] In step 6, the cross-layer weighted fusion strategy adopts an adaptive weight allocation method. The weight coefficients of the output feature maps of each decoding layer are learned through the fully connected layer. The weight coefficients of the low-level feature maps are used to compensate for the loss of fine edge information, while the weight coefficients of the high-level feature maps are used to ensure the integrity of the water body morphology.
[0072] This section further defines the cross-layer weighted fusion strategy, clarifying the specific implementation of the fusion method. It is explained as follows: "Adaptive weight allocation" differs from traditional fixed-weight fusion. Its advantage is that it can automatically adjust weights based on the feature differences of different scenarios, adapting to different water boundary scenarios. "Learning weight coefficients through fully connected layers" refers to the fully connected layers, a mature module in deep learning used for feature integration and weight learning. Essentially, it uses a series of learnable parameters to weight and sum the features of each level of feature maps. The learning of weight coefficients is synchronized with model training, gradually optimizing by minimizing the total loss function to ensure the rationality of weight allocation. "Weight coefficients of low-level feature maps are used to compensate for the loss of subtle edge information." Because low-level feature maps retain more local details, reasonable weight allocation can prevent these details from being masked by higher-level features, thus reducing the "fragmented" boundary phenomenon. "Weight coefficients of high-level feature maps are used to ensure the integrity of the water body morphology." Because high-level feature maps provide the global water body morphology, higher weights ensure that the final boundary mask does not deviate from the overall outline of the water body, avoiding the problem of "boundary misalignment." This constraint ensures that multi-scale features can be effectively integrated, taking into account both the detail accuracy and overall integrity of the boundary, and further improving the continuity and geometric fidelity of the water body boundary.
[0073] The method also includes a model training step: constructing a training dataset containing high-resolution remote sensing multispectral ground scene images and corresponding ground truth values of water body boundary annotations, inputting the training dataset into the model, using the weighted sum of the boundary-guided loss function and the cross-entropy loss function as the total loss function, and iteratively training until the model converges to ensure the model's boundary extraction accuracy in the transition zone region.
[0074] This section supplements the model training steps, clarifying how the model achieves optimal performance through training and improving the completeness of the application. The principle is as follows: "Model training steps" are a prerequisite for deep learning models to achieve accurate predictions, because learnable parameters such as gating parameters and fully connected layer weights need to be trained to reach their optimal values. First, "constructing a training dataset" consists of two parts: high-resolution remote sensing multispectral ground scene images and corresponding ground truth annotations for water body boundaries. The dataset should contain at least 1000 images to ensure the model can fully learn the water body boundary features under different scenarios. Second, "inputting the dataset into the model" involves batch training, allowing the model to gradually learn the correlation between image features and ground truth boundary values. "Using the weighted sum of the boundary-guided loss function and the cross-entropy loss function as the total loss function," the cross-entropy loss function is a mature loss function commonly used in classification tasks to measure the overall classification accuracy of the model. Combined with the boundary-guided loss function, it can balance overall classification accuracy and boundary detail precision. The formula for the total loss function is:
[0075]
[0076] In the formula, The total loss during model training is represented by γ; γ is the weight coefficient. Boundary-oriented loss function; The cross-entropy loss function is calculated using the following formula:
[0077]
[0078] In the formula For the first The labeled true value of each pixel. The model predicts the probability that the pixel is water. Finally, iterates the training until the model converges. The criterion for model convergence is that the value of the total loss function no longer decreases after 10 consecutive iterations. At this point, the model parameters have reached their optimal level, enabling stable extraction of water body boundaries. This step ensures that after training, the model can accurately capture the spectral gradient features of the transition zone region and achieve high-precision boundary extraction even in complex scenes, further improving the model's practicality.
[0079] The water body boundary mask extracted by this method improves the boundary F1 score by no less than 5% compared with the traditional U-Net+attention scheme in complex ground scenes such as wetland transition zones and seasonal water level fluctuation areas. It also significantly reduces edge jaggedness and breakage, improves model interpretability compared with traditional methods, and meets the practical application requirements of high-resolution remote sensing water body extraction in terms of boundary continuity and geometric fidelity.
[0080] Complex ground scenarios such as wetland transition zones and areas with seasonal water level fluctuations are where water body boundaries are most prone to "jagged" and "fragmented" shapes, and traditional methods perform poorly in these scenarios. The "boundary F1 score" is a core indicator for measuring boundary extraction accuracy, and its calculation formula is as follows:
[0081]
[0082] In the formula, Precision refers to the proportion of pixels that the model predicts as water body boundaries but are actually water body boundaries; Recall refers to the proportion of pixels that are actually water body boundaries but were correctly predicted by the model; and the F1 score ranges from 0 to 1, with a higher score indicating higher boundary extraction accuracy.
[0083] The foregoing has only described certain exemplary embodiments of the present invention by way of illustration. Undoubtedly, those skilled in the art can modify the described embodiments in various ways without departing from the spirit and scope of the present invention. Therefore, the foregoing drawings and descriptions are illustrative in nature and should not be construed as limiting the scope of protection of the claims of the present invention.
Claims
1. A water boundary extraction method based on a progressive attention mechanism, characterized in that, The application of automated water body boundary extraction in high-resolution remote sensing imagery includes the following steps: Step 1: Acquire high-resolution remote sensing multispectral ground scene images. The images cover lake, reservoir, and river water areas, as well as transition zones between water and land. The transition zones include shallow water areas, wetland edges, and areas with seasonal water level fluctuations. The images also retain subtle feature information of water body boundaries. Step 2: Perform multi-level downsampling processing on the input image obtained in Step 1 to construct an encoder feature pyramid. The encoder feature pyramid contains multiple feature maps at different resolution levels. Each level of feature map corresponds to water features at different scales. Among them, the high-level feature maps focus on global water body morphological semantic information, while the low-level feature maps focus on local water body edge detail information. Step 3: Set up an independent gated modulation progressive attention gating unit at each decoding level of the decoder. The gated modulation progressive attention gating unit corresponds one-to-one with the feature map of each level of the encoder feature pyramid, and is used to achieve differentiated enhancement of water body boundary features at different resolution levels. Step 4: The gated modulation progressive attention gating unit receives three input signals, namely the encoder feature map corresponding to the current decoding level, the feature map output from the previous decoding level, and the layer depth encoding vector. The attention weight contribution of the three input signals is dynamically adjusted through learnable gating parameters to achieve progressive boundary focusing from coarse to fine. The gating unit corresponding to the higher-level decoding focuses on global water body morphology perception, while the gating unit corresponding to the lower-level decoding focuses on local edge fine localization. Step 5: After outputting feature maps at each decoding level, a boundary-guided loss function is introduced. The boundary-guided loss function extracts the gradient field of the current level prediction mask and the gradient field of the labeled ground truth through the Sobel operator, performs orientation alignment constraints on the two gradient fields, and suppresses the jitter of classification confidence in the edge region, thereby improving the uniformity of classification confidence in the edge region. Step 6: Fuse the output feature maps of all decoding layers using a cross-layer weighted fusion strategy to generate a water boundary extraction mask with high continuity and high geometric fidelity.
2. The water boundary extraction method based on progressive attention mechanism according to claim 1, characterized in that, The high-resolution remote sensing multispectral ground scene image mentioned in step 1 has a spatial resolution of no less than 10 meters and includes at least blue, green, red and near-infrared bands in its spectral bands, which are used to accurately distinguish the spectral gradient characteristics of the transition zone between water and land.
3. The water boundary extraction method based on a progressive attention mechanism according to claim 1, characterized in that, The multi-level downsampling process in step 2 adopts convolutional downsampling, with a step size of 2 for each level of downsampling. The encoder feature pyramid contains at least 4 different resolution levels. The feature maps of each level are optimized through batch normalization and activation functions to enhance the distinguishability of water features.
4. The water boundary extraction method based on progressive attention mechanism according to claim 1, characterized in that, The gated modulation progressive attention gating unit in step 3 includes a gated modulation module and an attention recalibration module. The gated modulation module is used to perform dimensional unification and feature preprocessing on the three input signals, and the attention recalibration module is used to dynamically allocate attention weights according to the hierarchical depth coding vector.
5. The water boundary extraction method based on a progressive attention mechanism according to claim 1, characterized in that, The layer depth encoding vector mentioned in step 4 is a one-dimensional vector with the same dimension as the number of decoding layers. It is generated by one-hot encoding and is used to distinguish the feature priority of different decoding layers. The encoding vector corresponding to higher-level decoding has a higher weight than that of lower-level decoding, ensuring the dominant role of global morphological features.
6. The water boundary extraction method based on a progressive attention mechanism according to claim 1, characterized in that, The learnable gating parameters mentioned in step 4 include the weight matrix and the bias vector, which are iteratively optimized during model training using the stochastic gradient descent algorithm. The optimization objective is to minimize the semantic conflict of features at each level and improve the synergy of boundary features.
7. The water boundary extraction method based on progressive attention mechanism according to claim 1, characterized in that, The calculation process of the boundary-guided loss function in step 5 is as follows: First, the gradient magnitude and gradient direction of the predicted mask and the labeled ground truth are calculated using the Sobel operator; then, the cosine similarity of the gradient directions of the two is calculated, and higher loss weights are applied to regions with low similarity; finally, the gradient magnitude loss and the gradient direction loss are weighted and summed to obtain the total boundary-guided loss.
8. The water boundary extraction method based on progressive attention mechanism according to claim 1, characterized in that, The cross-layer weighted fusion strategy described in step 6 adopts an adaptive weight allocation method, which learns the weight coefficients of the output feature maps of each decoding layer through a fully connected layer. The weight coefficients of the low-level feature maps are used to compensate for the loss of fine edge information, while the weight coefficients of the high-level feature maps are used to ensure the integrity of the water body morphology.
9. The water boundary extraction method based on a progressive attention mechanism according to claim 1, characterized in that, The method also includes a model training step: constructing a training dataset containing high-resolution remote sensing multispectral ground scene images and corresponding ground truth values of water body boundary annotations, inputting the training dataset into the model, using the weighted sum of the boundary-guided loss function and the cross-entropy loss function as the total loss function, iteratively training until the model converges, ensuring the model's boundary extraction accuracy in the transition zone region.
10. The water boundary extraction method based on a progressive attention mechanism according to any one of claims 1 to 9, characterized in that, The water body boundary mask extracted by the method improves the boundary F1 score by no less than 5% compared with the traditional U-Net+attention scheme in complex ground scenes such as wetland transition zones and seasonal water level fluctuation areas. It also significantly reduces edge jaggedness and breakage, improves model interpretability compared with traditional methods, and meets the practical application requirements of high-resolution remote sensing water body extraction in terms of boundary continuity and geometric fidelity.
Citation Information
Patent Citations
Automatic image segmentation technology based on convolutional neural network
CN120807537A
Sea-land image segmentation method based on cascade cross-scale attention and boundary perception
CN120876866A