Medical image segmentation method and system based on multi-scale global context perception and boundary guidance fusion
By using the Swin Transformer and a multi-scale global context-aware and boundary-guided fusion network, the accuracy and efficiency issues of polyp segmentation in colonoscopy images were solved, achieving high-precision segmentation and robust generalization in complex backgrounds.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUBEI UNIV OF TECH
- Filing Date
- 2026-01-07
- Publication Date
- 2026-05-05
AI Technical Summary
Existing medical image segmentation methods struggle to effectively capture multi-scale global contextual information and boundary details in colonoscopy images, resulting in low accuracy and efficiency in polyp identification and segmentation. In particular, they are prone to problems such as false edges, oversegmentation, or missed segmentation in complex backgrounds.
A multi-scale global context-aware and boundary-guided fusion network based on Swin Transformer is adopted. The global context-aware module (GCAM) and the boundary-guided fusion module (BGFM) enhance the collaborative expression of global semantics and local details. The pyramid global attention module (PGAM) is used to achieve adaptive feature balancing and information filtering. The circular residual convolution module is combined for feature reconstruction.
It significantly improves the accuracy and robustness of medical image segmentation, enabling accurate segmentation of small and large polyps in complex backgrounds, reducing false positive and false negative rates, enhancing the model's generalization ability, and adapting to different lighting and equipment conditions.
Smart Images

