A medical image segmentation method based on wavelet transform combined with SAM in bridging mode
By combining wavelet transform and adaptive attention mechanism with CNN and SAM, the shortcomings in processing multi-scale features and boundary details in medical image segmentation are addressed. A composite loss function is designed to improve the accuracy and robustness of ultrasound image segmentation.
Patent Information
- Application Number
- CN202510048374.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-13
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2045-01-13
AI Technical Summary
Existing medical image segmentation algorithms have shortcomings in handling multi-scale features and boundary details. Especially in ultrasound images with low contrast and a lot of noise, traditional CNN models have difficulty effectively distinguishing target objects from the background, SAM models lack understanding of details and features in medical images, and loss functions fail to effectively improve the segmentation accuracy of boundary regions.
By combining convolutional neural networks (CNN) and Segment Anything Model (SAM), multi-scale feature decomposition is performed through wavelet transform, low-frequency and high-frequency features are fused using a bridging mode, and feature weighting is performed through an adaptive attention mechanism. A composite loss function of Dice coefficient and boundary-aware BCE loss is designed to improve the model's sensitivity to boundaries and details.
It significantly improves the boundary accuracy and detail recovery capability of medical image segmentation, especially in images with blurred boundaries and low contrast, thereby enhancing segmentation accuracy and robustness.
Smart Images

