A medical image segmentation method based on attention mechanism and edge detection
By combining the attention mechanism and edge detection network, the problem of boundary segmentation error in medical image segmentation is solved, the global semantics and edge details are taken into account, and the segmentation accuracy and efficiency are improved.
Patent Information
- Application Number
- CN202310431557.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-21
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2043-04-21
AI Technical Summary
Existing medical image segmentation methods based on deep learning have errors in image boundary segmentation and find it difficult to take into account both global semantic features and edge details, resulting in insufficient segmentation precision and accuracy.
The attention mechanism and edge detection network are used to extract the global semantic features and local edge features of the image respectively, and feature fusion is performed. By combining the preprocessing network, backbone network and edge detection network, accurate segmentation of the image boundary is achieved.
It improves the accuracy of medical image segmentation, improves segmentation efficiency, retains edge detail information, prevents false detection, and enhances the prediction accuracy of the model.
Smart Images

Figure CN116363120B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer vision and image processing, and more specifically, to a medical image segmentation method based on attention mechanism and edge detection. Background Art
[0002] Image segmentation is a pixel-level classification task. Its essence is to assign a semantic label to each pixel in an image, dividing the image into several non-overlapping regions so that these features exhibit consistency or similarity within the same region, but distinct differences between different regions. Medical image segmentation is one of the most important applications of image segmentation. Compared to natural images, medical images have relatively simple semantics and fixed structures. Segmentation generally does not involve multi-classification information of pixels, but it is crucial for specific and accurate segmentation of organs or diseased tissues. Medical image segmentation has greatly enhanced the knowledge of normal and diseased anatomy in medical research and is a key step in medical image quantitative analysis and three-dimensional reconstruction. It is a crucial technical prerequisite for clinical diagnosis, image-guided surgery, and radiotherapy. By changing the visualization process of medical images, it assists doctors in the rapid localization, qualitative and quantitative diagnosis and analysis of key areas (tissues, organs, or lesions). These medical images play a vital role in clinical diagnosis and are a key component of diagnosis and treatment planning.
[0003] With the rapid development of deep learning in recent years, convolutional neural networks (CNNs) have achieved tremendous results in the field of image vision. Medical image segmentation methods based on deep learning are also continuously achieving breakthroughs in both speed and accuracy. Currently, most medical image segmentation methods based on deep learning use convolutional neural networks to classify each pixel in the image. While this approach can accurately classify most pixels, it relies on deeper network models and a larger number of parameters. These complex network models are not only unable to simultaneously extract global contextual features and boundary spatial information, but also have difficulty locating ambiguous lesions, making it difficult to accurately segment boundary details, resulting in image boundary segmentation errors, thus affecting the precision and accuracy of medical image segmentation. Summary of the Invention
[0004] The purpose of the present invention is to overcome the shortcomings and deficiencies in the prior art and provide a medical image segmentation method based on attention mechanism and edge detection. This medical image segmentation method solves the problem of image boundary segmentation errors in the prior art. The global semantic features and local edge features of the image are obtained respectively through the attention network and the edge detection network, and the features of the two different levels are integrated to achieve accurate segmentation of the image boundary, thereby improving the accuracy of medical image segmentation.
[0005] In order to achieve the above object, the present invention is implemented by the following technical solution: a medical image segmentation method based on attention mechanism and edge detection, characterized in that it includes the following steps:
[0006] S1. Set the images to be segmented and the true labeled segmented images of the training set, validation set, and test set respectively; blur the centroids of the segmented objects in the true labeled segmented images of the training set and validation set to obtain the true labeled segmented dataset;
[0007] Establish a preprocessing network and input the real annotated segmentation dataset into the preprocessing network to obtain the parameters of the preprocessing network; use the parameters of the preprocessing network to predict the image to be segmented in the test set and construct a complete preprocessing image;
[0008] S2, splicing the pre-processed image obtained in step S1 with the images to be segmented in the training set and the validation set, and outputting a feature fusion image;
[0009] S3. Establish a backbone network including an attention mechanism, input the feature fusion image into the backbone network including the attention mechanism, and obtain the output of the backbone network including the attention mechanism;
[0010] S4. Establish an edge detection network, input the images to be segmented in the training set and the validation set into the edge detection network to obtain image edge information, and obtain the output of the edge detection network;
[0011] S5. Feature fusion is performed on the output of the backbone network containing the attention mechanism in step S3 and the output of the edge detection network in step S4, and the features are normalized to output the segmented image of the medical image.
[0012] Step S1 includes the following steps:
[0013] S1-1. Set the images to be segmented and the real labeled segmented images for the training set, validation set, and test set respectively;
[0014] S1-2. Calculation formula for the centroid of segmented objects in the real annotated segmented images of the training set and the validation set
[0015] for:
[0016] Among them, M ij is a matrix with i rows and j columns, representing the weight of the pixel, I(x,y) is the size of the pixel at the (x,y) position in the image, M 00 is the quality of all pixels and M 10 and M 01 The sum of the mass of the horizontal pixels and the sum of the mass of the vertical pixels are respectively divided by the two to obtain the horizontal centroid line and the vertical centroid line, (c x ,c y) is the coordinate of the centroid where the two lines intersect, which can be understood as the center coordinate of the position to be segmented in the real annotated image.
[0017] Use Gaussian filtering to blur the centroid to obtain the real labeled segmentation dataset;
[0018] S1-3, establishing a preprocessing network; the preprocessing network consists of an encoder module, a decoder module and a skip connection module;
[0019] S1-4, input the real annotated segmentation dataset into four encoder modules for feature extraction, four skip connection modules and four decoder modules for image restoration, and obtain the parameters of the preprocessing network;
[0020] S1-5. Use the parameters of the preprocessing network to predict the images to be segmented in the test set and construct complete preprocessed image data.
[0021] In S1-3, the encoder module consists of six convolution blocks through residuals; the skip connection module consists of two convolution blocks and a bilinear interpolation upsampling module; the decoder module consists of two convolution blocks and skip connections, which are summed and then passed through two convolution blocks and a bilinear interpolation upsampling module.
[0022] In S1-2, the following formula is used to use Gaussian filtering to blur the centroid to obtain a light spot, and G r×r express:
[0023]
[0024] where g ij G is the i-th row and j-th column r×r The value of x i =[0,1,...,r-1],y j =[[0],[1],...,[r-1]], σ is the standard deviation;
[0025] G r×r The centroid coordinates are inserted into an image with all pixels set to 0, which is the same size as the true labeled segmentation image, to obtain the true labeled segmentation dataset.
[0026] Step S2 includes the following steps:
[0027] S2-1, the image to be segmented passes through two convolution blocks and is then concatenated with the preprocessed image that has passed through one convolution block in the channel dimension;
[0028] S2-2: Pass the splicing result of S2-1 through a convolution block and then splice it with the image to be segmented in the channel dimension. Then, pass it through a convolution block to obtain the feature fusion module.
[0029] Step S3 includes the following steps:
[0030] S3-1. Build a backbone network with an attention mechanism. The backbone network consists of four convolutional pooling layers, four residual blocks Res-1, Res-2, Res-3, and Res-4, which represent semantic information at four different levels, and an attention mechanism module. A convolutional block is added to the output of Res-1 to extract features, resulting in Res-1`. A feature pyramid module is added to the output of Res-4 to expand the receptive field, resulting in Res-4`.
[0031] S3-2, the attention mechanism module includes a channel attention mechanism module CAB and a feature fusion module FFB; Res-1` and Res-4` are merged in the channel dimension to obtain the output feature map A, which serves as the input of the channel attention mechanism module CAB and the feature fusion module FFB;
[0032] S3-3, the channel attention mechanism module CAB deforms the input feature map A to obtain the feature map B∈R C×HW , where C is the number of channels of feature map A, H and W are the height and width of feature map A; then the feature map A is deformed and transposed to obtain R C ×WH , the result is matrix multiplied with the feature map B and the channel feature map X∈R is obtained through the softmax layer C×C , the expression of X is:
[0033]
[0034] where x ji represents the impact of the i-th channel on the j-th channel;
[0035] S3-4, after the result of matrix multiplication of feature map B and feature map X is deformed, it is matrix multiplied with feature map B again to restore it to feature map E∈R C×H×W , the expression of E is:
[0036]
[0037] S3-5, the feature fusion module FFB passes the input feature map A through two convolutional layers that double the number of channels, then through two convolutional layers that halve the number of channels, and then performs matrix multiplication with the feature map E obtained in step S3-4. Finally, it passes through a convolution block and performs matrix multiplication with the feature map A to obtain the output of the attention mechanism module;
[0038] S3-6. The output of the attention mechanism module in S3-5 is passed through a convolution block to perform feature dimensionality reduction, and then bilinear interpolation upsampling is performed to restore the image size to obtain the output of the backbone network including the attention mechanism.
[0039] Step S4 includes the following steps:
[0040] S4-1. Establish an edge detection network. The edge detection network consists of three feature extraction convolution blocks, three upsampling convolution blocks, and a feature fusion module. The first two feature extraction convolution blocks consist of two convolution layers with a kernel size of 3, a batch normalization layer, and a Relu layer. The third feature extraction block consists of six convolution layers with a kernel size of 3, a batch normalization layer, and a Relu layer. Adjacent upsampling convolution layers are connected by residuals to prevent gradient vanishing. Each upsampling convolution block consists of a standard convolution and a transposed convolution. The feature fusion module uses a GroupNormalization layer for normalization.
[0041] S4-2. Input the images to be segmented of the training set and the validation set into the feature extraction convolution block. The output of each feature extraction convolution block is used as the input of the upsampling convolution block. Finally, the outputs of the three upsampling convolution blocks are spliced in the channel dimension and passed through the feature fusion module to obtain the output of the edge detection network.
[0042] The step S6 is also included:
[0043] Calculate the cross entropy loss and dice coefficient loss between the segmented image of the medical image output in step S5 and the given standard segmented image, and use the stochastic gradient descent method to update the parameters of the backbone network and edge detection network containing the attention mechanism to achieve accurate segmentation of the input image; the loss function L total The calculation of is as follows:
[0044]
[0045] L BCE =-g(k,i)log[p(k,i)]-(1-g(k,i))log[1-p(k,i)];
[0046] L total =αL Dice +(1-α)L BCE ;
[0047] Among them L Dice Denotes the dice coefficient loss, L BCE Represents the cross entropy loss, p(k,i)∈[0,1] and g(k,i)∈[0,1] are the predicted image and the real image respectively, and α is a parameter to be adjusted so that the network can obtain the best segmentation effect.
[0048] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0049] 1. Existing image segmentation preprocessing often involves horizontal or vertical flipping, followed by random cropping of the original and flipped images. These traditional methods still rely on information from the image to be segmented. This invention uses a convolutional neural network to extract key information from the image to be segmented, helping the subsequent medical image segmentation network quickly determine the spatial location of the region to be segmented during the feature extraction phase. This expands existing data information, improves segmentation efficiency, and avoids wasting performance on noise in the segmentation model.
[0050] 2. Existing technologies often neglect the extraction of image edge details or connect edge detection modules in series with other feature extraction modules, losing the original edge information. This invention directly performs edge detection on the segmented image, preserving edge details to the greatest extent possible and improving the accuracy of the model's prediction results.
[0051] 3. Existing technologies often use either attention mechanisms or edge extraction alone, failing to take into account both global semantic information and edge detail information. This invention combines attention mechanisms and edge extraction, improving both spatial segmentation and edge accuracy.
[0052] 4. The present invention proposes a new preprocessing network to learn the spatial position of the segmented target; the present invention connects the edge detection network in parallel with the backbone network containing the attention mechanism to prevent false detection from affecting the feature extraction of the backbone network containing the attention mechanism; and uses the attention mechanism module to fuse high-level and low-level features to grasp the global semantic information. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 It is a principle flow chart of the medical image segmentation method of the present invention;
[0054] Figure 2 : This is a network structure diagram of the medical image segmentation method of the present invention; LEDB is an edge detection network, and GGB is a backbone network including an attention mechanism;
[0055] Figure 3 : is a preprocessing network structure diagram of the medical image segmentation method of the present invention, wherein REB is the encoder module, JCB is the skip connection module, and UDB is the decoder module;
[0056] Figure 4(a) is a schematic diagram of the encoder module in the pre-trained network;
[0057] Figure 4(b) is a schematic diagram of the decoder module in the pre-trained network;
[0058] Figure 4(c) is a schematic diagram of the skip connection module in the pre-trained network;
[0059] Figure 5It is a network structure diagram for splicing the pre-processed image with the images to be segmented in the training set and the validation set in the medical image segmentation method of the present invention to output a feature fusion image;
[0060] Figure 6 is a network structure diagram of the attention mechanism module of the medical image segmentation method of the present invention;
[0061] Figure 7 is a structural diagram of an edge detection network of a medical image segmentation method according to the present invention;
[0062] Figure 8 This is the visual comparison result of the medical image segmentation method of the present invention and other algorithms; DETAILED DESCRIPTION
[0063] The present invention will be described in further detail below with reference to the accompanying drawings and specific embodiments.
[0064] Example
[0065] like Figures 1 to 8 As shown, the medical image segmentation method based on attention mechanism and edge detection of the present invention includes the following steps:
[0066] S1. Set the images to be segmented and the true labeled segmented images of the training set, validation set, and test set respectively; blur the centroids of the segmented objects in the true labeled segmented images of the training set and validation set to obtain the true labeled segmented dataset;
[0067] A preprocessing network is established, and the real labeled segmentation dataset is input into the preprocessing network to obtain the parameters of the preprocessing network; the parameters of the preprocessing network are used to predict the images to be segmented in the test set to construct a complete preprocessed image.
[0068] Specifically:
[0069] S1-1. This embodiment is based on the BUSI dataset and selects 647 images as the original training data. They are divided into 520 images as the training set, 64 images as the validation set, and 63 images as the test set according to the ratio of 8:1:1. Each image includes the image to be segmented and the real annotated segmented image.
[0070] S1-2. Calculation formula for the centroid of segmented objects in the real annotated segmented images of the training set and the validation set
[0071] for:
[0072] Among them, M ij is a matrix with i rows and j columns, representing the weight of the pixel, I(x,y) is the size of the pixel at the (x,y) position in the image, M 00 is the quality of all pixels and M10 and M 01 The sum of the mass of the horizontal pixels and the sum of the mass of the vertical pixels are respectively divided by the two to obtain the horizontal centroid line and the vertical centroid line, (c x ,c y ) is the coordinate of the centroid where the two lines intersect, which can be understood as the center coordinate of the position to be segmented in the real annotated image;
[0073] Use the following formula to use Gaussian filtering to blur the centroid to get a spot, using G r×r express:
[0074]
[0075] Among them, r is the blur radius, g ij is row i, column j, column G r×r The value of x i =[0,1,...,r-1],y j =[[0],[1],...,[r-1]], σ is the standard deviation;
[0076] G r×r The centroid coordinates are inserted into an image with all pixels set to 0, which is the same size as the true labeled segmentation image, to obtain the true labeled segmentation dataset.
[0077] S1-3. Establish a preprocessing network; the preprocessing network consists of an encoder module, a decoder module and a jump connection module; the encoder module consists of six convolution blocks through residuals; the jump connection module consists of two convolution blocks and a bilinear interpolation upsampling module; the decoder module consists of two convolution blocks and a jump connection summation, and then two convolution blocks and a bilinear interpolation upsampling module.
[0078] S1-4: The ground truth segmentation dataset is sequentially fed into four encoder modules for feature extraction, four skip connection modules, and four decoder modules for image restoration, obtaining the parameters of the preprocessing network. Specifically, the ground truth segmentation dataset is sequentially fed into the four encoder modules for feature extraction. The first skip connection module is fed into the output of the third encoder module, and the remaining three skip connection modules are fed into the output of the previous skip connection module. Finally, the image is restored through the four decoder modules.
[0079] S1-5. Use the parameters of the preprocessing network to predict the images to be segmented in the test set and construct complete preprocessed image data.
[0080] S2. Concatenate the preprocessed image obtained in step S1 with the images to be segmented in the training set and the validation set, and output a feature fusion image.
[0081] The specific steps include:
[0082] S2-1. After the image to be segmented passes through two convolution blocks, it is spliced with the preprocessed image that passes through one convolution block in the channel dimension.
[0083] S2-2: Pass the splicing result of S2-1 through a convolution block and then splice it with the image to be segmented in the channel dimension. Then, pass it through a convolution block to obtain the feature fusion module.
[0084] S3. Establish a backbone network including an attention mechanism, input the feature fusion image into the backbone network including the attention mechanism, and obtain the output of the backbone network including the attention mechanism.
[0085] The specific steps include:
[0086] S3-1. Build a backbone network with an attention mechanism. The backbone network consists of four convolutional pooling layers, four residual blocks Res-1, Res-2, Res-3, and Res-4, which represent semantic information at four different levels, and an attention mechanism module. A convolutional block is added to the output of Res-1 to extract features, resulting in Res-1`. A feature pyramid module is added to the output of Res-4 to expand the receptive field, resulting in Res-4`.
[0087] S3-2, the attention mechanism module includes a channel attention mechanism module CAB and a feature fusion module FFB; Res-1` and Res-4` are merged in the channel dimension to form a feature map A, which serves as the input of the channel attention mechanism module CAB and the feature fusion module FFB;
[0088] S3-3, the channel attention mechanism module CAB deforms the input feature map A to obtain the feature map B∈R C×HW , where C is the number of channels of feature map A, H and W are the height and width of feature map A; then the feature map A is deformed and transposed to obtain R C ×WH , the result is matrix multiplied with the feature map B and the channel feature map X∈R is obtained through the softmax layer C×C , the expression of X is:
[0089]
[0090] where x ji represents the impact of the i-th channel on the j-th channel;
[0091] S3-4, after the result of matrix multiplication of feature map B and feature map X is deformed, it is matrix multiplied with feature map B again to restore it to feature map E∈R C×H×W , the expression of E is:
[0092]
[0093] S3-5, the feature fusion module FFB passes the input feature map A through two convolutional layers that double the number of channels, then through two convolutional layers that halve the number of channels, and then performs matrix multiplication with the feature map E obtained in step S3-4. Finally, it passes through a convolution block and performs matrix multiplication with the feature map A to obtain the output of the attention mechanism module;
[0094] S3-6. The output of the attention mechanism module in S3-5 is passed through a convolution block to perform feature dimensionality reduction, and then bilinear interpolation upsampling is performed to restore the image size to obtain the output of the backbone network including the attention mechanism.
[0095] S4. Establish an edge detection network, input the images to be segmented in the training set and the validation set into the edge detection network to obtain image edge information, and obtain the output of the edge detection network.
[0096] The specific steps include:
[0097] S4-1. Establish an edge detection network. The edge detection network consists of three feature extraction convolution blocks, three upsampling convolution blocks, and a feature fusion module. The first two feature extraction convolution blocks consist of two convolution layers with a kernel size of 3, a batch normalization layer, and a Relu layer. The third feature extraction block consists of six convolution layers with a kernel size of 3, a batch normalization layer, and a Relu layer. Adjacent upsampling convolution layers are connected by residuals to prevent gradient vanishing. Each upsampling convolution block consists of a standard convolution and a transposed convolution. The feature fusion module uses a GroupNormalization layer for normalization.
[0098] S4-2. Input the images to be segmented of the training set and the validation set into the feature extraction convolution block. The output of each feature extraction convolution block is used as the input of the upsampling convolution block. Finally, the outputs of the three upsampling convolution blocks are spliced in the channel dimension and passed through the feature fusion module to obtain the output of the edge detection network.
[0099] S5. Feature fusion is performed on the output of the backbone network containing the attention mechanism in step S3 and the output of the edge detection network in step S4, and the features are normalized to output the segmented image of the medical image.
[0100] S6. Calculate the cross entropy loss and dice coefficient loss between the segmented image of the medical image output in step S5 and the given standard segmented image, and use the stochastic gradient descent method to update the parameters of the backbone network and edge detection network containing the attention mechanism to achieve accurate segmentation of the input image; the loss function L total The calculation of is as follows:
[0101]
[0102] L BCE =-g(k,i)log[p(k,i)]-(1-g(k,i))log[1-p(k,i)];
[0103] L total =αL Dice +(1-α)L BCE ;
[0104] Among them L Dice Denotes the dice coefficient loss, L BCE represents the cross entropy loss, p(k,i)∈[0,1] and g(k,i)∈[0,1] are the predicted image and the real image respectively, and α is a parameter to be adjusted to enable the network to obtain the best segmentation effect. In this embodiment, α is set to 0.3.
[0105] In this embodiment, the comparison results of the model adopted by the method of the present invention and other semantic segmentation models on the BUSI dataset are shown in Table 1. It can be seen from Table 1 that the overall performance of the present invention exceeds that of other disclosed model algorithms, especially in the dice coefficient indicator. The model proposed in this chapter has a significant improvement compared with other models.
[0106] Table 1 Comparison results of the proposed model with other semantic segmentation models on the BUSI dataset
[0107]
[0108] This example also provides a comparison of the segmentation results of the model of the present invention and other image segmentation models on the BUSI dataset. Figure 8 As shown in the figure, the first column is the image to be segmented; the second column is the real labeled segmented image; the third column is the segmentation result diagram of the model of the present invention; it can be seen that the image segmentation effect of the model of the present invention is better than the segmentation effect of other models, indicating that the network model with the edge detection network and the attention module can better distinguish the boundary features of different categories while ensuring the extraction of global information, thereby achieving better segmentation effect.
[0109] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be considered as equivalent replacement methods and are included in the scope of protection of the present invention.
Claims
1. A medical image segmentation method based on attention mechanism and edge detection, characterized by: The following steps are involved: S1. Set the images to be segmented and the real labeled segmented images for the training set, validation set, and test set respectively; Blurring the centroids of the segmented objects in the true labeled segmentation images of the training set and the validation set to obtain the true labeled segmentation dataset; Establish a preprocessing network and input the real labeled segmentation dataset into the preprocessing network to obtain the parameters of the preprocessing network; Use the parameters of the preprocessing network to predict the image to be segmented in the test set and construct a complete preprocessing image; S2, splicing the pre-processed image obtained in step S1 with the images to be segmented in the training set and the validation set, and outputting a feature fusion image; S3. Establish a backbone network including an attention mechanism, input the feature fusion image into the backbone network including the attention mechanism, and obtain the output of the backbone network including the attention mechanism; Step S3 includes the following steps: S3-1. Build a backbone network with an attention mechanism. The backbone network consists of four convolutional pooling layers, four residual blocks Res-1, Res-2, Res-3, and Res-4, which represent semantic information at four different levels, and an attention mechanism module. A convolutional block is added to the output of Res-1 to extract features, resulting in Res-1`. A feature pyramid module is added to the output of Res-4 to expand the receptive field, resulting in Res-4`. S3-2, the attention mechanism module includes a channel attention mechanism module CAB and a feature fusion module FFB; the output feature maps A of Res-1` and Res-4` are used as the inputs of the channel attention mechanism module CAB and the feature fusion module FFB respectively; S3-3, the channel attention mechanism module CAB deforms the input feature map A to obtain the feature map B∈R C×HW , where C is the number of channels of feature map A, H and W are the height and width of feature map A; then the feature map A is deformed and transposed to obtain R C×WH , the result is matrix multiplied with the feature map B and the channel feature map X∈R is obtained through the softmax layer C×C , the expression of X is: where x ji represents the impact of the i-th channel on the j-th channel; S3-4, after the result of matrix multiplication of feature map B and feature map X is deformed, it is matrix multiplied with feature map B again to restore it to feature map E∈R C×H×W , the expression of E is: S3-5, the feature fusion module FFB passes the input feature map A through two convolutional layers that double the number of channels, then through two convolutional layers that halve the number of channels, and then performs matrix multiplication with the feature map E obtained in step S3-4. Finally, it passes through a convolution block and performs matrix multiplication with the feature map A to obtain the output of the attention mechanism module; S3-6, pass the output of the attention mechanism module in S3-5 through a convolution block to reduce the feature dimension, and then perform bilinear interpolation upsampling to restore the image size to obtain the output of the backbone network including the attention mechanism; S4. Establish an edge detection network, input the images to be segmented in the training set and the validation set into the edge detection network to obtain image edge information, and obtain the output of the edge detection network; S5. Feature fusion is performed on the output of the backbone network containing the attention mechanism in step S3 and the output of the edge detection network in step S4, and the features are normalized to output the segmented image of the medical image.
2. The medical image segmentation method based on attention mechanism and edge detection according to claim 1, characterized in that: Step S1 includes the following steps: S1-1. Set the images to be segmented and the real labeled segmented images for the training set, validation set, and test set respectively; S1-2. The calculation formula for the centroid of the segmented objects in the real labeled segmented images of the training set and the validation set is: Among them, M ij is a matrix with i rows and j columns, representing the weight of the pixel, I(x,y) is the size of the pixel at the (x,y) position in the image, M 00 is the quality of all pixels and M 10 and M 01 The sum of the mass of the horizontal pixels and the sum of the mass of the vertical pixels are respectively divided by the two to obtain the horizontal centroid line and the vertical centroid line, (c x ,c y ) is the centroid position coordinate of the intersection of the two lines, which can be understood as the center coordinate of the position to be segmented in the real annotated image; Gaussian filtering is used to blur the centroid to obtain the real annotated segmentation dataset; S1-3, establishing a preprocessing network; the preprocessing network consists of an encoder module, a decoder module and a skip connection module; S1-4, input the real annotated segmentation dataset into four encoder modules for feature extraction, four skip connection modules and four decoder modules for image restoration, and obtain the parameters of the preprocessing network; S1-5. Use the parameters of the preprocessing network to predict the images to be segmented in the test set and construct complete preprocessed image data.
3. The medical image segmentation method based on attention mechanism and edge detection according to claim 2, characterized in that: In S1-3, the encoder module consists of six convolution blocks through residuals; the skip connection module consists of two convolution blocks and a bilinear interpolation upsampling module; the decoder module consists of two convolution blocks and skip connections, which are summed and then passed through two convolution blocks and a bilinear interpolation upsampling module.
4. The medical image segmentation method based on attention mechanism and edge detection according to claim 2, characterized in that: In S1-2, the following formula is used to use Gaussian filtering to blur the centroid to obtain a light spot, using G r×r express; Among them, r is the blur radius, and g ij G is the i-th row and j-th column r×r The value of x i =[0,1,...,r-1],y j =[[0],[1],...,[r-1]], σ is the standard deviation; G r×r The centroid coordinates are inserted into an image with all pixels set to 0, which is the same size as the true labeled segmentation image, to obtain the true labeled segmentation dataset.
5. The medical image segmentation method based on attention mechanism and edge detection according to claim 1, characterized in that: Step S2 includes the following steps: S2-1, the image to be segmented passes through two convolution blocks and is then concatenated with the preprocessed image that has passed through one convolution block in the channel dimension; S2-2: Pass the splicing result of S2-1 through a convolution block and then splice it with the image to be segmented in the channel dimension. Then, pass it through a convolution block to obtain the feature fusion module.
6. The medical image segmentation method based on attention mechanism and edge detection according to claim 1, characterized in that: Step S4 includes the following steps: S4-1. Establish an edge detection network. The edge detection network consists of three feature extraction convolution blocks, three upsampling convolution blocks, and a feature fusion module. The first two feature extraction convolution blocks consist of two convolution layers with a kernel size of 3, a BatchNormalization layer, and a Relu layer. The third feature extraction block consists of six convolution layers with a kernel size of 3, a BatchNormalization layer, and a Relu layer. Adjacent upsampling convolution layers are connected by residuals to prevent gradient vanishing. Each upsampling convolution block consists of standard convolution and transposed convolution. The feature fusion module uses a GroupNormalization layer for normalization. S4-2. Input the images to be segmented of the training set and the validation set into the feature extraction convolution block. The output of each feature extraction convolution block is used as the input of the upsampling convolution block. Finally, the outputs of the three upsampling convolution blocks are spliced in the channel dimension and passed through the feature fusion module to obtain the output of the edge detection network.
7. The medical image segmentation method based on attention mechanism and edge detection according to claim 1, characterized in that: The step S6 is also included: Calculate the cross entropy loss and dice coefficient loss between the segmented image of the medical image output in step S5 and the given standard segmented image, and use the stochastic gradient descent method to update the parameters of the backbone network and edge detection network containing the attention mechanism to achieve accurate segmentation of the input image; the loss function L total The calculation of is as follows: L BCE =-g(k,i)log[p(k,i)]-(1-g(k,i))log[1-p(k,i)]; L total =αL Dice +(1-α)L BCE ; Among them L Dice Denotes the dice coefficient loss, L BCE Represents the cross entropy loss, p(k,i)∈[0,1] and g(k,i)∈[0,1] are the predicted image and the real image respectively, and α is a parameter to be adjusted so that the network can obtain the best segmentation effect.
Citation Information
Patent Citations
Medical image segmentation method and system based on AS-UNet
CN113012172A
Image foreground segmentation method combining subject determination and edge precision
CN113592893A