Figure CN121982303A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to, but is not limited to, the field of medical technology, and particularly relates to a medical image segmentation method and system based on multi-scale global context awareness and boundary-guided fusion. Background Technology
[0002] Colorectal cancer (CRC) is a common and highly dangerous malignant tumor, ranking among the top three in incidence worldwide. Numerous clinical and epidemiological studies have shown that most CRC cases originate from precancerous lesions such as adenomatous polyps. Early detection and timely removal of these lesions through systematic screening can significantly reduce the incidence and mortality of CRC. Currently, colonoscopy is the primary clinical method for colorectal cancer screening and prevention. However, polyps in colonoscopy images exhibit significant differences in size, color, and texture, and images often suffer from uneven lighting and insufficient contrast, making the boundary between polyps and the mucosa blurred, increasing the difficulty of manual identification and segmentation. These factors can easily lead to missed or false positives for polyps, thus affecting the accuracy and efficiency of screening.
[0003] With the development of deep learning, neural network-based medical image segmentation methods have made significant progress. The U-Net architecture, through its encoder-decoder framework and skip connections, achieves good segmentation results, but it has shortcomings in modeling global context and long-range dependencies, easily leading to loss of detail and poor global consistency. To compensate for the limitations of convolutional neural networks in global modeling, the Transformer architecture was introduced into medical image segmentation tasks. Through self-attention mechanisms, it captures multi-scale global information, significantly improving the model's contextual understanding ability. Subsequently, the fusion of CNN and Transformer architectures achieved a balance between global modeling and local localization, but segmentation accuracy still suffers in complex backgrounds or scenes with blurred boundaries. Furthermore, edge features are crucial to the accuracy of medical image segmentation. While existing methods utilize saliency guidance, backattention, or boundary enhancement mechanisms to improve boundary recognition capabilities, they remain imperfect in multi-scale feature fusion and edge uncertainty modeling, easily resulting in false edges, oversegmentation, or undersegmentation. Therefore, how to maintain global context modeling capabilities while fully utilizing edge detail information to achieve high-precision segmentation of target regions in complex medical images remains a technical problem that needs to be solved in this field. Summary of the Invention
[0004] To address the problems existing in the prior art, this invention provides a medical image segmentation method based on multi-scale global context awareness and boundary-guided fusion.
[0005] This invention is implemented as follows: a medical image segmentation method based on multi-scale global context awareness and boundary-guided fusion, the method comprising:
[0006] S1: Obtain the colonoscopy polyp dataset and preprocess the dataset, including image normalization, data augmentation, and size uniformity;
[0007] S2: The Swin Transformer backbone network is used to extract hierarchical features from the input image. Multi-scale semantic information is gradually obtained through a four-stage coding structure to achieve rich context modeling.
[0008] S3: Input the fused features into the decoder, restore the spatial resolution through stepwise upsampling and residual connection, and output high-quality polyp segmentation results.
[0009] Furthermore, S2 specifically includes:
[0010] The output features of each layer are input into the Global Context Aware Module (GCAM) and the Boundary Guided Fusion Module (BGFM), respectively. The former is used to enhance the collaborative expression of global and local semantics and capture long-distance dependencies; the latter is used to strengthen boundary detail modeling and improve the model's sensitivity and recognition of edge information. Subsequently, the multi-scale features are fused through the feature aggregation module (Agg) to ensure the effective complementarity between high-level semantics and low-level spatial details, thereby providing comprehensive contextual information support for the decoding stage.
[0011] The Pyramid Global Attention Module (PGAM) is introduced to achieve adaptive feature balancing and information filtering by dynamically fusing spatial and channel attention features, thereby improving the model's feature discrimination ability in complex scenarios.
[0012] Furthermore, the global context-aware module comprises three parts: a multi-scale dilated convolution branch, a spatial attention branch, and a channel attention branch;
[0013] The global context-aware module first extracts multi-scale features through 3×3 dilated convolutions with three different dilation rates (1, 3, and 5) to simultaneously capture the details of small polyps and the overall structure of large polyps; the outputs of each branch are concatenated along the channel dimension to form a fused feature F; the fusion method of the fused feature is as follows:
[0014]
[0015]
[0016] in This represents the input to the global context-aware module. Indicates the expansion ratio. Indicates different branches;
[0017] Next, the global context-aware module performs 1×1 convolution and Softmax normalization on the fused feature F to generate spatial attention weights. This is used to suppress irrelevant background areas and highlight the main polyp area; the normalization process and attention weight generation method are as follows:
[0018]
[0019]
[0020] in The output represents the fused features, and Softmax represents the normalization function. Represents the spatial attention weight map;
[0021] Meanwhile, the global context-aware module performs global average pooling on the fused feature F, and obtains the channel attention weights after passing through two fully connected layers and an activation function. This allows for dynamic adjustment of the importance of channel features, strengthening key semantic features; the global average pooling and channel attention weight generation methods are as follows:
[0022]
[0023]
[0024] in, and These are parameters of the fully connected layer; GAP indicates global average pooling. Indicates Sigmoid activation;
[0025] The outputs of spatial attention and channel attention are fused through a cross-attention module to generate new spatial attention weights. and channel attention weights Simultaneously, Sigmoid weights for opposing branches are introduced and combined with... and The two components are weighted and fused together, and finally the output feature Y is obtained through a 1×1 convolution, realizing the collaborative modeling of global semantics and local structure. The cross-attention fusion method, the weighted generation method, and the final output feature are shown below:
[0026]
[0027]
[0028]
[0029]
[0030] in This includes two convolution operations with kernel sizes of 1 and 3, respectively, followed by ReLU and Sigmoid activations for each convolution operation. This indicates that the Sigmoid function is activated.
[0031] Furthermore, the boundary-guided fusion module includes a reverse attention branch, a boundary attention branch, and a high-frequency edge feature branch; the boundary-guided fusion module receives three inputs: a feature map X from the encoder, a prediction map from the output of the previous layer decoder, and so on. And the boundary feature map extracted from the original image using the Laplacian operator. ; For the prediction map Perform sigmoid activation and reverse processing to obtain a reverse attention map. This feature is used to highlight background information and suppress polyp regions; after being fused with encoder feature X, it effectively reduces background interference; the boundary attention branch uses the Laplacian operator to extract the predicted boundary map. It is fused with encoder features to enhance edge details; the high-frequency branch integrates the original boundary feature map. The features are directly fused with encoder features to extract high-frequency edge information; the outputs of the three branches are concatenated and fused with a 3×3 convolution operation to form a comprehensive feature. This method incorporates both the morphological information of the polyp and boundary details, thereby enhancing edge sensitivity and segmentation accuracy. The generated inverse attention map and the generated comprehensive feature map are shown below:
[0032]
[0033]
[0034] in, This represents the segmentation prediction map of the previous level. This represents a reverse attention map. This represents the boundary map generated from the prediction map. This represents the boundary map generated from the original image. This represents the Sigmoid activation function.
[0035] Furthermore, the pyramid global attention module employs a parallel structure to fuse channel attention and spatial attention; traditional CBAM modules use a fixed serial structure with a single fusion method, making it difficult to adapt to different contrast and noise levels. The pyramid global attention module introduces learnable gating units to dynamically balance channel and spatial attention weights, enabling the model to automatically adjust its focus based on the differences in input features. When the contrast between the polyp and the background is low, the gating unit adaptively increases the channel attention weight to enhance semantic difference recognition; when the polyp boundary is blurred, the spatial attention weight is increased to enhance the model's ability to capture edge structures. Therefore, the pyramid global attention module can effectively maintain the clarity and stability of segmentation boundaries in low-contrast and complex backgrounds.
[0036] Furthermore, S3 specifically includes: achieving feature reconstruction and detail preservation through a circular residual convolution module; this module, combined with residual propagation and feedback mechanisms, effectively alleviates the gradient vanishing problem and enhances the transmission and recovery of polyp region features, thereby outputting high-quality segmentation results.
[0037] Another object of the present invention is to provide a computer device, the computer device including a memory and a processor, the memory storing a computer program, the computer program being executed by the processor causing the processor to perform the steps of the medical image segmentation method based on multi-scale global context awareness and boundary-guided fusion.
[0038] Another object of the present invention is to provide a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the steps of the medical image segmentation method based on multi-scale global context awareness and boundary-guided fusion.
[0039] Based on the above technical solutions and the technical problems solved, the advantages and positive effects of the technical solution to be protected by this invention are as follows:
[0040] This invention proposes a novel medical image segmentation network, a multi-scale global context-aware and boundary-guided fusion network, for high-precision segmentation of polyps in colonoscopy. This network effectively fuses global contextual information and boundary detail information, overcoming the limitations of existing technologies such as limited single convolutional feature extraction, insufficient global semantic modeling, loss of boundary information, and single fixed serial attention fusion. The network uses a Swing Transformer as the backbone encoder to perform four-stage hierarchical feature extraction on the input image. At each stage, parallel processing with dilated convolutions of different dilation rates is used to simultaneously capture the boundary details of small polyps and the overall contour of large polyps. Multi-scale features are fused along the channel dimension to enhance global context awareness. Furthermore, the multi-scale global context-aware and boundary-guided fusion network incorporates a Global Context Awareness (GCAM) module, simultaneously introducing spatial and channel attention into multi-scale features. Coupling and fusion are achieved through a cross-attention module, where spatial attention emphasizes boundary information and channel attention emphasizes key semantic channels. This enhances the model's ability to distinguish polyps of different shapes, sizes, and colors, effectively reducing false positives and false negatives, and improving segmentation accuracy in complex backgrounds. Meanwhile, this invention proposes a Boundary Guided Fusion Module (BGFM), which processes the encoder output and coarse segmentation prediction by fusing back attention, boundary attention, and high-frequency edge features. Back attention suppresses background interference, boundary attention enhances polyp boundary information, and high-frequency features preserve details, significantly improving the model's ability to perceive blurred boundaries and achieving fine-grained boundary segmentation. Furthermore, this invention designs a Pyramid Global Attention Module (PGAM) to model channel attention and spatial attention in parallel, and dynamically adjusts their weights through learnable gating units. When polyp boundaries are blurred or background contrast is low, the gating units adaptively enhance spatial or channel attention, effectively improving the model's robustness and generalization ability. These modules achieve efficient fusion and information transfer of multi-scale features through residual connections and cross-layer feature aggregation. A lightweight design ensures computational efficiency and low implementation cost, enabling the network to maintain high accuracy while possessing a reasonable structure and convenient training and deployment. This technical solution enables the multi-scale global context awareness and boundary guidance fusion network to effectively capture multi-scale polyp features, fully utilize global context information and boundary details to achieve accurate segmentation of small and large polyps, while suppressing background interference, reducing false detection and false negative rates, enhancing the robustness and generalization ability of the model, and has broad clinical application prospects.
[0041] Compared with the prior art, the beneficial effects of the present invention are as follows: (1) The Global Context Aware Module (GCAM) proposed in this invention effectively captures the global semantic information and local detail information of polyps through parallel modeling of multi-scale dilated convolution and dual attention mechanism (spatial and channel), enhances feature representation ability, and significantly reduces false detection and false negative detection. (2) The Boundary Guided Fusion Module (BGFM) proposed in this invention introduces a dual-path modeling mechanism of reverse attention and boundary attention, which can highlight the high-frequency features of polyp edges and suppress irrelevant backgrounds, effectively improving the problems of boundary blurring and over-smoothing. (3) The Pyramid Global Attention Module (PGAM) proposed in this invention, through parallel fusion of channel and spatial attention and dynamic balancing mechanism of learnable gating units, enables the model to have stronger adaptability and segmentation robustness under complex background and low contrast conditions. (4) Combining the hierarchical feature extraction of the Swin Transformer backbone and the detail preservation mechanism of ring residual convolution, the overall network structure is compact, information transmission is efficient, and segmentation performance is significantly improved.
[0042] Therefore, the MCBASegFormer network proposed in this invention has the advantages of reasonable structure, high accuracy, strong generalization and excellent robustness, and has broad medical clinical application value.
[0043] The technical solution of this invention solves a long-standing but unresolved technical problem in the field of medical endoscopic image processing: accurate identification of small polyps, precise restoration of blurred or broken boundaries, and robust generalization capabilities across devices and datasets have long been critical challenges that have remained unresolved. The fundamental reason lies in the fact that medical endoscopic images are characterized by low contrast, complex noise sources, and significant illumination variations, causing conflicts between global semantic features, local texture features, and boundary structure features in the feature space. High-level semantic features are beneficial for the overall localization of target areas but suppress fine boundary information, while low-level texture features, although beneficial for restoring boundary details, typically contain a large amount of noise and are extremely sensitive to device differences. This makes it difficult for traditional methods to achieve unified modeling of semantics, texture, and boundaries, leading to problems such as missed detection of small targets, broken boundaries, and insufficient generalization performance.
[0044] This invention fundamentally solves the aforementioned technical bottlenecks through structured design and a multi-source feature fusion mechanism. Firstly, in the detection and segmentation of small polyps, this invention uses multi-scale dilated convolutional branches (with dilation coefficients of 1, 3, and 5) to extract semantic and structural information at different scales in parallel. This allows the network to simultaneously obtain fine-grained details of small polyps and the overall contextual representation of large-scale structures while maintaining high resolution. Simultaneously, the adaptive gating unit in the Pyramid Global Attention (PGAM) module automatically increases the weight of channel attention on key semantic channels when weak responses to small targets are detected, thus amplifying and enhancing the small targets in the feature space. Extensive experiments show that on the ETIS dataset, where small targets constitute a very low proportion and the background is complex, this invention significantly outperforms comparative methods in metrics such as mDice and mIoU, effectively alleviating the common problem of difficult small target detection in traditional methods.
[0045] To address the issues of blurred boundaries and structural breaks, this invention introduces a Boundary Guided Fusion Module (BGFM). This module suppresses false edges and background noise through reverse attention, provides explicit structural evidence by predicting the boundary and the Laplacian high-frequency features of the original image, and performs multi-source fusion during the decoding stage, thereby achieving layer-by-layer calibration and enhancement of the boundary. Furthermore, this invention incorporates a circular residual convolution module during the decoding process. By continuously compensating for high-frequency texture information in the upsampling path, it prevents the boundary from being gradually smoothed or weakened as the network depth increases. Experiments demonstrate that this invention achieves significant advantages in average intersection-union ratio and structural similarity metrics. Visualization results also show that it far surpasses existing methods in terms of boundary continuity and structural integrity.
[0046] Regarding cross-domain generalization ability, this invention combines the global context modeling capability of the Swin Transformer backbone network with the proposed multi-source attention fusion strategy, enabling the model to simultaneously learn universally applicable global semantic features and transferable boundary structure features. This reduces the impact of device differences, illumination variations, and reflection artifacts on model performance. Even on unseen datasets where the training and test distributions are not entirely consistent, this invention maintains a high average Dice coefficient and extremely low mean absolute error, fully demonstrating its robustness and stability across devices and data sources.
[0047] In summary, this invention, through a collaborative design of global, boundary, and multi-scale approaches, simultaneously solves three long-standing technical challenges—small target segmentation, boundary ambiguity processing, and cross-domain generalization—from three levels: network structure, feature modeling, and decoding recovery. It also provides sufficient technical evidence through quantitative indicators and qualitative visualization, demonstrating significant technological progress and ingenuity. Attached Figure Description
[0048] Figure 1This is the multi-scale global context awareness and boundary guidance fusion network model provided in the embodiments of the present invention;
[0049] Figure 2 This is the global context-aware module provided in the embodiments of the present invention;
[0050] Figure 3 This is the boundary guidance aggregation module provided in the embodiments of the present invention;
[0051] Figure 4 This is a visualization of the comparison results on five public datasets provided in this embodiment of the invention;
[0052] Figure 5 This is a schematic diagram comparing the multi-scale global context awareness and boundary guidance fusion network MCBASegFormer provided in this embodiment of the invention with seven existing methods. Detailed Implementation
[0053] 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.
[0054] In real-world colonoscopy applications, polyps often exhibit low contrast, uneven brightness, and strong background interference, making it difficult for traditional convolutional structures to maintain semantic consistency across large-scale contexts. This method leverages the hierarchical encoding structure of the Swin Transformer, employing a global self-attention mechanism to capture cross-regional correlations, enabling the model to achieve stable contextual semantic aggregation within the same scale. To further mitigate the problem of traditional Transformers neglecting local abrupt changes, this method introduces a multi-scale global context-aware module (GCAM). This module simultaneously extracts texture details from small polyps and the structural layout of large-scale tissues along multi-branch paths constructed from convolutions with varying dilation rates, significantly improving regional semantic ambiguity caused by insufficient contrast. The fundamental principle behind this structure is the coupling of long-range and short-range dependencies, allowing the network to maintain stable semantic representation capabilities even under complex lighting and strong reflection conditions.
[0055] In industrial gastrointestinal imaging systems, images often contain numerous wrinkles, light spots, and liquid reflection textures. These background components are often highly similar to the edge features of polyps, leading to high false positive rates in traditional segmentation networks. This method introduces a dual orthogonal modeling mechanism of spatial attention and channel attention within GCAM, suppressing non-target regions from two directions: "spatial saliency suppression" and "semantic dimension importance recalibration." The spatial attention weights (W_s1) generated after Softmax normalization automatically identify and suppress low-relevance background regions, while the channel attention weights (W_c1) are generated using a two-layer fully connected structure after global pooling, dynamically weakening channels with low local texture contribution. The fusion of these two attention mechanisms further enhances global semantic consistency, enabling the network to maintain low false positive segmentation performance even in scenarios with significant edge reflections and wrinkle interference, achieving engineering-grade robustness improvements.
[0056] In industrial applications, polyp removal surgery demands extremely high boundary accuracy. However, polyp boundaries are often affected by factors such as mucus, water stains, and instrument occlusion, making it difficult for traditional models to accurately locate the true cutting edge. Our proposed Boundary Guided Fusion Module (BGFM) utilizes back attention, predicted boundaries, and Laplacian high-frequency structure information simultaneously during the decoding stage, enabling the network to possess a dedicated boundary enhancement mechanism when restoring spatial resolution. The back attention map (f_r), obtained by applying Sigmoid activation to the predicted map (f_p) and then performing a reverse operation, enhances background suppression, thereby highlighting the contour region. The addition of the boundary map (f_e) allows the decoder to have explicit edge calibration capabilities at each level. The high-frequency structure (f_b) extracted by the Laplacian operator ensures that the model can still obtain continuous true contours under blurred conditions. The fused comprehensive feature (F_c) provides the model with multi-source edge evidence, solving the problem of boundary discontinuity from the underlying structure.
[0057] Small polyps, due to their extremely low pixel ratio, weak boundaries, and irregular shapes, are the most difficult objects to process in automatic segmentation systems. Traditional feature fusion in U-shaped structures is often limited by the contradiction of "coarse high-level semantics and high low-level texture noise." This method uses a feature aggregation module (Agg) and a pyramid global attention module (PGAM) to dynamically coordinate the weights of multi-scale features, enabling the model to determine the contribution ratio of semantic levels based on the actual difficulty of the input image. Unlike serial CBAM, PGAM employs a parallel attention + gated dynamic reweighting mechanism, automatically selecting the attention direction more suitable for the current image through learnable gating units. When the contrast of a small polyp is low, the channel attention weight increases to enhance semantic response; when the polyp boundary is fine, the spatial attention ratio increases to improve structural sensitivity. This adaptive scale balancing mechanism effectively solves the long-standing problem of missed detection of small polyps in the industry.
[0058] As model depth increases, traditional convolutional encoder-decoder structures often experience gradient decay, leading to insufficient detail recovery during the decoding stage, especially the gradual weakening of high-frequency textures in deep semantic features. This method introduces a ring-shaped residual convolution module in S3, which maintains efficient gradient flow in deep structures through residual propagation and local feedback paths. This module continuously supplements high-frequency information during each upsampling stage, enabling semantic recovery to move beyond a single path and form a closed iterative correction mechanism, thus significantly mitigating the loss of detail information after multi-scale fusion. Its working principle can be viewed as constructing a locally stable nonlinear loop in the feature space, allowing the model to maintain the complete representation of edges and textures during deep inference, which is particularly crucial for industrial-grade medical image segmentation.
[0059] Based on the above structure, this method constructs an industrially usable segmentation system for colonoscopy scenarios characterized by complex lighting, low contrast, blurred boundaries, and small targets. The four modules—global context, boundary guidance, multi-scale gating, and annular residuals—work synergistically, ensuring stable output even under real-world industrial conditions such as high noise, equipment model variations, and individual patient differences. Its overall working mechanism can be summarized as follows: establishing cross-scale semantic consistency during the encoding stage, achieving boundary and semantic complementarity during the feature fusion stage, and maintaining the progressive recovery of high-frequency details during the decoding stage. This enables the system to possess high precision, transferability, and robustness in multiple industrial scenarios such as polyp detection, intraoperative assistance, and intelligent quality control, providing more reliable fundamental algorithmic support for clinical imaging AI devices.
[0060] This invention provides a medical image segmentation method based on multi-scale global context awareness and boundary-guided fusion, the method comprising:
[0061] S1: Obtain the colonoscopy polyp dataset and preprocess the dataset, including image normalization, data augmentation, and size uniformity;
[0062] S2: The Swin Transformer backbone network is used to extract hierarchical features from the input image. Multi-scale semantic information is gradually obtained through a four-stage coding structure to achieve rich context modeling.
[0063] S3: Input the fused features into the decoder, restore the spatial resolution through stepwise upsampling and residual connection, and output high-quality polyp segmentation results.
[0064] S2 specifically includes:
[0065] The output features of each layer are input into the Global Context Aware Module (GCAM) and the Boundary Guided Fusion Module (BGFM), respectively. The former is used to enhance the collaborative expression of global and local semantics and capture long-distance dependencies; the latter is used to strengthen boundary detail modeling and improve the model's sensitivity and recognition of edge information. Subsequently, the multi-scale features are fused through the feature aggregation module (Agg) to ensure the effective complementarity between high-level semantics and low-level spatial details, thereby providing comprehensive contextual information support for the decoding stage.
[0066] The Pyramid Global Attention Module (PGAM) is introduced to achieve adaptive feature balancing and information filtering by dynamically fusing spatial and channel attention features, thereby improving the model's feature discrimination ability in complex scenarios.
[0067] The global context awareness module consists of three parts: a multi-scale dilated convolution branch, a spatial attention branch, and a channel attention branch.
[0068] The global context-aware module first extracts multi-scale features through 3×3 dilated convolutions with three different dilation rates (1, 3, and 5) to simultaneously capture the details of small polyps and the overall structure of large polyps; the outputs of each branch are concatenated along the channel dimension to form a fused feature F; the fusion method of the fused feature is as follows:
[0069]
[0070]
[0071] in This represents the input to the global context-aware module. Indicates the expansion ratio. Indicates different branches;
[0072] Next, the global context-aware module performs 1×1 convolution and Softmax normalization on the fused feature F to generate spatial attention weights. This is used to suppress irrelevant background areas and highlight the main polyp area; the normalization process and attention weight generation method are as follows:
[0073]
[0074]
[0075] in The output represents the fused features, and Softmax represents the normalization function. Represents the spatial attention weight map;
[0076] Meanwhile, the global context-aware module performs global average pooling on the fused feature F, and obtains the channel attention weights after passing through two fully connected layers and an activation function. This allows for dynamic adjustment of the importance of channel features, strengthening key semantic features; the global average pooling and channel attention weight generation methods are as follows:
[0077]
[0078]
[0079] in, and These are parameters of the fully connected layer; GAP indicates global average pooling. Indicates Sigmoid activation;
[0080] The outputs of spatial attention and channel attention are fused through a cross-attention module to generate new spatial attention weights. and channel attention weights Simultaneously, Sigmoid weights for opposing branches are introduced and combined with... and The two components are weighted and fused together, and finally the output feature Y is obtained through a 1×1 convolution, realizing the collaborative modeling of global semantics and local structure. The cross-attention fusion method, the weighted generation method, and the final output feature are shown below:
[0081]
[0082]
[0083]
[0084]
[0085] in This includes two convolution operations with kernel sizes of 1 and 3, respectively, followed by ReLU and Sigmoid activations for each convolution operation. This indicates that the Sigmoid function is activated.
[0086] The boundary-guided fusion module includes a reverse attention branch, a boundary attention branch, and a high-frequency edge feature branch; the boundary-guided fusion module receives three inputs: a feature map X from the encoder, a prediction map from the output of the previous layer decoder, and so on. And the boundary feature map extracted from the original image using the Laplacian operator. ; For the prediction map Perform sigmoid activation and reverse processing to obtain a reverse attention map. This feature is used to highlight background information and suppress polyp regions; after being fused with encoder feature X, it effectively reduces background interference; the boundary attention branch uses the Laplacian operator to extract the predicted boundary map. It is fused with encoder features to enhance edge details; the high-frequency branch integrates the original boundary feature map. The features are directly fused with encoder features to extract high-frequency edge information; the outputs of the three branches are concatenated and fused with a 3×3 convolution operation to form a comprehensive feature. This method incorporates both the morphological information of the polyp and boundary details, thereby enhancing edge sensitivity and segmentation accuracy. The generated inverse attention map and the generated comprehensive feature map are shown below:
[0087]
[0088]
[0089] in, This represents the segmentation prediction map of the previous level. This represents a reverse attention map. This represents the boundary map generated from the prediction map. This represents the boundary map generated from the original image. This represents the Sigmoid activation function.
[0090] The pyramid global attention module employs a parallel structure to fuse channel attention and spatial attention. Traditional CBAM modules use a fixed serial structure with a single fusion method, making it difficult to adapt to different contrast and noise levels. The pyramid global attention module introduces learnable gating units to dynamically balance channel and spatial attention weights, enabling the model to automatically adjust its focus based on the differences in input features. When the contrast between the polyp and the background is low, the gating unit adaptively increases the channel attention weight to enhance semantic difference recognition. When the polyp boundary is blurred, the spatial attention weight is increased to enhance the model's ability to capture edge structures. Therefore, the pyramid global attention module can effectively maintain the clarity and stability of segmentation boundaries in low-contrast and complex backgrounds.
[0091] Specifically, S3 includes: feature reconstruction and detail preservation through a circular residual convolution module; this module, combined with residual propagation and feedback mechanisms, effectively alleviates the gradient vanishing problem and enhances the transmission and recovery of polyp region features, thereby outputting high-quality segmentation results.
[0092] This invention relates to a method for colonic polyp segmentation based on a multi-scale global context-aware and boundary-guided fusion network. To verify the feasibility of this method, this embodiment uses the publicly available colorectal polyp datasets Kvasir and CVC-ClinicDB as training data sources. The Kvasir dataset contains 900 colonoscopy images with pixel-level annotations, and the CVC-ClinicDB dataset contains 550 annotated images. This embodiment merges these two datasets to form an original training dataset of 1450 samples. Subsequently, the dataset is randomly divided into a training set and a validation set, with 90% of the samples (i.e., 1305 images) used for training and the remaining 10% (i.e., 145 images) used for validation. A fixed random seed is used during the partitioning process to ensure experimental repeatability.
[0093] In this embodiment, to comprehensively evaluate the performance of the segmentation method, five benchmark datasets—CVC-300, CVC-ClinicDB, ETIS, CVC-ColonDB, and Kvasir—were selected as test sets. Specifically, the CVC-300 dataset contains 60 images, CVC-ClinicDB uses 62 images as test samples (image size 384×288), the ETIS test set contains 196 images (size 1225×966), the CVC-ColonDB dataset uses 380 images (size 574×500), and the Kvasir test set uses 100 images with sizes ranging from 332×487 to 1920×1072 pixels, showing significant differences in polyp size.
[0094] This embodiment uses six quantitative evaluation indicators to assess the model's performance, including the mean Dice coefficient (meandice, mdice), the mean intersection-over-union ratio (mean IoU, miou), and the weighted F-measure. )), structural similarity measure (structure measure, Enhanced alignment measure The metrics include the mean absolute error (MAE). The mean Dice coefficient measures the overlap between the predicted segmentation region and the ground truth label; a value closer to 1 indicates better segmentation. The mean IoU calculates the ratio of the intersection to the union of the predicted segmentation region and the ground truth label; a higher value indicates higher segmentation accuracy. The weighted F-measure considers both precision and recall; a higher value indicates better balance between positive and negative sample segmentation. The structural similarity metric evaluates the consistency between the predicted result and the ground truth label in overall structure, shape, and texture; a higher value indicates better structure preservation. The enhanced alignment metric evaluates prediction accuracy by considering pixel-level positional alignment and regional distribution differences; a higher value indicates a higher degree of alignment between the segmentation result and the ground truth label. The mean absolute error measures the average error between the predicted result and the ground truth label; a lower value indicates more accurate prediction. All metrics are calculated individually on each test image, and the final result is the average of the test set values. The formulas for calculating Dice and IoU are as follows:
[0095]
[0096]
[0097] In this context, TP represents a true positive, which is a correctly segmented polyp area; FP represents a false positive, which is a missegmentation of the background as a polyp area; and FN represents a false negative, which is a missegmentation of the polyp area as background.
[0098] This embodiment trains the segmentation model using the PyTorch framework on an NVIDIA RTX 3060 graphics card. During training, a stochastic gradient descent (SGD) optimizer is used, with a momentum coefficient of 0.9, weight decay of 1e-5, and an initial learning rate of 3e-4. The learning rate is dynamically adjusted using a polynomial decay strategy (power=0.9). The model training lasts for 80 epochs, with a batch size of 8, and the input images are uniformly scaled to 352×352 resolution. To improve the model's generalization ability and robustness, data augmentation is performed on the training images, including random rotation, random horizontal flipping, random vertical flipping (probability 0.5), and multi-scale training (scaling factors of 0.75, 1.0, and 1.25). Deep supervised loss function optimization is used during training; the segmentation model proposed in this invention employs a combination of BCE Loss (Binary CrossEntropy Loss) and Dice Loss for training. BCE Loss is used to calculate the binary classification error for each pixel, enabling the model to effectively distinguish polyp regions from background regions; Dice Loss measures the overlap between the predicted segment and the true label, enhancing the model's ability to perceive the overall shape and boundaries of polyp regions. Through joint optimization of both, the model achieves good results in both pixel-level accuracy and region-level consistency, while gradient clipping (threshold 0.5) ensures training stability. The loss function calculation formula is as follows:
[0099]
[0100]
[0101]
[0102] Where N is the sample size. This represents the true label of the i-th sample. This represents the predicted probability of the i-th sample. This represents the summation over all samples.
[0103] The above embodiments can effectively achieve high-precision segmentation of colon polyps, while ensuring the stability and generalization ability of the model under different datasets and complex scenarios, providing technical support for automated clinical polyp detection.
[0104] This invention provides a computer device, which includes a memory and a processor. The memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the medical image segmentation method based on multi-scale global context awareness and boundary-guided fusion.
[0105] This invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the steps of the medical image segmentation method based on multi-scale global context awareness and boundary-guided fusion.
[0106] In one embodiment, the proposed multi-scale global context-aware and boundary-guided fusion network MCBASegFormer was compared with seven state-of-the-art methods, including U-Net, U-Net++, TransUnet, PraNet, TGANet, MSRAformer, and MEGANet, where MEGANet uses Res2Net-50 as its backbone network. In this embodiment, the multi-scale global context-aware and boundary-guided fusion network uses the Kvasir dataset and the CVC-ClinicDB dataset as training samples. Although these two datasets were not visible during the testing phase, their image distribution closely matched the training samples, thus they were considered visible datasets. In one embodiment, the experimental results on the visible datasets are shown in Table 1. Compared to the second-best model on the CVC-ClinicDB dataset, MCBASegFormer improved the mean Dice by 1.7% and the weighted F-measure by 2.1%, demonstrating superior segmentation performance and boundary continuity, effectively reducing artifact interference and boundary spikes common in traditional methods. In one embodiment, the remaining three datasets, which were not present during the training phase, are considered invisible datasets, and their model generalization capabilities are shown in Table 2. In one embodiment, for the ETIS dataset, which has a high segmentation difficulty, this method achieves 77.2% and 68.8% in mean Dice and mean intersection-over-union (IoU), respectively, which are 2.7% and 3.2% higher than MSRAformer, indicating that the multi-scale global context-aware and boundary-guided fusion network still has significant advantages in scenarios with small targets, complex shapes, and severe background interference. In this embodiment, through the dynamic channel weight allocation of the multi-scale feature fusion module, this method can adapt to polyp features of different sizes and shapes to achieve high-precision segmentation. At the same time, the global context-aware module enhances the semantic information of the main body while preserving the key details of the polyp through a global-local dual-stream attention mechanism, and uses multi-branch dilated convolution to fuse the global context to ensure the integrity of the lesion, thus exhibiting good segmentation performance and robust generalization ability on both visible and invisible datasets.
[0107] Table 1. Results of MCBASegFormer and other advanced methods on the visible datasets Kvasir and CVC-ClinicDB.
[0108]
[0109] Table 2 Results of MCBASegFormer and other advanced methods on the invisible datasets ETIS, CVC-ColonDB, and CVC-300.
[0110]
[0111] It should be noted that embodiments of the present invention can be implemented in hardware, software, or a combination of both. The hardware portion can be implemented using dedicated logic; the software portion can be stored in memory and executed by a suitable instruction execution system, such as a microprocessor or dedicated-design hardware. Those skilled in the art will understand that the above-described devices and methods can be implemented using computer-executable instructions and / or included in processor control code, for example, such code provided on a carrier medium such as a disk, CD, or DVD-ROM, a programmable memory such as read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. The devices and modules of the present invention can be implemented by hardware circuitry such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, or programmable hardware devices such as field-programmable gate arrays, programmable logic devices, etc., or by software executed by various types of processors, or by a combination of the above-described hardware circuitry and software, such as firmware.
[0112] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications, equivalent substitutions, and improvements made by those skilled in the art within the scope of the technology disclosed in the present invention, and within the spirit and principles of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A medical image segmentation method based on multi-scale global context awareness and boundary-guided fusion, characterized in that, Includes the following steps: Acquire colonoscopy polyp image data, and perform normalization, data augmentation, and size unification processing on the images; A hierarchical Transformer coding network is used to extract multi-scale features from the input image to obtain coded features containing different semantic information; The encoded features are input into the decoding structure, and the spatial resolution is restored through step-by-step upsampling and residual connection to output the polyp segmentation result.
2. The method according to claim 1, characterized in that, In the multi-scale feature extraction process, features at each scale enter the global context-aware module and the boundary-guided fusion module respectively. The feature aggregation module then fuses the semantic and spatial features at different scales to provide fused features to the decoding structure.
3. The method according to claim 1, characterized in that, During the decoding process, the upsampled features are compensated for details and reconstructed using a circular residual convolution module to enhance the texture representation of the polyp region and improve the final segmentation accuracy.
4. The method according to claim 1, characterized in that, In the feature fusion process, a pyramid global attention module is used to adjust feature weights through a parallel structure of channel attention branches and spatial attention branches, so as to improve the feature discrimination ability in low contrast and complex backgrounds.
5. A global context-aware module, characterized in that, This includes multi-scale dilated convolution branches, spatial attention branches, and channel attention branches; The multi-scale dilated convolution branch processes the input features through three convolutional paths with dilation ratios of 1, 3, and 5, respectively, to obtain three sets of multi-scale features. The three sets of features are concatenated in the channel dimension, and spatial attention weights are generated through one-dimensional convolution to weight the multi-scale features. The spliced features obtain channel attention weights through global average pooling and a two-level fully connected structure, and the multi-scale features are then processed by channel weighting. The spatially weighted features and the channel-weighted features are fused through a cross-attention structure to output global context features.
6. The module according to claim 5, characterized in that, The cross-attention structure processes spatial weighted features and channel weighted features through one-dimensional convolution and three-dimensional convolution, respectively. After processing by activation functions, the final spatial weights and channel weights are generated. The weighted features are then fused to obtain the output features.
7. A boundary-guided fusion module, characterized in that, This includes the reverse attention branch, the prediction boundary branch, and the high-frequency edge branch; The reverse attention branch activates the prediction map and performs a reverse transformation to generate reverse features, which are then fused with the encoded features to suppress background interference. The predicted boundary branch performs edge operator processing on the predicted map to obtain predicted boundary features, which are then fused with encoded features to enhance the boundary localization capability. The high-frequency edge branch utilizes the fusion of high-frequency edge features and encoded features from the input image; The three-branch outputs are spliced and convolutionally processed to generate fused features.
8. The module according to claim 7, characterized in that, The fused features are processed by convolution, normalization, and activation after splicing, which simultaneously enhances the structural features and boundary details of the polyp region.
9. A medical image segmentation system, characterized in that, It includes a data preprocessing unit, an encoding unit, a feature fusion unit, and a decoding unit; The data preprocessing unit is used to perform normalization, enhancement, and size unification processing on the polyp images; The encoding unit is used to extract multi-scale semantic features from the input image; The feature fusion unit includes a global context-aware module, a boundary-guided fusion module, and a pyramid global attention module, which are used to perform multi-scale fusion of encoded features; The decoding unit is used to upsample and reconstruct the fused features to output medical image segmentation results.
10. The system according to claim 9, characterized in that, The decoding unit performs gradient feedback reconstruction of multi-level fused features through a ring residual convolution structure, so that the restored spatial details maintain continuity and structural integrity.