Figure CN119888230B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of medical image segmentation technology, specifically relating to a medical image segmentation method based on a combination of wavelet transform and SAM using bridging mode. Background Technology
[0002] Medical image segmentation technology plays a vital role in modern medical diagnosis and treatment. It uses computer-aided identification and segmentation of organs, tissues, and lesions in medical images, providing doctors with precise anatomical and pathological information to support clinical decision-making, surgical planning, and treatment evaluation. Ultrasound images, as a widely used type of imaging in clinical diagnosis, possess many unique characteristics. The low contrast and high noise of ultrasound images often make it difficult to distinguish target objects from the background, especially when the boundaries of soft tissue and lesions are blurred. Furthermore, the quality of ultrasound imaging is highly dependent on the operator's skill and equipment parameters; image acquisition is often affected by the probe angle and position. These factors make ultrasound image segmentation more complex than other imaging techniques and place higher demands on the segmentation accuracy of the model. Simultaneously, because ultrasound images can be acquired in real time, efficient and accurate automatic segmentation technology is crucial for improving the speed and accuracy of clinical diagnosis.
[0003] In recent years, with the rapid development of deep learning in computer vision, Convolutional Neural Networks (CNNs) have become the mainstream method for medical image segmentation. However, CNNs have certain limitations in processing global information, boundary details, and multi-scale features in images, especially in images with complex backgrounds or blurred boundaries, where their performance is often affected. To address these issues, the Segment Anything Model (SAM), as a model based on large-scale pre-training, has demonstrated powerful capabilities in natural image segmentation tasks. SAM is trained on large-scale datasets using the Vision Transformer (ViT) architecture, effectively processing global information in images and providing relatively accurate segmentation results. However, due to the unique characteristics of medical images, especially ultrasound images, in terms of contrast, noise, and boundary blurring, the results of directly applying SAM to medical image segmentation tasks are often less than expected. The existing technologies specifically suffer from the following problems:
[0004] (1) Current medical image segmentation algorithms, especially those based on convolutional neural networks (CNNs), have significant shortcomings in handling multi-scale features and boundary details. This is because the receptive field of CNNs is usually fixed and cannot effectively adapt to multi-scale features in images. Due to low contrast, high noise, and blurred boundaries in ultrasound images, traditional CNN models struggle to effectively distinguish target objects from the background, especially in the transition region between diseased and healthy tissues, leading to decreased segmentation accuracy. These problems have not been effectively solved in traditional CNNs, particularly when dealing with low-contrast and complex backgrounds like ultrasound images. They still fail to fully consider the features of different scales and detailed regions, affecting segmentation accuracy.
[0005] (2) The SAM (Segment Anything Model) has achieved good results in natural image segmentation tasks, but its direct application to medical images, especially ultrasound images, often faces significant challenges. The pre-training dataset for SAM mainly comes from natural images and lacks relevant data on medical images, resulting in its inability to fully understand the details and features of medical images. In particular, the global information modeling capability of SAM does not effectively compensate for the problems of blurred edges, low contrast, and noise in ultrasound images, leading to the model's inability to accurately segment lesion areas.
[0006] (3) In medical image segmentation tasks, the design of the loss function is crucial to the training and accuracy of the model. Currently, most medical image segmentation models mainly rely on Dice coefficient loss and binary cross-entropy (BCE) loss. Dice coefficient loss can effectively handle class imbalance, but it focuses more on global overlap and is weak in handling boundary details, especially in images with blurred boundaries or low contrast, failing to provide sufficient signals to optimize edges. BCE loss is suitable for pixel-level classification, but it treats all pixel regions equally and fails to effectively focus on boundary regions, resulting in insufficient segmentation accuracy. In ultrasound images, the boundaries of target objects are usually blurred and have low contrast. Traditional loss functions fail to provide sufficient training signals for these boundary regions, resulting in low segmentation accuracy of the model in the boundary parts. In addition, existing loss functions usually do not weight boundary information, failing to effectively improve the segmentation effect of detailed regions, thus affecting the overall segmentation accuracy.
[0007] Therefore, this invention explores a combination of CNN and SAM, using a hybrid model where CNN is used for local feature extraction and SAM is used for global information modeling. This aims to improve the model's ability to handle boundary details and multi-scale features. This combination not only compensates for the shortcomings of CNN in global modeling but also improves segmentation accuracy through SAM's powerful contextual understanding capabilities, thus providing more accurate and stable segmentation results in high-noise, low-contrast medical images such as ultrasound images.
[0008] Furthermore, wavelet transform (WT), a technique advantageous in time-frequency analysis, can effectively handle multi-scale features of images. Unlike traditional Fourier transform, wavelet transform provides both local and global information of an image in both the time and frequency domains, making it particularly suitable for processing non-stationary signals with multi-scale features. In medical image segmentation tasks, combining convolutional neural networks (CNNs) and wavelet transform can significantly enhance the model's ability to extract information at different scales. While CNNs excel at extracting local features, they have limitations in handling multi-scale features and capturing image boundary details, especially in low-contrast, noisy, and blurred ultrasound images. Wavelet transform can decompose an image into sub-images of multiple scales and frequencies, effectively capturing high-frequency details such as edges, textures, and minute lesions, thus helping the model better distinguish target objects from the background in complex environments. Moreover, the multi-scale decomposition of wavelet transform can improve the robustness of image processing and reduce the interference of noise on the segmentation results. Therefore, combining CNN and wavelet transform can not only improve the segmentation accuracy of the model in ultrasound images, but also enhance its sensitivity to image boundaries and details, especially when dealing with the boundaries of soft tissue and lesions, which can significantly improve the segmentation effect.
[0009] Therefore, this invention proposes a medical image segmentation method based on a combination of wavelet transform and SAM in bridging mode. Summary of the Invention
[0010] The purpose of this invention is to provide a medical image segmentation method based on wavelet transform and SAM combined with bridging mode, in order to solve the problems that existing methods fail to fully consider the impact of features of different scales and detailed regions on segmentation accuracy, and that existing loss functions cannot effectively improve the segmentation effect of detailed regions.
[0011] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0012] The first aspect of this invention proposes a medical image segmentation method based on a combination of wavelet transform and SAM using bridging mode, comprising at least the following steps:
[0013] S1. Data preprocessing: Perform data augmentation on the input image and standardize the input image;
[0014] S2. Feature extraction: The preprocessed image is used to extract preliminary features using a convolutional neural network, and then multi-scale feature decomposition is performed through wavelet transform to obtain low-frequency feature maps and high-frequency feature maps.
[0015] S3. Multi-scale feature fusion: Low-frequency feature maps and high-frequency feature maps are fused through a bridging mode. The fused features are weighted using an adaptive attention mechanism, and the weighted features are recovered using inverse wavelet transform. Feature maps that have undergone different processing are then weighted and fused.
[0016] S4. Feature Decoding and Prediction: Image features are decoded using a self-attention mechanism, and deformable attention mechanism is used to adjust the image features. After decoding, the features are input into the prediction head, and the predicted bounding box coordinates and target category are finally output.
[0017] Preferably, S1 is specifically as follows:
[0018] First, the images are normalized by scaling their pixel values to a standard range. Second, data augmentation is performed on the images, including random cropping, translation, rotation, and horizontal flipping. Finally, all images are resized to a uniform size.
[0019] Furthermore, the input images are first normalized. Normalization scales each pixel value to the range [0,1] to eliminate brightness differences between different images and reduce bias during model training. Secondly, data augmentation methods (such as random cropping, rotation, flipping, and translation) are used to improve the model's robustness and ensure good performance even with varying image deformations and noise. Next, the images are resized. To avoid image distortion, scaling is performed while maintaining the original aspect ratio, and blank areas are filled with black. Finally, all images are uniformly resized to 256×256 pixels, and pixel values are further normalized to ensure standardized input image processing.
[0020] Preferably, step S2 is as follows:
[0021] Assuming the input feature is x, the input feature is initially processed through a convolutional layer (SingleConv) to obtain the initial low-level feature x1; this process can be represented as:
[0022] x1 = SingleConv(x1)
[0023] Input feature x1 undergoes wavelet transform and multi-scale decomposition to extract low-frequency and high-frequency information, represented as:
[0024] x2,x3=DWT(x1)
[0025] Where x2 represents the features of the low-frequency part, capturing the overall structure of the image; x3 represents the features of the high-frequency part, capturing the details and edge information of the image; DWT is wavelet transform.
[0026] Furthermore, the wavelet transform undergoes multi-scale decomposition, as follows:
[0027] Wavelet transform decomposes the input feature map using a filter bank, as follows:
[0028]
[0029] in, and These are the low-pass and high-pass filters, respectively, and m and n are the coordinates of the image.
[0030] Preferably, step S3 is as follows:
[0031] Features x2 and x3 are fused using a bridging mode to preserve information at different scales, as shown below:
[0032] x bridge =Concat(x2,x3)
[0033] Where Concat represents the bridging layer, x bridge This represents the feature obtained by fusing the features of the low-frequency component and the features of the high-frequency component;
[0034] For feature x bridge Global information modeling using Transformer is represented as follows:
[0035] x4 = Transformer(x bridge )
[0036] After being modeled by the Transformer, feature x4 is restored to its spatial dimension through inverse wavelet transform, resulting in the restored feature x5, represented as:
[0037] x5 = IWT(x4)
[0038] Where IWT represents inverse wavelet transform;
[0039] After wavelet transform, Transformer modeling, and inverse wavelet transform, the feature x5 is weighted and fused with the initial input feature x through residual connection to obtain the final output feature map x. out , is represented as:
[0040] x oUt = x + 0.5 × x5.
[0041] Furthermore, the Transformer performs global information modeling, as follows:
[0042] The Transformer models long-range dependencies in images through a self-attention mechanism to obtain global contextual information. The self-attention mechanism calculation process is as follows:
[0043]
[0044] Where Q is the query, K is the key, V is the value, and d is the feature dimension; the self-attention mechanism enhances the modeling of long-range dependencies in the image through these weighted coefficients.
[0045] Furthermore, the inverse wavelet transform restores the spatial dimension, as follows:
[0046] The inverse wavelet transform process reconstructs the low-frequency and high-frequency features back to the original features, as shown below:
[0047]
[0048] Where, δ L and δ H It is the inverse of low-pass and high-pass filters, used to recover frequency domain information to the spatial domain.
[0049] The second aspect of this invention proposes a medical image segmentation system based on a bridging mode wavelet transform combined with SAM, applicable to the above-mentioned method. The system employs a medical image segmentation model, which includes:
[0050] The BridgeWave Transformer hybrid encoder includes a wavelet transform module, a bridging layer, a Transformer encoder, an inverse wavelet transform module, and a weighted fusion module. The Transformer encoder is based on the ViT architecture in SAM and has an adaptive attention mechanism. It is used for feature extraction and multi-scale feature fusion.
[0051] The decoder, comprising a multi-head self-attention module, a deformable attention module, and a prediction head, is used for feature decoding and prediction.
[0052] Preferably, during the training phase, the Dice loss and boundary-aware BCE loss in the image segmentation task are calculated separately, and the total loss of the model is obtained by combining the two loss functions. The gradient of the loss is calculated by the backpropagation algorithm, and the model network parameters are updated.
[0053] For the composite loss function combining Dice loss and boundary-aware BCE loss, the formula for the composite loss function is:
[0054] Total Loss=β1·Dice Loss+β2·Boundary_Aware BCE Loss
[0055] Here, β1 and β2 are hyperparameters used to balance the weights of the two loss components; Dice Loss is the Dice loss, and Boundary-Aware BCE Loss is the boundary-aware BCE loss.
[0056] Furthermore, the Dice loss is specifically as follows:
[0057]
[0058] Among them, y pred It is the predicted binary image, y true The image is the actual labeled image; the Dice coefficient is used to measure the overlap between the predicted and the actual label, and the goal of Dice Loss is to minimize the difference between the segmented region and the actual region.
[0059] Furthermore, the boundary-aware BCE loss is specifically as follows:
[0060]
[0061] Among them, w boundary (y true ) is a weight function that is dynamically adjusted based on boundary information.
[0062] Compared with the prior art, the present invention has the following beneficial effects:
[0063] (1) The method proposed in this invention is a feature extraction method combining wavelet transform and adaptive attention mechanism (SAM). First, the input image undergoes preliminary feature extraction through a convolutional layer (SingleConv) to extract low-level edge and texture information. Next, the features are decomposed into low-frequency and high-frequency components through discrete wavelet transform (DWT). The low-frequency component preserves the overall structure of the image, while the high-frequency component captures the details and edge information of the image. After multi-scale decomposition, the low-frequency and high-frequency features are concatenated and fused through a bridge connection mode to ensure effective preservation of multi-scale information and transmission of details. Finally, the fused feature map is input into a SAM-based Transformer module, which models the global information in the image through a self-attention mechanism, further improving the expressive power of the features. This module effectively combines local detail information and global contextual information, and is particularly suitable for feature extraction tasks in medical images with blurred boundaries and low contrast.
[0064] (2) To address the issues of blurred boundaries and loss of detail in small targets during medical image segmentation, this invention designs a composite loss function combining the Dice coefficient and boundary-aware BCE loss. A boundary weight coefficient is introduced on top of the standard binary cross-entropy (BCE) loss, enabling the model to focus on the prediction accuracy of boundary regions. The Dice loss measures the overlap between the predicted segmented region and the ground truth label region, and is suitable for handling class imbalance and small target tasks. The boundary-aware BCE loss dynamically adjusts the boundary region weights, strengthening the model's training signal for boundary regions, thereby improving the boundary accuracy of the segmentation results. Finally, the composite loss function combines the two weighted values. Attached Figure Description
[0065] Figure 1 This is a structural block diagram of the medical image segmentation system based on the combination of wavelet transform and SAM in bridging mode in this invention;
[0066] Figure 2 This is a block diagram of the wavelet transform module in the BridgeWave Transformer hybrid encoder of this invention;
[0067] Figure 3 This is a structural block diagram of the Transformer encoder in the BridgeWave Transformer hybrid encoder of this invention. Detailed Implementation
[0068] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0069] Example 1:
[0070] This invention is a medical image segmentation method based on the combination of wavelet transform in bridging mode and SAM's Transformer, in order to solve the problems of insufficient boundary accuracy and detail recovery ability in medical image segmentation in the prior art, especially when processing medical images with blurred boundaries and low contrast.
[0071] To achieve the above objectives, this invention provides the following technical solution: a medical image segmentation method based on a bridging mode wavelet transform combined with SAM. The entire method can be divided into four stages: data preprocessing, feature extraction, multi-scale feature fusion, and feature decoding and prediction. In the data preprocessing stage, the input image is normalized, stochastically transformed, and scaled to enhance the robustness of the model and standardize the input data. In the feature extraction stage, the preprocessed image is first input into the backbone network, and preliminary features are extracted using a convolutional neural network. Multi-scale feature decomposition is then performed using wavelet transform to obtain feature information in different frequency bands. In the multi-scale feature fusion stage, low-frequency and high-frequency features from the wavelet transform are combined, and the features are weighted using an adaptive attention mechanism (SAM) to improve image detail recovery and boundary accuracy. In the feature decoding and prediction stage, the fused and weighted feature map is input into the decoder, and upsampling is performed layer by layer to restore the original image size, ultimately outputting an accurate segmentation result. The entire process effectively improves the boundary accuracy and detail recovery capability of medical image segmentation, especially showing strong advantages when processing low-contrast and blurred images, such as… Figure 1 As shown. Specifically:
[0072] Step 1: Data preprocessing;
[0073] To improve the model's utilization of input medical image information, the images need to be preprocessed before entering the network for feature extraction.
[0074] First, image normalization is performed, scaling the pixel values to a standard range (e.g., 0 to 1 or -1 to 1). This accelerates model convergence. Next, to increase model robustness, the training data undergoes random transformations, including random cropping, translation, rotation, and horizontal flipping. These data augmentation methods improve the network's adaptability under different conditions, especially when dealing with noise and distortion in images. Finally, all training images are resized to a uniform size to meet the input requirements of subsequent networks; typically, a fixed size (e.g., 256×256) is chosen. This process ensures the uniformity of input images and provides standardized data for subsequent processing.
[0075] Step 2: Feature extraction;
[0076] The preprocessed image is input into the feature extraction module. Wavelet transform (DWT) decomposes the image into low-frequency and high-frequency components, capturing the overall structure and detailed information of the image, respectively. The low-frequency component primarily extracts global structures, such as the background and object contours, while the high-frequency component focuses on details and edge features. The wavelet-transformed low-frequency and high-frequency feature maps are then fed into a convolutional neural network (CNN) to further extract low-level features (such as edges and textures), generating feature maps at multiple scales to represent information at different levels of the image.
[0077] Step 3: Multi-scale feature fusion;
[0078] Low-frequency and high-frequency features are fused using a bridge connection. The bridge connection concatenates low-frequency and high-frequency features from different scales, ensuring effective preservation of semantic information at different scales. This fusion method effectively prevents the loss of details and provides rich, multi-layered features for subsequent Transformer modules. After fusing the low-frequency and high-frequency features through the bridge layer, the resulting feature map is fed into the next stage of global information modeling.
[0079] The bridged and fused features are then fed into the Transformer encoder, which is based on the ViT architecture in the SAM model. The Transformer models long-range dependencies in the image through a self-attention mechanism, capturing global contextual information. This module, by modeling global information, enables the network to understand the relationships between distant pixels in the image, thereby improving segmentation performance. The features processed by the Transformer are then recovered using inverse wavelet transform (IWT), and the recovered features are returned to the spatial domain, thus preserving the image's details and structural information.
[0080] Specifically, in this invention, feature extraction and multi-scale feature fusion are achieved through a BridgeWave Transformer hybrid encoder. The function of this BridgeWave Transformer hybrid encoder is to extract detailed and global information from images at multiple scales, particularly in medical images with blurred boundaries and low contrast, thereby improving the model's feature extraction capabilities. The module structure is as follows: Figure 2-3 As shown.
[0081] The main working principle of this module is as follows: Assuming the input feature is x, the input feature is first processed through a convolutional layer (SingleConv) to obtain preliminary low-level features x1. The convolutional kernel size is 3×3, and the number of channels is C. The purpose is to extract low-level features from the image, such as edge and texture information. This process can be represented as:
[0082] x1 = SingleConv(x1)
[0083] Then, the input feature x1 is decomposed into multiple scales using wavelet transform (DWT) to extract low-frequency and high-frequency information:
[0084] x2,x3=DWT(x1)
[0085] Here, x2 represents the low-frequency component, which captures the overall structure of the image; x3 represents the high-frequency component, which captures the details and edge information of the image.
[0086] Specifically, DWT decomposes the input feature map using a filter bank:
[0087]
[0088] in, and These are a low-pass filter and a high-pass filter, respectively, where m and n are the coordinates of the image. Through this decomposition, the low-frequency component retains the coarse information of the image, while the high-frequency component captures details and edge information.
[0089] Next, features x2 and x3 will be fused using a bridge connection. The bridge layer will stitch these two feature sets together to preserve information at different scales.
[0090] x bridge =Concat(x2,x3)
[0091] This stitching method ensures the preservation of multi-scale information, avoids the loss of details, and provides rich multi-level features for subsequent Transformer modules, which helps subsequent models better preserve boundaries and details when processing images.
[0092] Then, feature x bridge It will be fed into the Transformer module for global information modeling. The Transformer module is based on the ViT (Vision Transformer) architecture in SAM (Segment Anything Model).
[0093] x4 = Transformer(x bridge )
[0094] The Transformer models long-range dependencies in images through a self-attention mechanism to obtain global contextual information. The self-attention mechanism calculation process is as follows:
[0095]
[0096] Where Q is the query, K is the key, V is the value, and d is the feature dimension. The self-attention mechanism enhances the modeling of long-range dependencies in images through these weighted coefficients.
[0097] Next, the feature x4 modeled by the Transformer will be restored to the spatial dimension through inverse wavelet transform (IWT) to obtain the restored feature x5:
[0098] x5 = IWT(x4)
[0099] The process of IWT involves reconstructing low-frequency and high-frequency features back to the original features:
[0100]
[0101] Where, δ L and δ H It is an inverse low-pass and high-pass filter used to restore frequency domain information to the spatial domain. The inverse wavelet transform restores features from the frequency domain of the wavelet transform to the spatial domain, thereby preserving detailed information and restoring the structure of the image.
[0102] Finally, the feature x5 after wavelet transform, Transformer modeling, and inverse wavelet transform is weighted and fused with the initial input feature x through residual connection to obtain the final output feature map x. out :
[0103] x out =x + 0.5 × x5
[0104] This weighted fusion allows the model to better combine initial input features with the output after deep feature modeling, improving image segmentation and reconstruction performance, especially in images with blurred boundaries and lost details. Residual connections help avoid the vanishing gradient problem during training and improve model stability.
[0105] Step 4: Feature Decoding and Prediction;
[0106] This process is implemented using a decoder. The decoder uses a multi-head self-attention module and a deformable attention module to further process the features output by the encoder.
[0107] First, the decoder decodes image features using a self-attention mechanism to capture long-range dependencies and enhance the understanding of global image information. Then, a deformable attention mechanism is used to further refine the features, optimizing the modeling of details and complex structures. The decoded feature sequence is then input into the prediction head, ultimately outputting the predicted bounding box coordinates and object category. This process accurately generates object segmentation maps and classifies different objects, improving segmentation accuracy, and exhibiting strong robustness, especially when dealing with images with blurred details or indistinct boundaries.
[0108] The above method is implemented using a medical image segmentation model, which includes a BridgeWave Transformer hybrid encoder, decoder, and data preprocessing module. This outlines the entire process during the model inference phase. During training, the Dice loss and boundary-aware BCE loss for the image segmentation task are calculated separately, and the total loss of the model is obtained by combining these two loss functions. The gradient of the loss is calculated using backpropagation, and the network parameters are gradually adjusted to optimize the segmentation results.
[0109] This invention proposes a composite loss function combining the Dice coefficient and the boundary-aware binary cross-entropy loss (BCE Loss) to improve the accuracy of image segmentation tasks, especially when dealing with images with blurred boundaries and lost details. The combination of these two loss functions improves the overall segmentation performance and enhances the prediction ability for details and boundary regions. The calculated loss is used to update the network parameters through backpropagation to improve the model's segmentation accuracy. Therefore, in training mode, the Dice coefficient loss and the boundary-aware BCE loss are used to optimize the model.
[0110] The loss function consists of two parts: Dice coefficient loss, which measures the similarity between the predicted image and the true label, and is particularly suitable for handling imbalanced datasets and small objects; and Boundary-Aware BCE loss, which strengthens the focus on the boundary between the target object and the background on the basis of the standard binary cross-entropy loss function (BCE), thereby improving the accuracy of the segmentation results in the boundary region. Specifically, by adding the weight of the boundary region, the model can provide a higher training signal when segmenting the boundary region, thus enhancing the prediction accuracy of the boundary.
[0111] The composite loss function combining the Dice coefficient and the boundary-aware BCE coefficient is as follows:
[0112] 1) The Dice coefficient is used to measure the overlap between the predicted and the true labels. Its calculation formula is as follows:
[0113]
[0114] Where A and B represent the predicted and actual binary regions, respectively. A larger Dice coefficient indicates a higher degree of overlap between the predicted and actual regions. The Dice loss is:
[0115]
[0116] Among them, y pred It is the predicted binary image, y true These are real labeled images. The goal of Dice Loss is to minimize the difference between the segmented regions and the real regions, thereby improving the overall accuracy of segmentation.
[0117] 2) Boundary-Aware BCE Loss introduces weights into the standard binary cross-entropy loss function to highlight boundary regions in the image, thereby improving the model's segmentation accuracy of boundary regions. The standard BCE loss is:
[0118]
[0119] The boundary-aware BCE loss modifies this standard formula by adding greater weight to the boundary region, and is defined as:
[0120]
[0121] Among them, y true and y pred These are the image's true label and the predicted result, respectively.
[0122] w boundary (y ttue `boundary_weight` is a dynamically adjusted weight function based on boundary information. Its purpose is to enhance the segmentation accuracy of boundary regions during training, ensuring the model can more accurately predict boundary regions in an image, thus strengthening the training signal for boundary regions. Typically, boundary regions receive a larger weight, encouraging the model to make more accurate predictions in these areas.
[0123] 3) Combination loss function
[0124] The final loss function is a weighted sum of the Dice coefficient loss and the boundary-aware BCE loss. The formula for this composite loss function is:
[0125] Total Loss=β1·Dice Loss+β2·Boundary_Aware BCE Loss
[0126] Here, β1 and β2 are hyperparameters used to balance the weights of the two parts of the loss. Typically, the choice of β1 and β2 depends on the requirements of boundary accuracy and overall segmentation accuracy in the specific task.
[0127] Based on the above-described invention, the following evaluation of its technical effects is proposed:
[0128] Performance evaluation: This invention was tested and evaluated on the TN3K and BUSI datasets. The TN3K dataset is an ultrasound image dataset for thyroid nodule segmentation, containing 3493 images and segmentation annotations, divided into training and testing sets. BUSI is a classification and segmentation dataset containing breast ultrasound images, consisting of 780 images classified into three categories: normal, benign, and malignant. The ratio of the training, testing, and validation sets was 7:2:1.
[0129] This invention compares various optimized and improved algorithms with the benchmark model SAM.
[0130] Table 1 shows the comparative test results on the BUSI and TN3K datasets.
[0131]
[0132]
[0133] The results show that the present invention achieves state-of-the-art performance on both datasets. On the TN3K dataset, the Dice coefficient reaches 84.50 and the Hausdorff distance (HD) is 28.11; on the BUSI dataset, the Dice coefficient reaches 88.27 and the HD is 21.57. Compared to the baseline model SAM and various optimization algorithms, the present invention demonstrates significant advantages in both segmentation accuracy (Dice coefficient) and boundary consistency (HD).
[0134] The above description is only for the purpose of helping to understand the method and core essence of the present invention, but the scope of protection of the present invention is not limited thereto. For those skilled in the art, any equivalent substitutions or modifications made to the technical solution and inventive concept disclosed in the present invention within the scope of the technology disclosed in the present invention should be covered within the scope of protection of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A medical image segmentation method based on wavelet transform combined with SAM using bridging mode, characterized in that, At least the following steps are included: S1. Data preprocessing: Perform data augmentation on the input image and standardize the input image; S2, Feature Extraction; The preprocessed image is used to extract preliminary features using a convolutional neural network, and then multi-scale feature decomposition is performed using wavelet transform to obtain low-frequency feature maps and high-frequency feature maps. S3, Multi-scale feature fusion; Low-frequency and high-frequency feature maps are fused using a bridging mode. The fused features are then weighted using an adaptive attention mechanism and recovered using inverse wavelet transform. Feature maps that have undergone different processing are then weighted and fused. S4. Feature Decoding and Prediction: Image features are decoded using a self-attention mechanism, and deformable attention mechanisms are used to adjust the image features. After decoding, the features are input into the prediction head, and the final output is the predicted bounding box coordinates and target category.
2. The medical image segmentation method based on wavelet transform and SAM combined with bridging mode according to claim 1, characterized in that, S2 is specifically as follows: Assuming the input feature is x, the input feature is initially processed through a convolutional layer to obtain a preliminary low-level feature x1; this process can be represented as: x1 = SingleConv(x1) Input feature x1 undergoes wavelet transform and multi-scale decomposition to extract low-frequency and high-frequency information, represented as: x2,x3=DWT(x1) Where x2 represents the features of the low-frequency part, capturing the overall structure of the image; x3 represents the features of the high-frequency part, capturing the details and edge information of the image; DWT is wavelet transform.
3. The medical image segmentation method based on wavelet transform and SAM combined with bridging mode according to claim 2, characterized in that, The wavelet transform is performed as a multi-scale decomposition, as follows: Wavelet transform decomposes the input feature map using a filter bank, as follows: in, and These are the low-pass and high-pass filters, respectively, and m and n are the coordinates of the image.
4. The medical image segmentation method based on wavelet transform and SAM combined with bridging mode according to claim 3, characterized in that, S3 is specifically as follows: Features x2 and x3 are fused using a bridging mode to preserve information at different scales, as shown below: x bridge =Concat(x2,x3) Where Concat represents the bridging layer, x bridge This represents the feature obtained by fusing the features of the low-frequency component and the features of the high-frequency component; For feature x bridge Global information modeling using Transformer is represented as follows: x4=Transformer(x bridge ) After being modeled by the Transformer, feature x4 is restored to its spatial dimension through inverse wavelet transform, resulting in the restored feature x5, represented as: x5 = IWT(x4) Where IWT represents inverse wavelet transform; After wavelet transform, Transformer modeling, and inverse wavelet transform, the feature x5 is weighted and fused with the initial input feature x through residual connection to obtain the final output feature map x. out , is represented as: x out =x+0.5×x5。 5. The medical image segmentation method based on wavelet transform and SAM combined with bridging mode according to claim 4, characterized in that, The Transformer performs global information modeling, as follows: The Transformer models long-range dependencies in images through a self-attention mechanism to obtain global contextual information. The self-attention mechanism calculation process is as follows: Where Q is the query, K is the key, V is the value, and d is the feature dimension; the self-attention mechanism enhances the modeling of long-range dependencies in the image through these weighted coefficients.
6. The medical image segmentation method based on wavelet transform and SAM combined with bridging mode according to claim 4, characterized in that, The inverse wavelet transform restores the spatial dimension, as detailed below: The inverse wavelet transform process reconstructs the low-frequency and high-frequency features back to the original features, as shown below: Where, δ L and δ H It is the inverse of low-pass and high-pass filters, used to recover frequency domain information to the spatial domain.
7. A medical image segmentation system based on wavelet transform and SAM combined with bridging mode, applied to the method of any one of claims 1-6, characterized in that, A medical image segmentation model is employed, which includes: The BridgeWave Transformer hybrid encoder includes a wavelet transform module, a bridging layer, a Transformer encoder, an inverse wavelet transform module, and a weighted fusion module. The Transformer encoder is based on the ViT architecture in SAM and has an adaptive attention mechanism. It is used for feature extraction and multi-scale feature fusion. The decoder, comprising a multi-head self-attention module, a deformable attention module, and a prediction head, is used for feature decoding and prediction.
8. The medical image segmentation system based on bridging mode wavelet transform and SAM according to claim 7, characterized in that, During the training phase, the Dice loss and boundary-aware BCE loss in the image segmentation task are calculated separately, and the total loss of the model is obtained by combining the two loss functions. The gradient of the loss is calculated by the backpropagation algorithm, and the model network parameters are updated. For the composite loss function combining Dice loss and boundary-aware BCE loss, the formula for the composite loss function is: Total Loss=β1·Dice Loss+β2·Boundary_Aware BCE Loss Here, β1 and β2 are hyperparameters used to balance the weights of the two loss components; Dice Loss is the Dice loss, and Boundary-Aware BCE Loss is the boundary-aware BCE loss.
9. The medical image segmentation system based on bridging mode wavelet transform and SAM according to claim 8, characterized in that, The Dice loss is specifically as follows: Among them, y pred It is the predicted binary image, y true The image is the actual labeled image; the Dice coefficient is used to measure the overlap between the predicted and the actual label, and the goal of Dice Loss is to minimize the difference between the segmented region and the actual region.
10. The medical image segmentation system based on bridging mode wavelet transform and SAM according to claim 9, characterized in that, The boundary-aware BCE loss is specifically as follows: Among them, w boundary (y true ) is a weight function that is dynamically adjusted based on boundary information.