Image segmentation method, device, medium and equipment based on deep neural network
The image segmentation method of deep neural network uses block area average pooling and feature splicing technology to solve the blur problem caused by noise and tissue complexity in medical image segmentation, and improves the accuracy and precision of image segmentation.
Patent Information
- Application Number
- CN202411188142.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-08-28
AI Technical Summary
The medical image segmentation task is affected by factors such as noise, field offset, local volume effects, and tissue motion, resulting in blur and inhomogeneity, which in turn reduces the accuracy of image segmentation.
The image segmentation method based on deep neural network is used to calculate the background class in the image through block area average pooling, downsampling preprocessing, global context feature splicing and upsampling preprocessing, combined with convolution kernel and normalized exponential function layer. and probability map of the target class to generate image segmentation results.
Through multi-scale global splicing and fusion of global context features, the limitations of convolution operations in extracting local features are overcome, and the accuracy and precision of medical image segmentation are improved.
Smart Images

Figure CN118691631B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to an image segmentation method, device, medium and equipment based on a deep neural network. Background Art
[0002] Image segmentation is a key technology in image analysis and plays an increasingly important role in medical imaging. Image segmentation is an indispensable means to extract quantitative information of special tissues in images, and it is also a preprocessing step and prerequisite for visualization. Segmented images are being widely used in various occasions, such as quantitative analysis of tissue volume, diagnosis, localization of lesions, learning of anatomical structures, treatment planning, local volume effect correction of functional imaging data, and computer surgery guidance.
[0003] Due to the differences in the imaging principles of medical images and the characteristics of the tissue itself, the formation of images is affected by noise, field offset effects, local volume effects, and tissue movement. Therefore, compared with ordinary images, medical images inevitably have the characteristics of blur and unevenness. In addition, the structure and shape of human tissues are complex and vary greatly from person to person, which brings difficulties to medical image segmentation. Summary of the invention
[0004] The purpose of the present invention is to provide an image segmentation method, device, medium and equipment based on a deep neural network, aiming to improve the accuracy of image segmentation.
[0005] In order to achieve the above-mentioned purpose, a first aspect of the embodiments of the present disclosure provides an image segmentation method based on a deep neural network, the method comprising:
[0006] The obtained input tensor corresponding to the medical image to be segmented is subjected to block area average pooling with adjacent pixels of different block area sizes as a whole, and an input tensor to be processed corresponding to each block area size is obtained respectively;
[0007] The input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each of the block area sizes are respectively subjected to downsampling preprocessing to obtain a global context feature tensor with doubled number of channels corresponding to the medical image to be segmented and a global context feature tensor with doubled number of channels corresponding to the input tensor to be processed corresponding to each of the block area sizes;
[0008] Performing feature splicing in each dimension on the global context feature tensor of the medical image to be segmented and the global context feature tensor corresponding to the input tensor to be processed corresponding to each block area size, so as to generate a spliced tensor with doubled channels;
[0009] Performing upsampling preprocessing on the spliced tensor to obtain an image tensor with the same resolution as the medical image to be segmented and the same number of channels as the input tensor;
[0010] A convolution layer with a convolution kernel of 1x1x1 and a normalized exponential function layer are used to calculate the probability map of the background class and the target class to be segmented in the image tensor to obtain an image segmentation result.
[0011] In a possible implementation, the downsampling preprocessing is performed on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each of the block area sizes to obtain a global context feature tensor with doubled number of channels corresponding to the medical image to be segmented and a global context feature tensor with doubled number of channels corresponding to the input tensor to be processed corresponding to each of the block area sizes, including:
[0012] Performing linear mapping and information compression on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area size, respectively, to obtain a first tensor with a shape of (1, D, H, W) in the embedding space;
[0013] Reshape each of the first tensors to obtain a second tensor corresponding to each of the first tensors, the second tensor having a shape of (DHW, 1, 1, 1);
[0014] Normalizing each of the second tensors by a normalized exponential function layer to obtain a weight tensor for each spatial position in each of the second tensors;
[0015] Performing matrix multiplication of the weight tensor corresponding to the medical image to be segmented and the input tensor of the medical image to be segmented to obtain a global context feature tensor with doubled number of channels corresponding to the medical image to be segmented;
[0016] The input tensor to be processed corresponding to each block area size is matrix multiplied with the corresponding weight tensor to obtain a global context feature tensor with double the number of channels corresponding to the input tensor to be processed corresponding to each block area size.
[0017] In a possible implementation, linear mapping and information compression are performed on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area size to obtain a first tensor with a shape of (1, D, H, W) in the embedding space, including:
[0018] Performing image feature extraction on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area size respectively through a first feature extraction module to obtain a first feature tensor with doubled channel number;
[0019] Performing image feature extraction on the first feature tensor with doubled channel number through a second feature extraction module to obtain a second feature tensor;
[0020] Features of different scales in each of the second feature tensors are aggregated through a context aggregation module to obtain a first tensor with a shape of (1, D, H, W) in the embedding space.
[0021] In a possible implementation, the first feature extraction module is composed of two basic convolution modules and a connection layer module connected in series in sequence, wherein the convolution layer step size in the first basic convolution module is 2, and the convolution layer step size in the first basic convolution module is 2 so that the number of output channels is twice the number of input channels;
[0022] The second feature extraction module is composed of two basic convolution modules and one connection layer module connected in series in sequence, wherein the convolution layer step size in the first basic convolution module is 1.
[0023] In a possible implementation, Leaky ReLU is used as an activation function in the basic convolution module, and the slope is set to 0.01, and a normalization layer is constructed between each convolution layer and the Leaky ReLU, wherein the normalization layer is used to calculate the mean and variance of the output of the previous convolution layer, and convert the data into a stable distribution with a mean of zero and a variance of 1, so as to prevent gradient explosion or diffusion and reduce dependence on network initialization parameters, and allow a larger learning rate to be used in training to accelerate the convergence speed of the network;
[0024] The standardization layer is used to standardize each channel and remove the correlation between channels.
[0025] In a possible implementation, performing upsampling preprocessing on the spliced tensor to obtain an image tensor having the same resolution as the medical image to be segmented and the same number of channels as the input tensor includes:
[0026] Using a convolution layer with a convolution kernel size of 1x1x1 and a stride of 1, convolution processing is performed on the spliced tensor so that the number of channels of the spliced tensor is halved, and a convolution tensor with the same number of channels as the input tensor is obtained;
[0027] The convolution tensor is upsampled by using an interpolation method so that the resolution of the convolution tensor is enlarged to 2 times, thereby obtaining the image tensor having the same resolution as the medical image to be segmented.
[0028] In a possible implementation, the interpolation method is a nearest neighbor interpolation method.
[0029] According to a second aspect of the present disclosure, there is provided an image segmentation device based on a deep neural network, comprising:
[0030] The block area average pooling module is configured to perform block area average pooling on the acquired input tensor corresponding to the medical image to be segmented, taking adjacent pixels of different block area sizes as a whole, and obtain the input tensor to be processed corresponding to each block area size;
[0031] A downsampling preprocessing module is configured to perform downsampling preprocessing on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each of the block area sizes, respectively, to obtain a global context feature tensor with doubled number of channels corresponding to the medical image to be segmented and a global context feature tensor with doubled number of channels corresponding to the input tensor to be processed corresponding to each of the block area sizes;
[0032] A splicing module is configured to perform feature splicing on each dimension of the global context feature tensor of the medical image to be segmented and the global context feature tensor corresponding to the input tensor to be processed corresponding to each block area size, so as to generate a spliced tensor with doubled channels;
[0033] An upsampling preprocessing module is configured to perform upsampling preprocessing on the spliced tensor to obtain an image tensor with the same resolution as the medical image to be segmented and the same number of channels as the input tensor;
[0034] The computing module is configured to use a convolution layer with a convolution kernel of 1x1x1 and a normalized exponential function layer to calculate the probability map of the background class and the target class to be segmented in the image tensor to obtain an image segmentation result.
[0035] According to a third aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the steps of any one of the methods described in the first aspect are implemented.
[0036] According to a fourth aspect of the embodiments of the present disclosure, an electronic device is provided, including:
[0037] a memory having a computer program stored thereon;
[0038] A processor is used to execute the computer program in the memory to implement the steps of any one of the methods in the first aspect.
[0039] The present invention provides an image segmentation method, device, medium and equipment based on a deep neural network. Compared with the prior art, it has the following beneficial effects:
[0040] The obtained input tensor corresponding to the medical image to be segmented is subjected to block area average pooling with adjacent pixels of different block area sizes as a whole, and the input tensors to be processed corresponding to each block area size are obtained respectively; the input tensor of the medical image to be segmented and the input tensors to be processed corresponding to each block area size are subjected to downsampling preprocessing respectively, and the global context feature tensor corresponding to the medical image to be segmented with doubled number of channels and the global context feature tensor corresponding to the input tensor to be processed corresponding to each block area size are obtained; the global context feature tensor of the medical image to be segmented and the global context feature tensor corresponding to the input tensor to be processed corresponding to each block area size are subjected to feature splicing in each dimension to generate a spliced tensor with doubled number of channels; the spliced tensor is subjected to upsampling preprocessing to obtain an image tensor with the same resolution as the medical image to be segmented and the same number of channels as the input tensor; a convolution layer with a convolution kernel of 1x1x1 and a normalized exponential function layer are used to calculate the probability map of the background class and the target class to be segmented in the image tensor to obtain the image segmentation result. The global context features are spliced and fused at multiple scales to overcome the limitation that convolution operation is only good at extracting local features, thereby improving the accuracy of image segmentation.
[0041] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:
[0043] Figure 1 It is a flowchart of an image segmentation method based on a deep neural network shown in an embodiment of the specification.
[0044] Figure 2 According to the embodiment of the specification, an implementation Figure 1 Schematic diagram of step S11 in FIG.
[0045] Figure 3 It is a schematic diagram showing doubling the number of channels and halving the number of channels according to an embodiment of the specification.
[0046] Figure 4 It is a schematic diagram of an architecture of image segmentation based on a deep neural network according to an embodiment of the specification.
[0047] Figure 5 It is a schematic diagram of a model structure of image segmentation based on a deep neural network according to an embodiment of the specification.
[0048] Figure 6It is a schematic diagram of the architecture of a downsampling module according to an embodiment of the specification.
[0049] Figure 7 It is a schematic diagram of the architecture of an upsampling module according to an embodiment of the specification.
[0050] Figure 8 It is a block diagram of an image segmentation device based on a deep neural network shown in an embodiment of the specification.
[0051] Fig. 9 It is a block diagram of another image segmentation device based on a deep neural network according to an embodiment of the specification. DETAILED DESCRIPTION
[0052] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0053] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.
[0054] Before introducing an image segmentation method, device, medium and equipment based on a deep neural network provided by an embodiment of the present disclosure, the technical content and existing technical problems in the relevant scenarios are first introduced. The medical image is segmented by 3D Unet, because the low-level features in the convolutional neural networks (CNN) carry more edge information, while the high-level features carry more abstract semantic information. 3D U-Net combines low-level features and high-level features for learning, and upsamples to the resolution of the original image step by step, so that the 3D U-Net network has a more refined segmentation effect than other network architectures. However, since local features are compact vector representations of local image neighborhoods, and global features include contour representations, shape descriptors, and object representations at long distances, etc., both are extremely important for image segmentation tasks. In CNN, convolution operations are good at extracting local features, but there are still certain limitations in capturing global feature representations. In addition, feature information of different scales cannot be processed and fused, resulting in low accuracy of image segmentation.
[0055] In order to achieve the above object, the present invention provides an image segmentation method based on a deep neural network. Figure 1This is a flowchart of an image segmentation method based on a deep neural network according to an embodiment. The method includes:
[0056] In step S11, the acquired input tensor corresponding to the medical image to be segmented is subjected to block area average pooling with adjacent pixels of different block area sizes as a whole, and the input tensor to be processed corresponding to each block area size is obtained respectively;
[0057] In the disclosed embodiments, multi-scale representation provides an effective method for processing object scale changes in semantic segmentation, and for the self-attention mechanism, adjacent pixels can be regarded as a whole, namely, a patch, and the self-attention mechanism between patches can be calculated. A multi-scale self-attention mechanism can be established by constructing patches of different sizes.
[0058] See also Figure 2 As shown in the figure, 2x2x2 and 4x4x4 average pooling layers are used to construct 2x2x2 and 4x4x4 patches respectively, and the average pooling results are used as the information of each patch. Then, global context features are obtained through context modeling, and connected or concatenated with the original non-patch global context features to obtain multi-scale global context features, followed by the extraction part. In addition, it is found that the use of shared context modeling can not only save parameters, but also does not cause loss of accuracy. Compared with the plain context block, the multi-scale context block only adds a little extra parameters and calculation.
[0059] In step S12, the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each of the block area sizes are respectively subjected to downsampling preprocessing to obtain a global context feature tensor with doubled number of channels corresponding to the medical image to be segmented and a global context feature tensor with doubled number of channels corresponding to the input tensor to be processed corresponding to each of the block area sizes;
[0060] In the disclosed embodiment, the Context Modeling part refers to the idea of the self-attention mechanism in the non-local operation module (NL Block), and uses a convolutional layer of size 1x1x1 to linearly map the input tensor and compress the information to obtain a tensor of shape (1, D, H, W) in the embedding space, and then reshape it into a shape of (DHW, 1, 1, 1), and then normalize it using a normalized exponential function layer to obtain the weight of each spatial position, and matrix multiply the weight tensor with the input tensor reshaped into a shape of (DHW, 1, 1, 1) to obtain the global context feature.
[0061] In step S13, the global context feature tensor of the medical image to be segmented and the global context feature tensor corresponding to the input tensor to be processed corresponding to each block area size are concatenated in each dimension to generate a concatenated tensor with doubled channels;
[0062] Among them, Concat is used to concatenate two or more tensors in each dimension to generate a new, larger tensor.
[0063] Determine the splicing dimension: First, it is necessary to determine the dimension on which the global context feature tensor of the medical image to be segmented and the global context feature tensor corresponding to the input tensor to be processed corresponding to each block area size are spliced. In the disclosed embodiment, the splicing dimension includes a channel dimension.
[0064] Check dimension consistency: Before concatenation, you need to ensure that the dimensions other than the concatenation dimension are consistent. For example, if you want to concatenate two feature maps on the channel dimension, the height and width of the two feature maps must be the same.
[0065] Perform concatenation: Once the concatenation dimensions have been determined and dimension consistency has been checked, the concatenation operation can be performed. The concatenation operation concatenates two or more tensors along the specified dimensions to form a new tensor.
[0066] In CNN, the Concat operation is often used in the following scenarios:
[0067] Feature fusion: The global context feature tensor of the medical image to be segmented and the global context feature tensor corresponding to the input tensor to be processed corresponding to each block area size are spliced to fuse feature information at different levels to achieve multi-scale feature extraction and fusion.
[0068] In this way, all information of the original features in the medical image to be segmented can be retained, and the features of the global context feature tensor corresponding to the input tensor to be processed corresponding to each block area size can be fused together through a splicing operation.
[0069] In step S14, upsampling preprocessing is performed on the spliced tensor to obtain an image tensor having the same resolution as the medical image to be segmented and the same number of channels as the input tensor;
[0070] See also Figure 3 As shown in the figure, Plain Context Block is divided into two parts: Context Modeling and Extract. The Context Modeling part refers to the idea of the self-attention mechanism in NL Block. It uses a convolutional layer of size 1x1x1 to linearly map the input tensor and compress the information to obtain a tensor of shape (1, D, H, W) in the embedding space, and then reshapes it into a shape of (DHW, 1, 1, 1). It is then normalized using a normalized exponential function layer to obtain the weight of each spatial position, and the weight tensor is matrix-multiplied with the input tensor reshaped into a shape of (DHW, 1, 1, 1) to obtain the global context feature. The Extract part uses the same MLP structure as SE Block, using MLP to increase nonlinearity and restore the number of output channels to the original number of input channels, and finally aggregates the global context features into the features of each spatial position.
[0071] In step S15, a convolution layer with a convolution kernel of 1x1x1 and a normalized exponential function layer are used to calculate the probability map of the background class and the target class to be segmented in the image tensor to obtain an image segmentation result.
[0072] See also Figure 4 and Figure 5As shown in the figure, a 3D CNN network based on the encoder-decoder architecture. Specifically, MSC-Unet extracts image features and implements global context modeling by stacking basic blocks and multi-scale context (MSC) blocks. The encoder part uses a downsampling module to downsample and double the number of channels, while the decoder part uses a skip connection to fuse low-level edge shape features and high-level abstract semantic features (Feature Concatenation), and uses an upsampling module to upsample and halve the number of channels, so that the resolution is gradually restored to the size of the original input image, and finally uses a convolution layer with a convolution kernel of 1x1x1 and a normalized exponential function layer to calculate the probability map of the background class and the target class to be segmented as the output of the network.
[0073] The target class to be segmented may be, for example, the left and right brachial plexus nerves.
[0074] The above technical scheme performs block area average pooling of adjacent pixels of different block area sizes as a whole on the input tensor corresponding to the acquired medical image to be segmented, and obtains the input tensors to be processed corresponding to each block area size respectively; performs downsampling preprocessing on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area size respectively, and obtains the global context feature tensor with doubled number of channels corresponding to the medical image to be segmented and the global context feature tensor with doubled number of channels corresponding to the input tensor to be processed corresponding to each block area size; performs feature splicing on each dimension of the global context feature tensor of the medical image to be segmented and the global context feature tensor corresponding to the input tensor to be processed corresponding to each block area size to generate a spliced tensor with doubled number of channels; performs upsampling preprocessing on the spliced tensor to obtain an image tensor with the same resolution as the medical image to be segmented and the same number of channels as the input tensor; uses a convolution layer with a convolution kernel of 1x1x1 and a normalized exponential function layer to calculate the probability map of the background class and the target class to be segmented in the image tensor to obtain the image segmentation result. The global context features are spliced and fused at multiple scales to overcome the limitation that convolution operation is only good at extracting local features, thereby improving the accuracy of image segmentation.
[0075] In a possible implementation, in step S12, the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each of the block area sizes are respectively subjected to downsampling preprocessing to obtain a global context feature tensor with doubled number of channels corresponding to the medical image to be segmented and a global context feature tensor with doubled number of channels corresponding to the input tensor to be processed corresponding to each of the block area sizes, including:
[0076] In step S121, linear mapping and information compression are performed on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area size, respectively, to obtain a first tensor with a shape of (1, D, H, W) in the embedding space;
[0077] In the disclosed embodiment, the input medical image tensor (which may be a multi-channel two-dimensional or three-dimensional image) and the input tensor to be processed corresponding to each block area (for example, an image block obtained by segmentation in some way) are mapped to an embedding space (Embedding Space) through a linear transformation (such as a fully connected layer or a convolutional layer). In this process, dimensionality reduction or feature extraction is usually performed to reduce the data dimension and extract key information, thereby obtaining a first tensor with a shape of (1, D, H, W), where D, H, and W represent the depth (number of channels), height, and width of the feature map, respectively.
[0078] Suppose there is a CT lung image whose original input tensor has the shape of (C, H, W), where C is the number of channels (C=1 for grayscale images and C=3 for color images). Through a series of convolutional layers, it can be mapped to a low-dimensional but information-rich feature space, and finally a (1, D, H, W) feature map is obtained, where D is the new number of channels, representing the number of key features extracted from the original image.
[0079] In step S122, each of the first tensors is reshaped to obtain a second tensor corresponding to each of the first tensors with a shape of (DHW, 1, 1, 1);
[0080] In the disclosed embodiment, each first tensor is reshaped from a shape of (1, D, H, W) to a shape of (DHW, 1, 1, 1). This process actually changes the dimension of the tensor to make it more suitable for subsequent operations, such as Softmax normalization. The reshaping operation does not change the total number of elements in the tensor, but only changes its organization. Continuing with the above example, the feature map with a shape of (1, D, H, W) is reshaped to (DHW, 1, 1, 1), so that the element at each position becomes a separate "feature vector" (although there is only one element in this dimension).
[0081] In step S123, each of the second tensors is normalized by a normalized exponential function layer to obtain a weight tensor for each spatial position in each of the second tensors;
[0082] In the disclosed embodiment, each second tensor is normalized using a normalized exponential function layer Softmax. The Softmax function is a function that converts the output of multiple classifications into a probability distribution, which ensures that the sum of the probabilities of all outputs is 1. In this step, Softmax is used to calculate the relative importance of each spatial position among all positions, that is, the weight.
[0083] For the reshaped feature map (DHW, 1, 1, 1), the normalized exponential function layer outputs a weight between 0 and 1 for each position, indicating the importance of the position in the global context. In this way, the information in the original input tensor or the processed input tensor can be adjusted according to these weights to make it more focused on the key areas.
[0084] In step S124, a weight tensor corresponding to the medical image to be segmented is matrix-multiplied with an input tensor of the medical image to be segmented to obtain a global context feature tensor with doubled number of channels corresponding to the medical image to be segmented;
[0085] In the disclosed embodiment, the input tensor of the medical image to be segmented is matrix-multiplied with the calculated weight tensor to obtain a global context feature tensor with doubled channels. This process actually uses the weight tensor to adjust the input tensor so that it contains more global context information.
[0086] The weight tensor has been normalized by Softmax and can be matrix multiplied with the original input tensor so that each pixel in the input tensor is weighted according to its global importance, thus generating a new feature tensor that contains richer global information. The number of channels of this feature tensor may be doubled because it may combine the original features and global context information in some way (such as concatenation or weighted sum).
[0087] In step S125, matrix multiplication is performed on the input tensor to be processed corresponding to each block area size and the corresponding weight tensor to obtain a global context feature tensor with double the number of channels corresponding to the input tensor to be processed corresponding to each block area size.
[0088] In the disclosed embodiment, for each block area size corresponding to the input tensor to be processed, an operation similar to step S124 is also performed, that is, matrix multiplication is performed with the corresponding weight tensor to obtain the global context feature tensor of each block area. This step ensures that each block area can be optimized according to its internal features and global context information.
[0089] If there are multiple patch regions of different sizes (e.g., obtained through multi-scale analysis), the above global context feature extraction process can be applied to each patch region. In this way, each patch region can be optimized based on its own features and global weights, resulting in a more accurate segmentation result.
[0090] In summary, through operations such as linear mapping, information compression, tensor reshaping, Softmax normalization, and matrix multiplication, the local features of medical images and global context information are effectively combined, providing a richer and more accurate feature representation for subsequent image segmentation tasks.
[0091] In a possible implementation, in step S121, linear mapping and information compression are respectively performed on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area size to obtain a first tensor with a shape of (1, D, H, W) in the embedding space, including:
[0092] In step S1211, the first feature extraction module performs image feature extraction on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area size, respectively, to obtain a first feature tensor with doubled channel number;
[0093] In the disclosed embodiment, the first feature extraction module is generally composed of one or more convolutional layers, which extract local features by sliding the convolution kernel on the input tensor. Each convolution kernel can be regarded as a feature detector that can capture specific patterns in the image (such as edges, textures, etc.). Through the convolution operation, a new feature tensor can be obtained, and its number of channels will usually increase (i.e., double) because each convolution kernel generates a new feature map. In addition, in order to increase the nonlinearity of the network, the convolution operation is usually followed by a nonlinear activation function (such as ReLU) to allow the network to learn more complex feature representations.
[0094] For example, suppose there is an input tensor of a lung CT image, whose original shape is (1, C, H, W), where C is the number of channels (C=1 for grayscale images, and C may be greater than 1 for some preprocessed color images). In step S1211, this input tensor is processed by a first feature extraction module (which may be a convolution block composed of one or more convolutional layers). This module uses convolution kernels to extract low-level features in the image, such as edges, textures, etc., and adds nonlinearity through activation functions (such as ReLU). After passing through this module, a new feature tensor is obtained, whose number of channels is doubled (for example, from C to 2C), but the height and width may be reduced (or remain unchanged, depending on the specific design) due to pooling layers or convolutional layers with a step size greater than 1. This new feature tensor contains richer image information.
[0095] In step S1212, the second feature extraction module performs image feature extraction on the first feature tensor with doubled channel number to obtain a second feature tensor;
[0096] In the disclosed embodiment, the second feature extraction module continues to deepen the feature extraction process, and it may include more convolutional layers, pooling layers, and possible residual connections. These structures work together to further extract high-level features of the image. Pooling layers (such as maximum pooling or average pooling) are used to reduce the resolution of feature maps, reduce the amount of calculation, and help the network capture more abstract features. Residual connections help alleviate the gradient vanishing problem in deep networks, making the network easier to train.
[0097] The first feature tensor with doubled number of channels obtained in step S1211 is sent to the second feature extraction module. This module may contain more convolutional layers, pooling layers, and possible residual connections (in deeper networks) to further extract high-level features of the image. These high-level features are usually more abstract and can capture semantic information in the image. After processing by the second feature extraction module, a new second feature tensor is obtained, the number of channels of which may increase again (or remain unchanged, depending on the specific design of the module), but similarly, the height and width may be further reduced. This second feature tensor contains important feature information of the input image at different scales.
[0098] In step S1213, features of different scales in each of the second feature tensors are aggregated through a context aggregation module to obtain a first tensor with a shape of (1, D, H, W) in the embedding space.
[0099] In the disclosed embodiment, the role of the context aggregation module is to fuse features of different scales so that local details and global context information can be used simultaneously in subsequent processing. This module may use a variety of technologies to achieve feature aggregation, such as feature pyramid network (FPN), dilated convolutions, attention mechanism, etc. Through these technologies, feature maps of different levels (including feature tensors obtained after two feature extractions of the original input tensor and feature tensors corresponding to each block area size) can be upsampled, downsampled or directly spliced to generate a unified feature representation with rich context information.
[0100] The context aggregation module is used to integrate the second feature tensors obtained in step S1212 (this may involve feature tensors corresponding to multiple block area sizes, as well as feature tensors of the original input tensor after two feature extractions). The function of the context aggregation module is to fuse features of different scales so that local details and global context information can be used simultaneously in subsequent processing. This module may use a variety of techniques to achieve feature aggregation, such as pyramid structure, attention mechanism, dilated convolutions, etc. Finally, the context aggregation module outputs a first tensor of shape (1, D, H, W), where D is the new number of channels, representing the feature dimension in the embedding space; H and W represent the height and width of the feature map, respectively. This first tensor will be used as input for subsequent steps for further image processing or segmentation tasks. In this way, the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area can be converted into feature representations in the embedding space.
[0101] In a possible implementation, the first feature extraction module is composed of two basic convolution modules and a connection layer module connected in series in sequence, wherein the convolution layer step size in the first basic convolution module is 2, and the convolution layer step size in the first basic convolution module is 2 so that the number of output channels is twice the number of input channels;
[0102] The second feature extraction module is composed of two basic convolution modules and one connection layer module connected in series in sequence, wherein the convolution layer step size in the first basic convolution module is 1.
[0103] In the disclosed embodiment, the downsampling module is mainly used for downsampling and doubling the number of channels. Figure 6As shown in the figure, the downsampling module (Downsampling Module) is composed of two Basic Blocks and a connection module (Context Block) connected in series in sequence, where the convolution layer stride in the first Basic Block is 2, and the number of output channels is twice the number of input channels.
[0104] In a possible implementation, Leaky ReLU is used as an activation function in the basic convolution module, and the slope is set to 0.01, and a normalization layer is constructed between each convolution layer and the Leaky ReLU, wherein the normalization layer is used to calculate the mean and variance of the output of the previous convolution layer, and convert the data into a stable distribution with a mean of zero and a variance of 1, so as to prevent gradient explosion or diffusion and reduce dependence on network initialization parameters, and allow a larger learning rate to be used in training to accelerate the convergence speed of the network;
[0105] The standardization layer is used to standardize each channel and remove the correlation between channels.
[0106] In the disclosed embodiment, the basic convolution module Basic Block is composed of Conv-IN-LeakyReLU, which is used to extract the image features of the input feature map. Since the activation function ReLU (Linear rectification function) is always 0 in the negative area, when the learning rate is too high and the parameters of the model are adjusted too much, the output of a large number of neurons may be set to 0. If all the neurons in a hidden layer are set to 0, the training will be interrupted, and once the neurons are set to 0, they will not recover and will die permanently because the parameters of the neurons will not be updated. Leaky ReLU (Leaky linear rectification function) gives a non-zero slope to all negative values, so Leaky ReLU is used as the activation function, and the slope is set to 0.01.
[0107] In addition, a normalization layer is introduced between each convolutional layer and Leaky ReLU. The normalization layer is used to calculate the mean and variance of the output of the previous convolutional layer, and the data is converted to a stable distribution with a mean of zero and a variance of 1. This can effectively prevent gradient explosion or diffusion and reduce dependence on network initialization parameters. It also allows a larger learning rate to be used during training, thereby accelerating the convergence of the network. At the same time, it regularizes the network to a certain extent, thereby improving the generalization ability of the network and thus improving the accuracy of target recognition.
[0108] In the disclosed embodiment, the batch size used is relatively small, so instance normalization is used to replace batch normalization. Instance Normalization normalizes each channel (feature map) to remove the correlation between channels (feature maps) so as to keep the data between channels independent.
[0109] In a possible implementation, performing upsampling preprocessing on the spliced tensor to obtain an image tensor having the same resolution as the medical image to be segmented and the same number of channels as the input tensor includes:
[0110] Using a convolution layer with a convolution kernel size of 1x1x1 and a stride of 1, convolution processing is performed on the spliced tensor so that the number of channels of the spliced tensor is halved, and a convolution tensor with the same number of channels as the input tensor is obtained;
[0111] The convolution tensor is upsampled by using an interpolation method so that the resolution of the convolution tensor is enlarged to 2 times, thereby obtaining the image tensor having the same resolution as the medical image to be segmented.
[0112] See also Figure 7 As shown in the figure, the upsampling module is composed of two Basic Blocks, a Context Block and an upsampling operation connected in series, where the number of output channels in the first Basic Block is half the number of input channels. In deep learning, upsampling can increase the output dimension of the neural network. Upsampling usually uses transposed convolution with stride, but transposed convolution can only return to a feature map with the same width and height, and cannot restore the information in the original feature map, resulting in loss of spatial information. Therefore, interpolation and a convolution layer with a kernel size of 1x1x1 and a stride of 1 are used to replace the transposed convolution, where interpolation is used to enlarge the spatial resolution to twice the original, and the convolution layer is used to halve the number of channels.
[0113] In a possible implementation, the interpolation method is a nearest neighbor interpolation method.
[0114] Based on the experimental results, the effect of using nearest neighbor interpolation is better, which not only reduces the amount of parameters but also improves the accuracy of segmentation.
[0115] It can be explained that the structure of Non-Local Block and SE Block is improved in the disclosed embodiment, a multi-scale global self-attention mechanism is used to extract global context features, and MLP is used to extract important features, effectively improving the accuracy of segmentation. The 3D CNN network MSC-Unet based on the encoder-decoder architecture effectively combines the Multi-Scale Context Block and uses the nearest neighbor interpolation upsampling layer to replace the traditional transposed convolution layer.
[0116] The present disclosure provides an image segmentation device based on a deep neural network. Figure 8 As shown, including:
[0117] The block area average pooling module 810 is configured to perform block area average pooling on the acquired input tensor corresponding to the medical image to be segmented, taking adjacent pixels of different block area sizes as a whole, and obtain the input tensor to be processed corresponding to each block area size;
[0118] The downsampling preprocessing module 820 is configured to perform downsampling preprocessing on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each of the block area sizes, respectively, to obtain a global context feature tensor with doubled number of channels corresponding to the medical image to be segmented and a global context feature tensor with doubled number of channels corresponding to the input tensor to be processed corresponding to each of the block area sizes;
[0119] The splicing module 830 is configured to perform feature splicing in each dimension on the global context feature tensor of the medical image to be segmented and the global context feature tensor corresponding to the input tensor to be processed corresponding to each block area size, so as to generate a spliced tensor with doubled channels;
[0120] An upsampling preprocessing module 840 is configured to perform upsampling preprocessing on the spliced tensor to obtain an image tensor with the same resolution as the medical image to be segmented and the same number of channels as the input tensor;
[0121] The calculation module 850 is configured to use a convolution layer with a convolution kernel of 1x1x1 and a normalized exponential function layer to calculate the probability map of the background class and the target class to be segmented in the image tensor to obtain an image segmentation result.
[0122] In a possible implementation, the downsampling preprocessing module 820 is configured as follows:
[0123] Performing linear mapping and information compression on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area size, respectively, to obtain a first tensor with a shape of (1, D, H, W) in the embedding space;
[0124] Reshape each of the first tensors to obtain a second tensor corresponding to each of the first tensors, the second tensor having a shape of (DHW, 1, 1, 1);
[0125] Normalizing each of the second tensors by a normalized exponential function layer to obtain a weight tensor for each spatial position in each of the second tensors;
[0126] Performing matrix multiplication of the weight tensor corresponding to the medical image to be segmented and the input tensor of the medical image to be segmented to obtain a global context feature tensor with doubled number of channels corresponding to the medical image to be segmented;
[0127] The input tensor to be processed corresponding to each block area size is matrix multiplied with the corresponding weight tensor to obtain a global context feature tensor with double the number of channels corresponding to the input tensor to be processed corresponding to each block area size.
[0128] In a possible implementation, the downsampling preprocessing module 820 is configured as follows:
[0129] Performing image feature extraction on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area size respectively through a first feature extraction module to obtain a first feature tensor with doubled channel number;
[0130] Performing image feature extraction on the first feature tensor with doubled channel number through a second feature extraction module to obtain a second feature tensor;
[0131] Features of different scales in each of the second feature tensors are aggregated through a context aggregation module to obtain a first tensor with a shape of (1, D, H, W) in the embedding space.
[0132] In a possible implementation, the first feature extraction module is composed of two basic convolution modules and a connection layer module connected in series in sequence, wherein the convolution layer step size in the first basic convolution module is 2, and the convolution layer step size in the first basic convolution module is 2 so that the number of output channels is twice the number of input channels;
[0133] The second feature extraction module is composed of two basic convolution modules and one connection layer module connected in series in sequence, wherein the convolution layer step size in the first basic convolution module is 1.
[0134] In a possible implementation, Leaky ReLU is used as an activation function in the basic convolution module, and the slope is set to 0.01, and a normalization layer is constructed between each convolution layer and the Leaky ReLU, wherein the normalization layer is used to calculate the mean and variance of the output of the previous convolution layer, and convert the data into a stable distribution with a mean of zero and a variance of 1, so as to prevent gradient explosion or diffusion and reduce dependence on network initialization parameters, and allow a larger learning rate to be used in training to accelerate the convergence speed of the network;
[0135] The standardization layer is used to standardize each channel and remove the correlation between channels.
[0136] In a possible implementation, the upsampling preprocessing module 840 is configured as follows:
[0137] Using a convolution layer with a convolution kernel size of 1x1x1 and a stride of 1, convolution processing is performed on the spliced tensor so that the number of channels of the spliced tensor is halved, and a convolution tensor with the same number of channels as the input tensor is obtained;
[0138] The convolution tensor is upsampled by using an interpolation method so that the resolution of the convolution tensor is enlarged to 2 times, thereby obtaining the image tensor having the same resolution as the medical image to be segmented.
[0139] In a possible implementation, the interpolation method is a nearest neighbor interpolation method.
[0140] The present disclosure also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the method described in any one of the aforementioned embodiments are implemented.
[0141] The present disclosure also provides an electronic device, including:
[0142] a memory having a computer program stored thereon;
[0143] A processor is used to execute the computer program in the memory to implement the steps of the method in any one of the aforementioned embodiments.
[0144] Fig. 9The image segmentation device 100 based on a deep neural network shown includes: a processor 1001 and a memory 1003. The processor 1001 and the memory 1003 are connected, such as through a bus 1002. Optionally, the image segmentation device 100 based on a deep neural network may also include a communication component, which can be used for data interaction between the device 100 and other devices, such as data transmission and / or data reception. It should be noted that the communication component is not limited to one in actual scheduling, and the structure of the image segmentation device 100 based on a deep neural network does not constitute a limitation on the embodiments of the present application.
[0145] Processor 1001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. Processor 1001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0146] The bus 1002 may include a path to transmit information between the above components. The bus 1002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 1002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0147] The memory 1003 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), magnetic disk storage medium, other magnetic storage devices, or any other medium that can be used to carry or store program code and can be read by a computer, without limitation herein.
[0148] The memory 1003 is used to store program codes for executing the embodiments of the present disclosure, and the execution is controlled by the processor 1001. The processor 1001 is used to execute the program codes stored in the memory 1003 to implement the steps shown in the above-mentioned embodiment of the image segmentation method based on deep neural network.
[0149] The embodiment of the present disclosure also provides a computer-readable storage medium having program code stored thereon. When the program code is executed by a processor, the steps and corresponding contents of the aforementioned embodiment of the image segmentation method based on a deep neural network can be implemented.
[0150] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments; within the technical concept of the present disclosure, various changes, modifications, substitutions and variations may be made to these embodiments, and these changes, modifications, substitutions and variations all fall within the protection scope of the present disclosure.
[0151] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any appropriate manner without contradiction, and they should also be regarded as the contents disclosed in this disclosure. In order to avoid unnecessary repetition, this disclosure will not further describe various possible combinations. The technical scope of this application is not limited to the contents in the specification, and its technical scope must be determined according to the scope of the claims.
Claims
1. An image segmentation method based on deep neural network, characterized in that: The method comprises: The obtained input tensor corresponding to the medical image to be segmented is subjected to block area average pooling with adjacent pixels of different block area sizes as a whole, and an input tensor to be processed corresponding to each block area size is obtained respectively; The input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each of the block area sizes are respectively subjected to downsampling preprocessing to obtain a global context feature tensor with doubled number of channels corresponding to the medical image to be segmented and a global context feature tensor with doubled number of channels corresponding to the input tensor to be processed corresponding to each of the block area sizes; Performing feature splicing in each dimension on the global context feature tensor of the medical image to be segmented and the global context feature tensor corresponding to the input tensor to be processed corresponding to each block area size, so as to generate a spliced tensor with doubled channels; Performing upsampling preprocessing on the spliced tensor to obtain an image tensor with the same resolution as the medical image to be segmented and the same number of channels as the input tensor; Using a convolution layer with a convolution kernel of 1x1x1 and a normalized exponential function layer, the probability map of the background class and the target class to be segmented in the image tensor is calculated to obtain an image segmentation result; The downsampling preprocessing is performed on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area size to obtain a global context feature tensor with doubled number of channels corresponding to the medical image to be segmented and a global context feature tensor with doubled number of channels corresponding to the input tensor to be processed corresponding to each block area size, including: Performing linear mapping and information compression on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area size, respectively, to obtain a first tensor with a shape of (1, D, H, W) in the embedding space; Reshape each of the first tensors to obtain a second tensor corresponding to each of the first tensors, the second tensor having a shape of (DHW, 1, 1, 1); Normalizing each of the second tensors by a normalized exponential function layer to obtain a weight tensor for each spatial position in each of the second tensors; Performing matrix multiplication of the weight tensor corresponding to the medical image to be segmented and the input tensor of the medical image to be segmented to obtain a global context feature tensor with doubled number of channels corresponding to the medical image to be segmented; Performing matrix multiplication of the input tensor to be processed corresponding to each block area size and the corresponding weight tensor to obtain a global context feature tensor with double the number of channels corresponding to the input tensor to be processed corresponding to each block area size; The step of linearly mapping and compressing the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area size to obtain a first tensor of shape (1, D, H, W) in the embedding space includes: Performing image feature extraction on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area size respectively through a first feature extraction module to obtain a first feature tensor with doubled channel number; Performing image feature extraction on the first feature tensor with doubled channel number by a second feature extraction module to obtain a second feature tensor; Aggregating features of different scales in each of the second feature tensors through a context aggregation module to obtain a first tensor with a shape of (1, D, H, W) in the embedding space; The first feature extraction module is composed of two basic convolution modules and a connection layer module connected in series in sequence, wherein the convolution layer step size in the first basic convolution module is 2, and the convolution layer step size in the first basic convolution module is 2 so that the number of output channels is twice the number of input channels; The second feature extraction module is composed of two basic convolution modules and one connection layer module connected in series in sequence, wherein the convolution layer step size in the first basic convolution module is 1.
2. The image segmentation method based on deep neural network according to claim 1, characterized in that: The basic convolution module uses Leaky ReLU as the activation function, and sets the slope to 0.01, and constructs a normalization layer between each convolution layer and the LeakyReLU, wherein the normalization layer is used to calculate the mean and variance of the output of the previous convolution layer, and convert the data into a stable distribution with a mean of zero and a variance of 1, so as to prevent the phenomenon of gradient explosion or diffusion and reduce the dependence on the network initialization parameters, and allow a larger learning rate to be used in training to accelerate the convergence speed of the network; The normalization layer is used to normalize each channel and remove the correlation between channels.
3. The image segmentation method based on deep neural network according to any one of claims 1 to 2, characterized in that: The upsampling preprocessing of the spliced tensor to obtain an image tensor with the same resolution as the medical image to be segmented and the same number of channels as the input tensor includes: Using a convolution layer with a convolution kernel size of 1x1x1 and a stride of 1, convolution processing is performed on the spliced tensor so that the number of channels of the spliced tensor is halved, and a convolution tensor with the same number of channels as the input tensor is obtained; The convolution tensor is upsampled by using an interpolation method so that the resolution of the convolution tensor is enlarged to 2 times, thereby obtaining the image tensor with the same resolution as the medical image to be segmented.
4. The image segmentation method based on deep neural network according to claim 3, characterized in that: The interpolation method is the nearest neighbor interpolation method.
5. An image segmentation device based on a deep neural network, characterized in that: include: The block area average pooling module is configured to perform block area average pooling on the acquired input tensor corresponding to the medical image to be segmented, taking adjacent pixels of different block area sizes as a whole, and obtain the input tensor to be processed corresponding to each block area size; A downsampling preprocessing module is configured to perform downsampling preprocessing on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each of the block area sizes, respectively, to obtain a global context feature tensor with doubled number of channels corresponding to the medical image to be segmented and a global context feature tensor with doubled number of channels corresponding to the input tensor to be processed corresponding to each of the block area sizes; A splicing module is configured to perform feature splicing on each dimension of the global context feature tensor of the medical image to be segmented and the global context feature tensor corresponding to the input tensor to be processed corresponding to each block area size, so as to generate a spliced tensor with doubled channels; An upsampling preprocessing module is configured to perform upsampling preprocessing on the spliced tensor to obtain an image tensor with the same resolution as the medical image to be segmented and the same number of channels as the input tensor; A calculation module is configured to use a convolution layer with a convolution kernel of 1x1x1 and a normalized exponential function layer to calculate probability maps of the background class and the target class to be segmented in the image tensor to obtain an image segmentation result; Wherein, the downsampling preprocessing module is configured as follows: Performing linear mapping and information compression on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area size, respectively, to obtain a first tensor with a shape of (1, D, H, W) in the embedding space; Reshape each of the first tensors to obtain a second tensor corresponding to each of the first tensors, the second tensor having a shape of (DHW, 1, 1, 1); Normalizing each of the second tensors by a normalized exponential function layer to obtain a weight tensor for each spatial position in each of the second tensors; Performing matrix multiplication of the weight tensor corresponding to the medical image to be segmented and the input tensor of the medical image to be segmented to obtain a global context feature tensor with doubled number of channels corresponding to the medical image to be segmented; Performing matrix multiplication of the input tensor to be processed corresponding to each block area size and the corresponding weight tensor to obtain a global context feature tensor with double the number of channels corresponding to the input tensor to be processed corresponding to each block area size; Wherein, the downsampling preprocessing module is configured as follows: Performing image feature extraction on the input tensor of the medical image to be segmented and the input tensor to be processed corresponding to each block area size respectively through a first feature extraction module to obtain a first feature tensor with doubled channel number; Performing image feature extraction on the first feature tensor with doubled channel number by a second feature extraction module to obtain a second feature tensor; Aggregating features of different scales in each of the second feature tensors through a context aggregation module to obtain a first tensor with a shape of (1, D, H, W) in the embedding space; The first feature extraction module is composed of two basic convolution modules and a connection layer module connected in series in sequence, wherein the convolution layer step size in the first basic convolution module is 2, and the convolution layer step size in the first basic convolution module is 2 so that the number of output channels is twice the number of input channels; The second feature extraction module is composed of two basic convolution modules and one connection layer module connected in series in sequence, wherein the convolution layer step size in the first basic convolution module is 1.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 4 are implemented.
7. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Image Semantic Segmentation Method Based on Deep Full Convolutional Network and Conditional Random Field
AU2020103901A4
Medical image segmentation method, system and device based on convolution and transformer fusion
CN114066902A
