Polymorphic water body segmentation method based on morphological prior and hybrid expert network
By employing a method based on morphological priors and hybrid expert networks, the segmentation challenge of narrow rivers and small ponds in remote sensing images was solved, achieving efficient and accurate segmentation of water bodies with different shapes and improving the ability to identify water bodies in remote sensing images.
Patent Information
- Application Number
- CN202610129423.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-30
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2046-01-30
AI Technical Summary
Existing remote sensing image processing methods struggle to accurately identify small-scale water bodies such as narrow rivers and small ponds in complex backgrounds. Furthermore, existing networks fail to explicitly distinguish between different water body morphologies, leading to missed detections of river breaks or small water bodies. Spectral indices are underutilized, and loss functions fail to effectively optimize for water bodies with unique morphologies.
A multi-morphological water body segmentation method based on morphological prior and hybrid expert network is adopted. A coarse water body mask is generated by calculating the normalized differential water body index, morphological factors are extracted and mapped into morphological embedding vectors, regional weights are calculated using a routing network, expert features of rivers, lakes and ponds are constructed, and multi-morphological water body feature fusion is achieved by combining spectral prior guidance and morphological weighted loss function.
It significantly improves the segmentation integrity and topological accuracy of multi-form water bodies, increases the recall rate of slender rivers and small ponds, maintains high inference efficiency, and solves the problem of water body segmentation in complex backgrounds.
Smart Images

