A medical image segmentation method based on multi-scale feature fusion
By constructing a medical image segmentation method based on multi-scale feature fusion, and utilizing CNN and Transformer channels to extract and fuse multi-scale features in the encoder and decoder, the problem of insufficient multi-scale information acquisition is solved, and more efficient medical image segmentation results are achieved.
Patent Information
- Application Number
- CN202311190293.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-15
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-09-15
AI Technical Summary
Existing medical image segmentation methods, due to insufficient acquisition of multi-scale information and limitations in computational cost, cannot fully learn multi-scale information, and after acquiring multi-scale information, they fail to make full use of the differences in features at different scales, affecting the segmentation results.
A multi-scale feature fusion medical image segmentation method is constructed by building multi-scale feature extraction modules and cross-feature extraction modules in the encoder and decoder, and combining CNN and Transformer channels to perform comprehensive extraction and fusion of multi-scale features. Five-fold cross-validation and weighted loss function are used to optimize model parameters.
Effective learning of multi-scale information in images alleviates the problem of inconsistent multi-scale features, improves the performance of medical image segmentation, and enhances the accuracy and precision of segmentation results.
Smart Images

Figure CN117726575B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of medical image processing technology, and in particular relates to a medical image segmentation method based on multi-scale feature fusion. Background Technology
[0002] Medical image segmentation involves separating specific, meaningful regions for quantitative or qualitative analysis. It is a key issue in medical image analysis and an important component of clinical applications, such as diagnostic aids, treatment planning, efficacy evaluation, and prognosis prediction. Multi-scale information in images can enrich feature representations and improve segmentation accuracy. However, due to the complexity of the information, blurred boundaries, and varying sizes of regions of interest, fully utilizing multi-scale information in medical image segmentation remains a challenge.
[0003] With the development of deep learning, convolutional neural networks (CNNs) have been widely used in medical image segmentation. It is worth noting that while CNNs can acquire rich feature information, their lack of long-range modeling ability and incomplete extraction of global information are due to their local connectivity and the variance of translation in convolution operations. To overcome this shortcoming, Vision Transformers (ViTs) were proposed for computer vision tasks. Due to their powerful attention mechanism, ViTs perform well in extracting global information. However, because the computational cost of ViTs is much higher than that of CNNs, they are usually only used to learn single-scale features. Although segmentation networks based on CNNs and Transformers have been proposed, most of them extract multi-scale features from low-resolution high-level semantic features or learn multi-scale features between the encoder and decoder due to computational cost limitations. The high computational cost limits the comprehensive learning of multi-scale features and also hinders the ideal fusion of extracted multi-scale features.
[0004] In summary, existing medical image segmentation methods have the following problems: First, the acquisition of multi-scale information is insufficient. Due to computational cost limitations, some existing methods cannot fully learn multi-scale information. Second, after acquiring multi-scale information, they simply stitch or add it together without considering the differences between different scales, which leads to the inability to fully utilize the features of different scales and thus affects the final segmentation result. Summary of the Invention
[0005] The purpose of this invention is to provide a medical image segmentation method based on multi-scale feature fusion, so as to achieve more comprehensive multi-scale information acquisition and more sufficient multi-scale feature fusion under a lightweight model.
[0006] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is a medical image segmentation method based on multi-scale feature fusion, characterized by comprising the following steps:
[0007] S1. Collect medical image data of the same type and delineate the ROI;
[0008] S2. Preprocess medical image data;
[0009] S3. Construct a multi-scale feature extraction module;
[0010] S4. Construct a multi-scale feature fusion module;
[0011] S5. Construct an encoder-decoder deep learning network model;
[0012] S6. Perform five-fold cross-validation on the network;
[0013] S7. Use evaluation metrics to verify the segmentation performance.
[0014] Furthermore, S2 specifically refers to:
[0015] S21. Read the data obtained in S1 into memory and calculate the mean and standard deviation of the data:
[0016]
[0017]
[0018] S22. Standardize the image based on the obtained mean and standard deviation:
[0019]
[0020] Where μ represents the calculated mean, std is the calculated standard deviation, n represents the sample size, and x i Let X represent the i-th sample, X represent the entire sample, and Y represent the sample obtained after standardization.
[0021] S23. Data preprocessing is performed by flipping and scaling the image to the same size.
[0022] Furthermore, when constructing the multi-scale feature extraction module in S3, the multi-scale feature extraction module is first constructed in the encoder and decoder; then, a cross-feature extraction module is constructed between the encoder and decoder.
[0023] Furthermore, the multi-scale feature extraction module includes a CNN channel based on local information feature extraction and a Transformer channel based on global information feature extraction; the CNN channel includes convolutional layers, normalization layers, and activation functions; the CNN channel calculation method is as follows:
[0024] Y1 = Relu(BN(Conv(Y0)))
[0025] Y2 = Relu(Y + BN(Conv(Y1)))
[0026] Where Y0 represents the input feature map, Conv represents the convolution operation, BN represents the normalization operation, and ReLU represents the activation function; Y1 is the result after one convolution, normalization, and activation function; Y2 is the final output feature map after passing through the CNN channels; the Transformer channel self-attention calculation method is as follows:
[0027] Q,K,V=DewConv(Y0)
[0028] Q1 = Conv S=r (Q)
[0029] K1 = Conv S=r (K)
[0030]
[0031] Where DewConv represents depthwise separable convolution, Y0 represents the input feature map, Q is the query matrix, K is the key matrix, V is the value matrix, and Conv... S=r This represents a convolution with stride r, where matrices Q and K are convolved to obtain matrices Q1 and K1; Light_Atten represents lightweight self-attention, d k Let be the dimension of the key matrix, and Softmax be the mapping function.
[0032] Furthermore, when constructing the cross-feature extraction module, its input is the feature map output by the encoder, wherein the encoder includes three layers of multi-scale feature extraction and fusion modules; the feature map output by the first layer of multi-scale feature extraction and fusion module is a1, and the output feature maps of the second and third layers are a2 and a3, respectively; to construct the cross-feature extraction module, firstly, matrix multiplication is performed on feature maps a1 and a2; then, the result of the matrix multiplication is normalized; the processed result is multiplied by feature map a3; finally, the result of the matrix multiplication is concatenated with a3 using residuals.
[0033] Furthermore, the S4 multi-scale feature fusion module includes two inputs: local information feature f1 extracted by CNN and global information feature f2 extracted by Transformer. The multi-scale feature fusion module first concatenates f1 and f2 into a feature map matrix, divides this matrix into v different parts in the first dimension, then performs a shift operation along the y-axis in h parts, and uses convolution to learn spatial location information, resulting in the feature map Z. V Then, a shift operation is performed along the x-axis, and spatial information is learned using convolution; finally, the resulting feature map Z is... H Perform a residual connection with the input feature map matrix:
[0034] Z V =Conc(Roll(Chunk(Z,v),Vertical))
[0035] Z H =Conv(Roll(Chunk(Z) V ,h),Horizontal))
[0036] Where Z is the concatenated feature map matrix, v is the part to be segmented, Chunk represents the segmentation operation, Roll represents the shift operation, Conv represents the convolution operation, Vertical represents the shift operation along the y-axis, and Horizontal represents the shift operation along the x-axis.
[0037] Furthermore, the encoder-decoder deep learning network model in S5 consists of an encoder and a decoder structure. The network includes four layers, each of which includes a multi-scale feature extraction module and a feature fusion module. The preprocessed medical image is input, and local features are summarized and feature maps are downsampled through a convolution module with stride. The resulting input feature maps are simultaneously fed into the CNN local feature extraction channel and the Transformer global feature extraction channel, resulting in two feature matrices of the same size. These two feature matrices are concatenated and then input into the multi-scale feature fusion module, which performs feature interaction at different scales through partitioning and shifting operations.
[0038] Furthermore, for features of different scales obtained by the encoder, feature attention is fused through the cross-feature extraction module between the encoder and decoder; then the obtained features are connected to the decoder, and after multi-scale feature extraction, fusion and upsampling, a segmented mask image is obtained.
[0039] Furthermore, S6 specifically involves dividing the dataset evenly into five subsets of similar size, using four of these subsets during training, and using the remaining subset as the validation set; performing five rounds of validation, and finally averaging the results of the five validation rounds to obtain the final result.
[0040] Furthermore, the model parameters are optimized and trained using weighted cross-entropy loss and Dice loss functions:
[0041]
[0042]
[0043] L total =αL Dice +(1-α)L CE
[0044] Where L Dice L represents the Dice loss function. CE L represents the cross-entropy loss function. total G represents the overall loss function; G represents the true label; P represents the segmentation region predicted by the model; N represents the total number of pixels in the input image, g ij In this context, 'i' represents the label category, 'j' represents the pixel, and 'g' is defined as the pixel whose predicted label matches the true label. ij The value of p is 1, but not both 0; ij The model outputs the probability value of pixel j, where α is a manually set parameter ranging from 0 to 1.
[0045] The beneficial effects of this invention are:
[0046] This invention extracts comprehensive multi-scale features from three parts of the network: the encoder, the decoder, and the connection between the encoder and decoder, effectively learning multi-scale information in images. After extracting the multi-scale features, an interactive module is used to fuse them, effectively alleviating the feature inconsistency problem caused by directly performing multi-scale fusion, thereby improving the performance of medical image segmentation. Attached Figure Description
[0047] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0048] Figure 1 This is a schematic diagram of multi-scale feature extraction in the codec;
[0049] Figure 2 Schematic diagram of the cross feature extraction module;
[0050] Figure 3 This is a schematic diagram of multi-scale feature fusion;
[0051] Figure 4 This is a diagram of an encoder-decoder network model;
[0052] Figure 5 This is a flowchart of the present invention. Detailed Implementation
[0053] 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 of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0054] This invention discloses a medical image segmentation method based on multi-scale feature fusion, such as... Figure 5 As shown, follow these steps:
[0055] Example 1
[0056] Step 1: Collect medical image data of the same type and delineate the ROI (Region of Interest):
[0057] The example used a public dataset of dermoscopy images, which contained 2,594 images in RGB format of different sizes, and the ROI was delineated by a professional physician.
[0058] Step 2: Preprocess the data:
[0059] First, the image is loaded into memory. Then, the mean and standard deviation of the data are calculated. Next, the image is standardized using the obtained mean and standard deviation. Finally, data processing is performed by methods such as image flipping and scaling the image to the same size. The standardization calculation method is as follows:
[0060]
[0061]
[0062]
[0063] Where μ represents the calculated mean, std is the calculated standard deviation, n represents the sample size, and x iLet X represent the i-th sample, X represent the overall sample, and Y represent the overall sample obtained after standardization.
[0064] Step 3: Construct a multi-scale feature extraction module:
[0065] First, a multi-scale feature extraction module is built in the encoder and decoder. For example... Figure 1 As shown, this module includes two channels: a CNN structure based on local information feature extraction and a Transformer structure based on global information feature extraction. The input feature maps serve as parallel inputs to the two different channels. The CNN learns detailed information through convolution, while the Transformer models long-range dependencies through lightweight self-attention computation. The lightweight self-attention computation method is as follows:
[0066] Q,K,V=DewConv(Y0)
[0067] Q1 = Conv S=r (Q)
[0068] K1 = Conv S=r (K)
[0069]
[0070] Where Y0 represents the input feature map, and DewConv represents depthwise separable convolution, which consists of channel convolution and pointwise convolution. The separable convolution yields three mapping matrices: the query matrix Q, the key matrix K, and the value matrix V. Conv S=r This represents a convolution with a stride of r. Matrix Q and K are convolved to obtain matrices Q1 and K1. Light_Atten represents lightweight self-attention, and the Softmax function maps the output values to the interval [0, 1].
[0071] Then, a cross-feature extraction module is built between the encoder and decoder. For example... Figure 2 As shown, the structure of this module differs from the multi-scale feature extraction modules in the encoder and decoder. Its input is the feature map of the dermoscopy image output by the encoder. The encoder contains three layers of multi-scale feature extraction and fusion modules, with the feature maps output from different layers denoted as a1, a2, and a3, respectively. First, matrix multiplication is performed on feature maps a1 and a2. Then, the result is subjected to Softmax normalization, followed by matrix multiplication with feature map a3. Finally, the result of the matrix multiplication is concatenated with a3 using residuals. This process calculates the cross-attention between feature maps of different scales, thereby improving the learning of multi-scale features.
[0072] Step 4: Construct a multi-scale feature fusion module:
[0073] This module can alleviate the feature inconsistency problem caused by features at different scales. For example... Figure 3 As shown, this module has two inputs: one is the local information feature f1 extracted by the CNN, and the other is the global information feature f2 extracted by the Transformer. For these two inconsistent features, the module first concatenates them into a single feature map matrix. Then, it divides this matrix into v distinct parts along the first dimension, and then simultaneously shifts h parts along the y-axis. Afterward, convolution is used to learn spatial location information. Similarly, the processed feature map is divided and shifted along the x-axis, followed by convolution to learn spatial information. Finally, the result is residually concatenated with the input feature map matrix. The calculation formula is shown below:
[0074] Z V =Conv(Roll(Chunk(Z,v),Vertical))
[0075] Z H =Conv(Roll(Chunk(Z) V ,h),Horizontal))
[0076] Where Z is the concatenated feature map matrix, v is the part to be segmented, Chunk represents the segmentation operation, Roll represents the shift operation, and Conv represents the convolution operation. V Z represents the feature map generated after operations in the y-axis direction. H This represents the feature map generated after operations in the x-axis direction.
[0077] Step 5: Construct an encoder-decoder deep learning network model:
[0078] like Figure 4 As shown, the network consists of an encoder and a decoder. The network comprises four layers, each including a multi-scale feature extraction module and a feature fusion module. The input is a preprocessed dermoscopy image, which undergoes local feature summarization via a convolutional module with a stride of 1 and a kernel size of 3, and feature map downsampling with a sampling rate of 2. The resulting input feature map is simultaneously fed into both the CNN local feature extraction channel and the Transformer global feature extraction channel, yielding feature matrices of the same size. These two feature matrices are concatenated and then input into the multi-scale feature fusion module, which performs feature interaction at different scales through partitioning and shifting operations.
[0079] The encoder performs partitioning and shifting operations on different layers to obtain fused features, which are then interacted with through a cross-feature extraction module between the encoder and decoder for feature attention. The obtained features are then connected to the decoder, and similarly undergo multi-scale feature extraction, fusion, and upsampling to obtain a segmented mask image.
[0080] Step 6: Perform five-fold cross-validation on the network:
[0081] To reduce random errors introduced by random partitioning, this network uses five-fold cross-validation for training and evaluation. This method uniformly divides the dataset into five similarly sized subsets. During training, four of these subsets are used, while the remaining subset serves as the validation set. Five iterations of cross-validation are performed, ensuring that each subset can be used as a validation set. Finally, the average of the five validation results is taken to obtain the final result.
[0082] The network uses weighted cross-entropy loss and Dice loss function to optimize the model parameters during training. The calculation formula is as follows:
[0083]
[0084]
[0085] L total =αLoss Dice +(1-α)Loss CE
[0086] Where L Dice L represents the Dice loss function. CE L represents the cross-entropy loss function. total This represents the overall loss function. G represents the true label, P represents the segmentation region predicted by the model, and N represents the total number of pixels in the input image. ij In this context, 'i' represents the label category, 'j' represents the pixel, and 'g' is defined as the pixel whose predicted label matches the true label. ij The value of p is 1, but not both 0. ij The model outputs the probability value of pixel j, where α is a manually set parameter ranging from 0 to 1.
[0087] Step 7: Use Dice coefficient, accuracy, precision, and recall to evaluate the medical image segmentation results.
[0088] To calculate Dice, Accuracy, Precision, and Recall, the four metrics of the model segmentation results should first be calculated: True Positive (TP), True Negative (TN), False Positive (FP), and False Negative (FN). The calculation method is as follows:
[0089]
[0090]
[0091]
[0092]
[0093] Where p i ,q i ∈{0,1}, where 0 represents a negative voxel and 1 represents a positive voxel. p i For the i-th voxel predicted by the model, q i The annotation results drawn by the professional physician in step 1 are as follows. The calculation methods for Dice, Accuracy, Precision, and Recall are as follows:
[0094]
[0095]
[0096]
[0097]
[0098] Table 1 compares the segmentation results of the present invention and existing methods on dermoscopy images, including Dice, Accuracy, Precision, and Recall.
[0099] Table 1 Comparison of medical image segmentation effects between the present invention and existing technologies.
[0100]
[0101] The evaluation results show that the method of the present invention achieved good segmentation results on four different evaluation indicators.
[0102] In medical image segmentation, the learning of multi-scale information has a significant impact on the segmentation results. Existing segmentation methods do not adequately acquire multi-scale information or effectively fuse multi-scale features, thus affecting the image segmentation results. The method of this invention fully learns multi-scale information in the encoder, decoder, and the connection between the encoder and decoder, and performs thorough feature fusion after extracting multi-scale features. This invention has demonstrated superior segmentation performance on different types of medical images.
[0103] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0104] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.
Claims
1. A medical image segmentation method based on multi-scale feature fusion, characterized in that, Includes the following steps: S1. Collect medical image data of the same type and delineate the ROI; S2. Preprocess the medical image data for subsequent training and evaluation of the network model; S3. Construct an encoder-decoder deep learning network model; S4. Perform five-fold cross-validation on the network; S5. Use evaluation metrics to verify the segmentation performance. Input the preprocessed medical image to obtain the segmented mask image and evaluate the medical image segmentation results. The S3 encoder-decoder deep learning network model consists of an encoder and a decoder structure. The network includes four layers, each of which includes a multi-scale feature extraction module and a multi-scale feature fusion module. The preprocessed medical image is input, and a convolutional module with stride is used to summarize local features and downsample the feature map. The resulting feature map is simultaneously fed into the CNN local feature extraction channel and the Transformer global feature extraction channel, resulting in two feature matrices of the same size. These two feature matrices are concatenated and then input into the multi-scale feature fusion module, which performs feature interaction at different scales through partitioning and shifting operations. For features of different scales obtained by the encoder, feature attention is fused through the cross-feature extraction module between the encoder and decoder; then the obtained features are connected to the decoder, and after multi-scale feature extraction, fusion and upsampling, the segmented mask image is obtained. The multi-scale feature extraction module includes a CNN channel based on local information feature extraction and a Transformer channel based on global information feature extraction; the CNN channel includes convolutional layers, normalization layers, and activation functions; the CNN channel calculation method is as follows: in, Indicates the input feature map, Conv This represents the convolution operation. BN For standardized operation, elu For activation functions; This is the result after one convolution, normalization, and activation function. This is the final feature map output after passing through the CNN channels; the self-attention calculation method for the Transformer channels is as follows: in, This represents depthwise separable convolution. Indicates the input feature map, For querying the matrix, The key matrix, For value matrices, Indicates step size is r Convolution, matrix , The matrix is obtained after convolution. and ; This indicates lightweight self-attention. Let be the dimension of the key matrix. For mapping functions; When constructing the cross-feature extraction module, its input is the feature map output by the encoder, where the encoder includes three layers of multi-scale feature extraction and fusion modules; the input feature map is processed by the first layer of multi-scale feature extraction and fusion module, and the output feature map is... The output feature maps of the second and third layers are respectively and Construct a cross-feature extraction module, first processing the feature map... and Perform matrix multiplication; then normalize the results of the matrix multiplication; finally, compare the normalized results with the feature map. Perform matrix multiplication; finally, combine the result of the matrix multiplication with... Perform residual connection; The multi-scale feature fusion module includes two inputs: local information features extracted by CNN. Global information features extracted by Transformer The multi-scale feature fusion module first... and The concatenation is performed to form a feature map matrix, which is then divided along the first dimension into... Different parts, then The parts are shifted along the y-axis, and convolution is used to learn spatial location information to obtain feature maps. Then, a shift operation is performed along the x-axis, and spatial information is learned using convolution; finally, the resulting feature map is... Perform a residual connection with the input feature map matrix: in, This is the concatenated feature map matrix. The part to be divided This indicates a partitioning operation. Indicates a shift operation. This represents the convolution operation. This indicates a shift operation along the y-axis. This indicates a shift operation along the x-axis.
2. The medical image segmentation method based on multi-scale feature fusion according to claim 1, characterized in that, Specifically, S2 is, S21. Read the data obtained in S1 into memory and calculate the mean and standard deviation of the data: S22. Standardize the image based on the obtained mean and standard deviation: in, This represents the calculated average value. To obtain the standard deviation, Indicates the number of samples. Indicates the first One sample, Represents the entire sample. This represents the overall sample obtained after standardization. S23. Data preprocessing is performed by flipping and scaling the image to the same size.
3. The medical image segmentation method based on multi-scale feature fusion according to claim 1, characterized in that, Specifically, S4 involves dividing the dataset evenly into five subsets of similar size, using four of these subsets during training, and using the remaining subset as the validation set; performing five rounds of validation; and finally averaging the results of the five validation rounds to obtain the final result.
4. The medical image segmentation method based on multi-scale feature fusion according to claim 3, characterized in that, The model parameters were optimized and trained using weighted cross-entropy loss and Dice loss functions. in Represents the Dice loss function. Represents the cross-entropy loss function. The loss function representing the overall loss; Labels that indicate authenticity This represents the segmentation region predicted by the model. This represents the total number of pixels in the input image. In Indicates the category of the label. This represents a pixel, where the predicted label of the pixel is equal to the true class label. The value is 1, and it is not 0 at the same time; Output pixels for the model The probability value, These are parameters set manually, ranging from 0 to 1.
Citation Information
Patent Citations
Melanoma segmentation method based on cavity convolution and multi-scale fusion
CN112446890A
Multi-scale feature generative adversarial network for suppressing artifact noise in low-dose CT image
CN112598759A