Figure CN121616831A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of remote sensing image processing and land cover interpretation technology, specifically to a multimorphic water body segmentation method based on morphological priors and hybrid expert networks. Background Technology
[0002] In the fields of remote sensing image processing and land cover interpretation, accurate extraction of water body information is of significant application value for water resource management, environmental monitoring, and disaster assessment. Traditional water body extraction methods mainly include thresholding methods based on spectral indices, such as using the Normalized Difference Water Index (NDDI) or improved NDDI, combined with global or adaptive thresholds to distinguish water bodies from non-water bodies. While these methods are simple to implement and computationally efficient, they are sensitive to factors such as sensor differences, changes in imaging conditions, shadow interference, and turbid water, and are prone to false positives or false negatives, especially in complex background environments. Their ability to identify small-scale water bodies such as narrow rivers and small ponds is particularly limited.
[0003] With the development of deep learning technology, semantic segmentation methods based on convolutional neural networks have been widely applied to water body extraction tasks in remote sensing imagery. For example, using fully convolutional networks such as U-Net and DeepLab for pixel-level classification can effectively identify water targets such as medium and large lakes and reservoirs. However, for water bodies with special morphological structures, such as long rivers, narrow ditches, and small ponds in high-resolution images, existing networks often struggle to maintain the integrity and connectivity of their morphology due to their small size, extreme aspect ratios, and complex surrounding backgrounds. This can easily lead to problems such as missed detections of broken rivers or small water bodies.
[0004] To further improve the segmentation performance of water bodies at multiple scales, some studies have introduced multi-scale feature pyramids and attention mechanisms to enhance the network's ability to perceive targets at different scales. Other works have attempted to use spectral indices as saliency maps or additional input channels to guide the network to focus on potential water body regions. However, existing methods generally treat "water bodies" as a single category and do not explicitly distinguish between different subtypes such as rivers, lakes, and ponds at the model structure and loss function levels. This results in an uneven ability of the network to express features of different water body forms, making it difficult to simultaneously ensure the connectivity of long, narrow rivers, the integrity of large lakes, and the detection rate of small ponds.
[0005] Furthermore, spectral indices often limit their use of prior information to threshold segmentation or simple weighting, failing to deeply integrate with the network's internal routing mechanisms and attention structures, thus restricting their effectiveness. On the other hand, commonly used loss functions primarily focus on class imbalance, while underutilizing geometric information about water bodies, such as area and slenderness, making it difficult to effectively optimize the training process for water bodies with unique shapes.
[0006] In view of the above, this application is hereby submitted. Summary of the Invention
[0007] This invention provides a multimorphic water body segmentation method based on morphological priors and hybrid expert networks, which can at least partially improve the above-mentioned problems.
[0008] To achieve the above objectives, the present invention adopts the following technical solution:
[0009] A multimorphic water body segmentation method based on morphological priors and hybrid expert networks includes: Acquire the image data to be processed and preprocess the image data. Based on the preprocessed image data, calculate the normalized difference water index and the improved normalized difference water index. The pre-trained multimorphic water body segmentation model is used to process the normalized differential water body index or the improved normalized differential water body index, specifically as follows: Based on the normalized differential water body index or the improved normalized differential water body index, a coarse water body binary mask is generated. Connectivity analysis is performed on the coarse water body binary mask to obtain the morphological factor vector. The morphological factors are mapped to morphological embedding vectors, and the regional weights corresponding to each connected water body region are calculated through a routing network. The regional weights are then mapped to pixel-level morphological routing weights. Based on the image data, shared features are constructed, and river expert features, lake expert features, and pond expert features are extracted based on the shared features. Then, spectral prior-guided feature fusion processing is performed on the shared features and each expert feature to obtain fused features. The fused features are decoded and classified to generate a water body prediction probability map.
[0010] In summary, this method first utilizes spectral indices to generate a coarse water body mask, calculating morphological factors such as area, aspect ratio, slenderness, and skeleton length for each connected water body region, and mapping them into low-dimensional morphological embeddings to describe morphological subtypes such as rivers, lakes, and ponds. Secondly, NDWI / MNDWI are mapped to prior features through a lightweight coding network, and input together with the morphological embeddings into the routing network and attention module to achieve joint spectral-morphological prior guidance. Thirdly, based on shared backbone features, river expert branches, lake expert branches, and pond expert branches are set, employing structural designs adapted to slender structures, large-scale regions, and small-scale targets, respectively. The three expert features are weighted and fused using routing weights to form multi-morphological water body features. Finally, the multi-expert features are weighted and fused based on pixel-level routing weights, and the resulting water body probability map is obtained through decoding and classification. Furthermore, it introduces weight factors based on connected region area and slenderness length on the basic BCE / Dice loss, assigning greater loss weights to slender rivers and small ponds, improving their recall and connectivity. It can effectively utilize spectral and morphological priors, and significantly improve the segmentation integrity and topological accuracy of multi-morphological water bodies while maintaining high inference efficiency. Attached Figure Description
[0011] Figure 1 This is a flowchart illustrating the multimorphic water body segmentation method based on morphological priors and hybrid expert networks provided in this embodiment of the invention.
[0012] Figure 2 This is a schematic diagram of the framework of the multimorphic water body segmentation method based on morphological prior and hybrid expert network provided in the embodiments of the present invention.
[0013] Figure 3 This is a schematic diagram of the morphological prior extraction module provided in an embodiment of the present invention.
[0014] Figure 4 This is a schematic diagram of a morphology-type driven hybrid expert network structure provided in an embodiment of the present invention. Detailed Implementation
[0015] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0016] refer to Figure 1 , Figure 2As shown, the first embodiment of the present invention discloses a multi-morphological water body segmentation method based on morphological priors and hybrid expert networks, which can be executed by a multi-morphological water body segmentation device based on morphological priors and hybrid expert networks (hereinafter referred to as the segmentation device), specifically, by one or more processors within the segmentation device, to implement the following method: S1, acquire the image data to be processed, and preprocess the image data. Based on the preprocessed image data, calculate the normalized difference water index and the improved normalized difference water index. Specifically, step S1 further includes: acquiring image data to be processed and preprocessing the image data, wherein the image data is a multispectral or fused remote sensing image containing water bodies, and the preprocessing includes radiometric calibration, atmospheric correction and geometric correction. Based on the preprocessed image data, the normalized difference water index and the improved normalized difference water index are calculated, and the formula is as follows: , Wherein, NDWI is the Normalized Difference Water Index, MNDWI is the Modified Normalized Difference Water Index, G is the green band, NIR is the infrared band, and SWIR is the shortwave infrared band. To prevent constants with a denominator of zero.
[0017] In this embodiment, remote sensing image data to be processed is acquired. This image data should be multispectral or fused remote sensing images containing various forms of water bodies such as rivers, lakes, and ponds, with a spatial resolution preferably better than 10 meters to preserve sufficient ground feature details. Subsequently, the image data undergoes preprocessing, including radiometric calibration, atmospheric correction, and geometric correction. This preprocessing aims to eliminate sensor errors, atmospheric scattering and absorption effects, and geometric distortion, ultimately obtaining a standardized image with uniform reflectance physical meaning and precise spatial alignment, ensuring a uniform reflectance scale and pixel-level spatial alignment. This preprocessing workflow is a mature technology in the field of remote sensing and can be efficiently completed using professional software such as SNAP and Sen2Cor, laying a reliable data foundation for subsequent accurate segmentation.
[0018] Based on the preprocessed image data, the Normalized Difference Water Index (NDWI) and the Modified Normalized Difference Water Index (MNDWI) were calculated. NDWI and MNDWI are classic water-sensitive spectral indices that effectively highlight the spectral differences between water bodies and features such as vegetation and buildings. NDWI / MNDWI calculations involve simple algebraic operations per pixel with a time complexity of O(N), making them suitable for large-scale imagery.
[0019] The pre-trained multimorphic water body segmentation model is used to process the normalized differential water body index or the improved normalized differential water body index, specifically as follows: S2, Based on the normalized differential water body index or the improved normalized differential water body index, a coarse water body binary mask is generated, and a connected region analysis is performed on the coarse water body binary mask to obtain the morphological factor vector. Specifically, step S2 further includes: generating a coarse water body binary mask based on the normalized differential water body index or the improved normalized differential water body index, through a global threshold, an adaptive threshold, or a lightweight initial network; The coarse water body binary mask is subjected to connected region marking processing to obtain each connected region. And calculate the connected components. The corresponding normalized area The aspect ratio of the minimum bounding rectangle slender length ,in, The area of the image. The length of the minimum bounding rectangle. The width of the minimum bounding rectangle. Let k be the perimeter, and k be the index of the connected component. Connected region The area; For connected regions The details are refined to obtain the centerline skeleton. Calculate the distance distribution from each pixel to the skeleton. Based on the distance distribution from all pixels to the skeleton, the average distance from pixels to the skeleton within the k-th connected water region is calculated. , Represents the i-th connected region. Let be the two-dimensional coordinates of the pixel within the i-th connected region. Indicates the centerline skeleton Pixels; normalized area The aspect ratio of the minimum bounding rectangle slender length The average distance from a pixel to the skeleton within the k-th connected water region. Perform max-min normalization to obtain the morphological factor vector. .
[0020] In this embodiment, a coarse binary water mask is generated using the calculated NDWI or MNDWI, through a global threshold, an adaptive threshold (such as the Otsu algorithm), or a lightweight initial convolutional network. This mask aims to quickly and initially identify potential water body regions. Subsequently, connected component analysis is performed on this coarse mask to identify each individual connected water body region.
[0021] For each connected region, its geometric morphological feature factor is calculated to quantify its morphological characteristics, specifically including: area. The aspect ratio of the minimum bounding rectangle slender length The average distance from a pixel to the skeleton within the k-th connected water region. After normalizing the four factors calculated above, they are concatenated to form the morphological factor vector of the connected region. The innovation of this step lies in its transformation of geometric measurements in traditional image processing into structured prior information that can be used to drive deep neural networks, providing a quantitative basis for subsequent differentiation of water morphological subtypes.
[0022] S3, map the morphological factors to morphological embedding vectors, calculate the regional weights corresponding to each connected water body region through the routing network, and map the regional weights to pixel-level morphological routing weights. Specifically, step S3 further includes: using a morphological embedding mapping function Mapping morphological factor vectors to morphological embedding vectors , ,in, This is an implementation of the morphological embedding mapping function, i.e., a multilayer perceptron (MLP). for A real vector space; where For morphological embedding vectors The dimension (i.e., the number of embedded channels); Based on the predefined morphological subtype and morphological embedding vector, the corresponding region-level weight is calculated through the routing network, using the following formula: Among them, the predefined morphological subtypes include rivers, lakes, and ponds. The river region-level weight for the k-th connected region. The lake region-level weight for the k-th connected region. The pond region-level weight for the k-th connected region. For normalized exponential functions, This is the weight matrix of the last linear layer of the routing network, used to... Logits mapped to three morphological subtypes (river / lake / pond); typical dimension is , This is the bias vector of the last linear layer in the routing network; typical dimensions are... ; Mapping the region-level weights to the pixel-level yields the morphological routing weights for each pixel within the i-th connected region. It performs K weight broadcasting operations for connected components. For all pixels, the weight of that region is directly reused, making K is the number of connected components. H represents the height (number of rows) of the input image (i.e., image data), and W represents the width (number of columns) of the input image. This avoids performing dense gated network forward computation on all pixels of the image. The shape routing weights of pixels within the k-th connected region.
[0023] Please see Figure 3 , Figure 3 This demonstrates how to extract morphological factors from a coarse water body mask and map them to morphological embeddings and routing weights. In this embodiment, the morphological factor vector is input into a multilayer perceptron and mapped to a low-dimensional morphological embedding vector, which is a high-order morphological feature representation. Based on the morphological embedding vector, a lightweight routing network (typically a linear layer with a Softmax activation function) is used to calculate the weights of the current connected region belonging to three predefined morphological subtypes (river, lake, pond).
[0024] To apply region-level weights to pixel-level feature fusion, a weight broadcasting operation is performed: for all pixels belonging to a connected region, their pixel-level morphological routing weights are directly assigned the weights of that region. This design is a key efficiency optimization point of this invention. Traditional hybrid expert networks require calculating routing weights for each pixel, resulting in a huge computational burden. This invention, based on a strategy of first coarsely dividing connected regions and then routing, only needs to perform routing calculations once for a limited number of connected regions. The results are then broadcast and reused, decoupling the computational overhead introduced by the MoE module from the image resolution. This maintains extremely high inference efficiency while ensuring the advantages of multi-expert collaboration.
[0025] S4. Construct shared features based on image data, extract expert features for rivers, lakes, and ponds based on the shared features, and perform spectral prior-guided feature fusion processing on the shared features and each expert feature to obtain fused features. Decode and classify the fused features to generate a water body prediction probability map.
[0026] Specifically, step S4 further includes: using a CNN or CNN-Transformer hybrid network to extract multi-scale features from the image data and the preset NDWI / MNDWI channels, and obtaining shared features based on the multi-scale features. That is, shared features are obtained at a certain scale (such as 1 / 8 resolution).
[0027] The normalized differential water index corresponding to each pixel in the i-th connected region. And improved normalized difference water index Let it be a two-dimensional vector and for binary vectors Perform a linear transformation to generate an attention bias. This is used to improve attention scores in potential water bodies, where T is the transpose. These are the linear transformation coefficients. For bias terms; Through pixel-by-pixel feature coding network Each binary vector Mapped to high-dimensional spectral prior eigenvectors and all high-dimensional spectral prior eigenvectors The combination yields the spectral prior feature map P, where the feature encoding network... Use shallow neural networks (such as MLP or 1) 1. Convolution). In the multi-head attention module, the spectral prior feature map P is used to generate prior query features and fuse them with the query features generated from shared features.
[0028] Three parallel branches are set up: a river expert network, a lake expert network, and a pond expert network, which will share features. As a priori branch, it is introduced within each expert branch in the form of query bias and attention bias to guide feature aggregation for three types of water bodies: rivers, lakes, and ponds. The first module within the river expert network, lake expert network, and pond expert network is an attention module with Q / K / V, a sub-network with multi-head self-attention as its core, preferably implemented as a Transformer encoder block. The attention modules of the river, lake, and pond experts adopt a similar structure, and their core computation can be represented as follows: the query feature (Q), key feature (K), and value feature (V) are all generated from shared feature maps and spectral prior feature maps through linear transformation. The attention weights are determined by the similarity between Q and K and based on n... i The biases constructed are jointly determined, and the final weighted summation of the value features V yields the expert output features.
[0029] The first module of the river expert network is called for preprocessing to obtain initial river expert features. Specifically: Based on shared characteristics Generate key feature matrix Sum characteristic matrix , , ,in, The key feature projection matrix of the river expert branch. The value feature projection matrix of the river expert branch. For key / query feature dimensions, For value feature dimension, For shared features The number of channels, i.e., the feature dimension corresponding to each pixel position. The value is a real number, and N is the number of pixels (or patches) in the current feature map after it is flattened. Based on shared characteristics Generate the first query feature ,in, This is the first query projection matrix in the river expert network; The second query feature is generated based on the spectral prior feature map P. ,in, This is the second query projection matrix in the river expert network. Let P be the number of channels in the spectral prior feature map; The first and second query features are linearly combined according to their weight coefficients to obtain the final query features. , The weighting coefficients of the spectral prior query component in the river expert branch are learnable scalars. Based on attention bias Generate logits bias Based on the logits bias, final query features, and key feature matrix, the attention logits matrix of the river expert branch is determined. , The attention logits matrix of the th Line 1 List Indicates the first The position is the first Attention score for each position The scaling factor for controlling the NDWI bias intensity; row-wise attention logits matrix Softmax normalization is performed to obtain the attention weight matrix of the river expert network. , , its first The line represents the first Attention weights of each position to all positions; The initial river expert features are obtained by weighting and summing the value feature matrix using the attention weight matrix. , , its first The line indicates that, under the combined effect of water body spectral priors and attention mechanisms, the first... River expert feature representation at each pixel location; Similarly, the first module of the lake expert network is used for preprocessing to obtain the initial lake expert features. The first module of the pond expert network is used for preprocessing to obtain the initial pond expert features. .
[0030] Call subsequent modules of the river expert network to process the initial river expert features. The data is processed to obtain the final river expert features. , This is a follow-up module to the River Expert Network, which employs strip convolution or directional attention modules to enhance the modeling of slender, curved structures and connectivity. Call subsequent modules of the lake expert network to refine the initial lake expert features. The process is performed to obtain the final lake expert characteristics. , This is a follow-up module of the Lake Expert Network, which employs structural modules such as large receptive field convolution and hollow spatial pyramid pooling to improve the ability to model large water bodies and their contexts. Call subsequent modules of the pond expert network to refine the initial pond expert features. The process is performed to obtain the final pond expert characteristics. , This is a follow-up module to the Pond Expert Network, which employs a high-resolution and small convolutional kernel structure to enhance the capture of small targets and boundary details.
[0031] The morphological routing weights are used to perform pixel-level weighted fusion of river expert features, lake expert features, and pond expert features to obtain fused features. ; Fusion features With shared features Residual superposition processing is performed to obtain the fused feature map. ,in, The residual weights are set as learnable global scalars. Let the river region-level weight be the i-th connected region. Let be the lake region-level weight for the i-th connected region. The pond region-level weight for the i-th connected region; Fuse feature maps The data is input into a preset decoder and classification head module, where it undergoes upsampling and convolutional prediction processing to obtain the water body probability value for each pixel and generate a water body prediction probability map.
[0032] In this embodiment, preferably, it further includes: thresholding the water body prediction probability map and refining the boundary of the water body prediction probability map using conditional random fields and morphological operations; The river skeleton was extracted and small fractures were bridged to improve the connectivity of the river network. Areas smaller than the preset value and with abnormal shapes were removed.
[0033] In this embodiment, the original image and NDWI and MNDWI index maps are used as input. A shared backbone network (such as ResNet, Swin Transformer, or a hybrid structure thereof) is used to extract multi-scale shared backbone feature maps. That is, shared features are obtained at a certain scale (e.g., 1 / 8 resolution). Simultaneously, the NDWI and MNDWI index maps are mapped to a spectral prior feature map P that matches the network feature dimension through a lightweight encoding network; this feature map is injected as a guiding signal into subsequent modules. In the multi-head attention module, the spectral prior feature map P is used to generate prior query features and fuse them with the query features generated from the shared features.
[0034] Based on shared features, three parallel branches are set up: river expert, lake expert, and pond expert. Taking the river expert branch as an example, it contains an NDWI-guided multi-head attention module to enhance feature responses in elongated water bodies.
[0035] Specifically, the NDWI-guided multi-head attention module generates a first query vector based on a shared feature map and a second query vector based on a spectral prior feature map, then weights and fuses the two. Simultaneously, the original NDWI / MNDWI indices at each pixel location are mapped to a bias term in the attention score through a linear transformation. This allows the network to prioritize attention weights for regions with higher NDWI responses during feature aggregation, thereby enhancing the saliency representation of water bodies. The river expert branch focuses on modeling strip-shaped, elongated, and connected water bodies. Building upon the aforementioned prior-guided multi-head attention module, it can further incorporate strip convolution or directional convolution structures, enabling the network to focus more on regions continuously distributed and narrow along the river channel when aggregating features, thus enhancing its ability to extract and preserve the skeleton and connectivity of meandering rivers. The lake expert branch focuses on capturing large-scale spatial contextual information. Its structure can include modules such as large-kernel convolution, dilated convolution, and spatial pyramid pooling, effectively integrating features of large water bodies and their surrounding environment, facilitating accurate delineation of lake boundaries and complete identification of homogeneous internal regions. The Pond Expert branch focuses on fine-grained perception of small-scale targets. It employs high-resolution feature streams, stacked small convolutional kernels, and boundary-enhancing convolutions to enhance the ability to capture details and improve boundary clarity for small, discrete pond targets.
[0036] The lake expert and pond expert branches have similar structures, differing only in their structural hyperparameters, such as the selected convolutional kernel size, receptive field size, and number of attention heads, to better adapt to spatial patterns of large-scale water surfaces and small-scale ponds. Correspondingly, lake expert features and pond expert features can be obtained, and all three expert features explicitly depend on NDWI / MNDWI priors.
[0037] Please refer to Figure 4 , Figure 4 This paper demonstrates how river, lake, and pond expert features are fused under the influence of morphological routing weights, based on a shared backbone. In this embodiment, the method utilizes pixel-level morphological routing weights to perform pixel-level adaptive weighted fusion of the three expert features, resulting in a multi-morphological water body fusion feature. For further stabilization training, residual connections can be made between the fused features and the original shared features to obtain a multi-morphological water body fusion feature map. Finally, based on the fused features, a water body prediction probability map is obtained through a decoder and a classification head. Thus, the network, through a morphological routing mechanism, achieves intelligent division of labor, allowing experts skilled in river processing to focus on river pixels and experts skilled in lake processing to focus on lake pixels. This fundamentally solves the problem of uneven representation capabilities of a single network for different water body morphologies from a model structure perspective.
[0038] In this embodiment, the decoder of the present invention can adopt a step-by-step upsampling decoding structure similar to that in the U-Net model. Specifically, the multi-scale features output by the encoder are upsampled multiple times and then connected and concatenated with the corresponding scale encoded features through skip connections, and then processed through several 3 Three convolutional layers are used for feature fusion to gradually restore the spatial resolution to the same level as the input image. After restoring the original resolution, the classification head can use a 1-layer convolutional layer. Convolution 1 compresses the number of channels to 1 (for water / non-water body segmentation) or 2 (for explicit foreground / background output), and obtains the water probability value for each pixel through the Sigmoid or Softmax activation function, thus forming a water probability map.
[0039] This invention utilizes multi-expert feature extraction guided by water body spectral priors and morphological priors, as well as morphological weighted segmentation loss. The decoder and classification head can adopt any publicly available upsampling decoding structure and classification prediction structure in existing semantic segmentation networks. In actual use, technicians can replace or simplify them according to specific needs.
[0040] In this embodiment, preferably, the total loss formula used by the multi-morphological water body segmentation model during the training phase is: ,in, The total loss is the shape-weighted binary cross-entropy loss. The weighting coefficient (positive scalar) of ). The shape-weighted Dice loss is a portion of the total loss. The weighting coefficient (positive scalar) of ). For morphology-weighted binary cross-entropy loss, The form-weighted Dice loss is used.
[0041] The calculation process for morphologically weighted binary cross-entropy loss and morphologically weighted Dice loss is as follows: Let the true label be... The predicted probability of water bodies is The standard BCE loss and Dice loss are defined as follows: , , The total number of pixels (or the total number of pixels within a mini-batch) used in the loss calculation is commonly... (or the total number of pixels after summing within a batch), used to calculate the average; The true label connected region for the pixels within the i-th connected region Define its weight as , , and All are shape weights. Connected regions for real labels Normalized region area Normalized true label connected regions slender length, To prevent constants with a denominator of zero, The true label connected region to which the pixel in the i-th connected region belongs. The area of the corresponding connected region (in pixels or area measure). The image area (total number of pixels), usually 1000. This is used to normalize the area of connected regions. , Connected regions for real labels The measure of fineness, , The maximum and minimum values of the thinness of all connected regions in the current image are used for thinness normalization. The morphological weights are assigned different loss weights to real water pixels at different locations based on the area and thinness of the connected regions of the real water body, thereby prioritizing the optimization of thin and small-area water bodies.
[0042] Based on standard BCE loss, Dice loss, and weights The morphology-weighted binary cross-entropy loss and the morphology-weighted Dice loss are constructed using the following formulas: , .
[0043] In this embodiment, during the training phase, a morphology-weighted segmentation loss (SWS-Loss) based on area, elongation, and skeleton distance is used to supervise the water body probability map and the ground truth labels. Morphology-weighted binary cross-entropy loss and morphology-weighted Dice loss are calculated, and a boundary loss term may be optionally introduced. The parameters of each module of the multimorphic water body segmentation model are updated using the backpropagation algorithm until convergence.
[0044] Specifically, to further enhance the optimization of difficult-to-segment samples (thin rivers, small ponds) during training, this method designs a morphology-weighted segmentation loss. First, the basic binary cross-entropy loss and Dice loss are calculated. Second, a morphology weight is calculated for each real water pixel, determined by the normalized area and thinness of its connected region. Finally, using this weight, morphology-weighted loss functions are constructed, such as morphology-weighted binary cross-entropy loss and morphology-weighted Dice loss; the total loss is the weighted sum of the two. This loss function explicitly introduces morphological priors at the optimization objective level, forming a "structure-loss" dual guarantee with the morphology routing mechanism in the aforementioned model structure, jointly ensuring improved segmentation performance for multi-morphological water bodies, especially difficult-to-detect water bodies.
[0045] In summary, this invention proposes a multi-morphological water body segmentation method based on morphological priors and a hybrid expert network, aiming to systematically solve the technical challenge of simultaneously and accurately segmenting various water body types such as rivers, lakes, and ponds in remote sensing images. This method first extracts dual priors of spectral and geometric morphology of the water body through classical spectral indices (NDWI / MNDWI) and morphological analysis, and innovatively transforms these priors into structured embedding vectors. Based on this, a hybrid expert model controlled by a morphological routing network is constructed. Through three targeted branches—river expert, lake expert, and pond expert—the feature extraction capabilities for slender structures, large-scale regions, and small-scale targets are optimized respectively. Furthermore, by leveraging regional gating and weight broadcasting mechanisms, the method maintains high inference efficiency while incorporating the advantages of multi-expert collaboration.
[0046] The core innovation of this invention lies in the explicit sub-classification of water bodies based on morphological differences, and the deep integration of spectral and morphological priors at both the network structure and loss function levels. At the structural level, spectral indices guide the attention mechanism to focus on water body regions as learnable features, while morphological embedding drives the routing network to achieve pixel-level intelligent fusion of expert features, thereby fundamentally enhancing the model's ability to represent the features of water bodies with different morphologies. At the optimization level, the designed morphological weighted loss function dynamically adjusts the training weights based on the area and elongation of the connected regions of the water body, significantly strengthening the supervision signal for easily missed small ponds and narrow rivers, effectively improving their recall and topological integrity.
[0047] In summary, this invention achieves a balance between accuracy and efficiency in multi-morphological water body segmentation through a collaborative framework of prior extraction, route allocation, expert processing, and morphological weighting. This method not only fully utilizes mature spectral indices and image processing operators but also achieves adaptive fusion of prior knowledge and data-driven features through structured innovation in deep learning models, providing a reliable technical solution for automated and refined mapping of complex water systems in high-resolution remote sensing imagery.
[0048] Compared with existing technologies, this method has the following advantages: 1. It explicitly introduces morphological subtypes (rivers / lakes / ponds) within a unified water body semantic category. Through morphological embedding and routing mechanisms, features of different water body morphologies are fed into corresponding expert branches, improving the overall segmentation performance of multi-morphological water bodies. 2. It embeds NDWI / MNDWI into the attention and routing modules in a learnable soft prior form, rather than using them only as thresholds or fixed weights, enhancing the flexibility of prior utilization and robustness to abnormal NDWI cases. 3. By combining area and shape-weighted loss, it selectively strengthens the weights of long and narrow rivers and small ponds during training, improving the recall rate of small water bodies and the topological integrity of river networks. 4. Each module is based on mature image processing and deep learning operators, with high engineering feasibility, and can be smoothly integrated into existing deep learning frameworks. 5. Efficient region-level gating mechanism: This method adopts a strategy of "coarse region segmentation first, then fine routing". The routing network calculates weights only for sparse connected regions (object-level), rather than calculating them for each of the millions of pixels in the entire image (pixel-level). The weights are then mapped back to pixels via a broadcasting mechanism. This design decouples the additional computational overhead of the MoE module from the image resolution, significantly improving segmentation accuracy while maintaining extremely high inference efficiency.
[0049] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A multi-morphology water body segmentation method based on morphology prior and hybrid expert network, characterized in that, The method comprises the following steps: acquiring image data to be processed, and preprocessing the image data, calculating a normalized difference water index and an improved normalized difference water index based on the preprocessed image data; calling a pre-trained multi-morphology water body segmentation model to process the normalized difference water index or the improved normalized difference water index, specifically: based on the normalized difference water index or the improved normalized difference water index, generating a coarse water body binary mask, performing connected region analysis on the coarse water body binary mask to obtain a morphology factor vector; mapping the morphology factor to a morphology embedding vector, and calculating the regional weight corresponding to each connected water body region through a routing network, and mapping the regional weight to a pixel-level morphology routing weight; constructing a shared feature according to the image data, extracting river expert features, lake expert features and pond expert features based on the shared feature, and performing spectral prior guided feature fusion processing on the shared feature and each expert feature to obtain a fusion feature, and decoding and classifying the fusion feature to generate a water body prediction probability map.
2. The method of claim 1, wherein the method further comprises: acquiring image data to be processed, and preprocessing the image data, calculating a normalized difference water index and an improved normalized difference water index based on the preprocessed image data, specifically: acquiring image data to be processed, and preprocessing the image data, wherein the image data is multispectral or fused remote sensing image containing water body, and the preprocessing includes radiation calibration, atmospheric correction and geometric correction; Based on the pre-processed image data, the normalized difference water index and the improved normalized difference water index are calculated, and the formula is: , wherein NDWI is the normalized difference water index, MNDWI is the improved normalized difference water index, G is the green band, NIR is the infrared band, and SWIR is the short-wave infrared band, is a constant to prevent the denominator from being zero.
3. The method of claim 2, wherein the method further comprises: based on the normalized difference water index or the improved normalized difference water index, generating a coarse water body binary mask, performing connected region analysis on the coarse water body binary mask to obtain a morphology factor vector, specifically: based on the normalized difference water index or the improved normalized difference water index, generating a coarse water body binary mask through global thresholding, adaptive thresholding or a lightweight initial network; The connected region marking processing is performed on the coarse water body binary mask to obtain each connected region , and the connected region is calculated , the minimum circumscribed rectangle aspect ratio , the thin length , wherein is the image area, is the length of the minimum circumscribed rectangle, is the width of the minimum circumscribed rectangle, is the perimeter, k is the connected region index, is the area of the connected region . Refining the connected region to obtain the centerline skeleton , calculating the distance distribution of each pixel to the skeleton , and calculating the average distance of the pixels in the kth connected water area to the skeleton according to the distance distribution of all pixels to the skeleton , denotes the ith connected region, is the two-dimensional coordinates of the pixels in the ith connected region, denotes the pixel of the centerline skeleton . area of the normalized image , aspect ratio of the minimum enclosing rectangle , thin length , average distance from pixels in the kth connected water region to the skeleton perform max-min normalization to obtain a morphological factor vector .
4. The method of claim 3, wherein the method further comprises: mapping the morphology factor to a morphology embedding vector, and calculating the regional weight corresponding to each connected water body region through a routing network, and mapping the regional weight to a pixel-level morphology routing weight, specifically: by a morphological embedding mapping function mapping a morphological factor vector into a morphological embedding vector , wherein, is a d-dimensional real-valued vector space, is a morphological embedding vector of dimension d. According to the preset morphological sub-type and morphological embedding vector, a corresponding regional level weight is calculated through a routing network, and a formula is as follows: wherein the preset morphological sub-type comprises a river, a lake and a pond, is a river regional level weight of the kth connected region, is a lake regional level weight of the kth connected region, is a pond regional level weight of the kth connected region, is a normalized exponential function, is a weight matrix of a last linear layer of the routing network, is a bias vector of the last linear layer of the routing network. mapping the region-level weights to pixel-level to get the morphological routing weight of each pixel in the i-th connected region and performing K times of weight broadcasting operation, for all pixels belonging to the connected region , directly multiplexing the weights of this region, such that , K is the number of connected regions, , H is the height of the image data, W is the width of the image data, is the morphological routing weight of the pixel in the k-th connected region.
5. The method of claim 4, wherein the morphological prior and hybrid expert network based multi-morphological water body segmentation method further comprises: constructing a shared feature according to the image data, extracting river expert features, lake expert features and pond expert features based on the shared feature, specifically: The multi-scale features are extracted from the image data and preset NDWI / MNDWI channels by using a CNN or a CNN-Transformer hybrid network, and shared features are obtained based on the multi-scale features ; a normalized difference water index corresponding to each pixel in the ith connected region and an improved normalized difference water index denoted as a binary vector and a linear transformation is performed on the binary vector to generate an attention bias T is a transpose, is a linear transformation coefficient, is a bias term; By a pixel-by-pixel feature encoding network Each binary vector Is mapped into a high-dimensional spectral prior feature vector And all high-dimensional spectral prior feature vectors Are combined to obtain a spectral prior feature map P, wherein the feature encoding network Adopts a shallow neural network.
6. The method of claim 5, wherein the morphological prior and hybrid expert network-based multi-morphological water body segmentation method further comprises: Further comprising: Three parallel branches of river expert network, lake expert network and pond expert network are set to share the characteristics As the first branch, the first module in the river expert network, the lake expert network and the pond expert network is an attention module with Q / K / V. The first module of the river expert network is called for preprocessing to obtain initial river expert features , specifically: According to the shared feature , a key feature matrix and a value feature matrix are generated , , wherein, is a key feature projection matrix of the river expert branch, is a value feature projection matrix of the river expert branch, is a key / query feature dimension, is a value feature dimension, is a number of channels of the shared feature is a real number field, and N is a pixel number after the current feature map is flattened. According to shared features Generating first query features wherein, is a projection matrix for the first query in the river of experts network; generating a second query feature according to the spectral prior feature map P wherein, is a second query projection matrix in the river expert network, is a channel number of the spectral prior feature map P; linearly combine the first query feature and the second query feature by a weight coefficient to obtain a final query feature , is a weight coefficient of the spectral prior query component in the river expert branch Based on attention bias Generate logits bias Based on the logits bias, final query features, and key feature matrix, the attention logits matrix of the river expert branch is determined. , The attention logits matrix of the th Line number List Indicates the first The position is the first Attention score for each position The scaling factor for controlling the NDWI bias intensity; row-wise attention logits matrix Softmax normalization is performed to obtain the attention weight matrix of the river expert network , The first row represents the attention weight of the first position to all positions; An initial river expert feature is obtained by weighting and summing the value feature matrix using an attention weight matrix , , the first row represents the river expert feature representation of the first pixel position under the joint action of the water body spectrum prior and the attention mechanism; Similarly, the first module of the lake expert network is used for preprocessing to obtain initial lake expert features The first module of the pond expert network is used for preprocessing to obtain initial pond expert features .
7. The method of claim 6, wherein the method further comprises: Further comprising: subsequent modules of the river expert network are called are processed to obtain final river expert features , are subsequent modules of the river expert network, wherein the subsequent modules of the river expert network employ a strip convolution or a direction attention module The subsequent module of the lake expert network calls the initial lake expert feature The subsequent module of the lake expert network calls the initial lake expert feature , The subsequent module of the lake expert network calls the initial lake expert feature subsequent modules of the pond expert network are called processed to obtain final pond expert features , for subsequent modules of the pond expert network, wherein the subsequent modules of the pond expert network employ high resolution and small kernel structure modules.
8. The method of claim 7, wherein the method further comprises: performing spectral prior guided feature fusion processing on the shared feature and each expert feature to obtain a fusion feature, and decoding and classifying the fusion feature to generate a water body prediction probability map, specifically: The river expert feature, the lake expert feature and the pond expert feature are fused by using morphological routing weights to obtain fused features ; Fusion features Shared features Residual superposition processing is performed to obtain fusion feature maps wherein, is a residual weight, is a river area-level weight of the i-th connected region, is a lake area-level weight of the i-th connected region, is a pond area-level weight of the i-th connected region; The fused feature map is input into a preset decoder and classification head module, up-sampling and convolution prediction processing are performed, a water body probability value of each pixel is obtained, and a water body prediction probability map is generated.
9. The method of claim 1, wherein the method further comprises: Further comprising: performing thresholding processing on the water body prediction probability map, and using conditional random field and morphological operation to refine the boundary of the water body prediction probability map; performing river skeleton extraction and small fracture bridging processing, performing connectivity repair on the river network, and removing regions with an area less than a preset value and abnormal morphology.
10. The method of claim 9, wherein the method further comprises: The total loss formula used by the multi-morphology water body segmentation model in the training stage is: wherein, is a weight coefficient of the morphology weighted binary cross entropy loss in the total loss, is a weight coefficient of the morphology weighted Dice loss in the total loss, is the morphology weighted binary cross entropy loss, is the morphology weighted Dice loss. The calculation process of the morphology weighted binary cross entropy loss and the morphology weighted Dice loss is as follows: Let the ground truth label be , the predicted water probability be , and define the standard BCE loss and Dice loss as: , , is the total number of pixels for loss calculation. the real label connected region to which the i-th connected region belongs , the weight of which is defined as , , and are all morphological weights, is the real label connected region normalized area of the region, is the normalized thin length of the real label connected region , is a constant to prevent the denominator from being zero, is the real label connected region to which the i-th connected region belongs corresponding connected region area, is the image area, is the thin length metric of the real label connected region , is the maximum value of the thin length of all connected regions in the current image, is the minimum value of the thin length of all connected regions in the current image. According to the standard BCE loss, Dice loss and weight , the morphological weighted binary cross-entropy loss and the morphological weighted Dice loss are constructed, and the formula is: , .
Citation Information
Patent Citations
Geographic weighting and random forest coupled surface temperature downscaling method
CN117035066A
Desert remote sensing image lake extraction method based on SSI and water body index fusion
CN119672524A
Multi-modal remote sensing image real-time water body segmentation method and system adaptive to unmanned aerial vehicle
CN120747775A
Pump shell welding seam quality detection method based on image segmentation
CN120953275A
Enhanced target detection method and device based on feature fusion and medium
CN121191041A