Dynamic multi-scale medical image segmentation method based on morphological boundary condition gating
By introducing a dynamic multi-scale medical image segmentation method with morphological boundary condition gating, and dynamically adjusting branch weights and GAN network constraints using morphological boundary features, the performance bottleneck of single-scale convolutional neural networks in preserving small-scale lesions and boundary details is solved, achieving more efficient lesion segmentation results.
Patent Information
- Application Number
- CN202511383742.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-26
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2045-09-26
AI Technical Summary
Existing single-scale convolutional neural networks have performance bottlenecks when dealing with diverse lesion features, especially in small-scale lesions and preserving boundary details, and fail to fully consider the impact of local lesion regions, especially boundary information, on branch selection.
A dynamic multi-scale medical image segmentation method based on morphological boundary condition gating is adopted. By combining morphological erosion, dilation difference and high-pass filtering to extract boundary features through a dynamic multi-branch perception module, branch weights are dynamically generated. Combined with GAN network and dynamic segmentation loss function, constraints on the overall structure and local details are applied to achieve adaptive adjustment of multi-scale receptive field and edge consistency correction.
It improves the ability to detect small-scale hemorrhage areas and ambiguous boundaries, reduces missed detections and false judgments, and enhances the consistency and accuracy of segmentation boundaries.
Smart Images

Figure CN120876514A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, specifically to a dynamic multi-scale medical image segmentation method based on morphological boundary condition gating. Background Technology
[0002] Medical image segmentation is a crucial technology in computer-aided diagnosis, widely applied in clinical scenarios such as lesion detection, quantitative assessment of lesion areas, and surgical planning. However, in medical images of diseases like cerebral hemorrhage, the size, edge features, and salience of lesion regions often vary considerably, leading to the inadequacy of traditional single-scale convolutional neural networks in handling diverse lesion features. Particularly in CT images of cerebral hemorrhage, small hemorrhage areas are easily missed or missegmented due to their small proportion within the brain tissue, while large hemorrhage areas, although more prominent in the brain tissue, are not always regular in shape, and their boundaries are often blurred.
[0003] To address the aforementioned issues, existing technologies typically employ stacking fixed-size convolutional kernels or dilated convolutional modules to expand the receptive field, such as the typical dilated spatial pyramid pooling (ASPP) or multi-kernel convolutional structures, which can capture contextual information at different scales to some extent. However, most of these methods rely solely on fixed-structure stacking and lack the ability to dynamically adjust receptive field weights based on input image features. Some existing research has introduced multi-branch convolutional kernels and adaptive weight mechanisms, which can generate branch weights based on the input to achieve kernel selection. However, their weight generation relies solely on global contextual statistics and does not fully consider the impact of local lesion regions, especially boundary information, on branch selection. Therefore, performance bottlenecks still exist in preserving small-scale lesions or boundary details. Summary of the Invention
[0004] This invention addresses the shortcomings of existing single-scale convolutional neural networks in handling diverse lesion features. Their weight generation relies solely on global context statistics and does not fully consider the impact of local lesion regions, especially boundary information, on branch selection. Therefore, performance bottlenecks still exist in preserving small-scale lesions or boundary details.
[0005] To solve the above-mentioned technical problems, the present invention is achieved through the following technical solution: Option 1: This invention proposes a dynamic multi-scale medical image segmentation method based on morphological boundary condition gating, the method comprising the following steps: Step 1: Obtain CT images of cerebral hemorrhage and preprocess the CT images of cerebral hemorrhage. The preprocessing involves slicing along the z-axis to generate cross-sectional images and performing image enhancement on the cross-sectional images. Step 2: Input the preprocessed cross-sectional image into the segmentation network, which includes a dynamic multi-branch perception module for extracting multi-scale features using convolutional branches of different sizes or dilatations. A branch weight generator is used to dynamically generate the weights of each branch by combining global information of the input image and boundary features extracted by morphological erosion, dilation difference and high-pass filtering, so as to realize multi-scale adaptive adjustment of receptive field driven by local structural conditions. The boundary refinement module is used to extract edge features using morphological methods and Laplacian high-pass filtering, and to correct the edge consistency of the segmentation results through learnable convolutional residuals. Step 3: Combine the dynamic segmentation loss function, assign different penalty weights according to the size of the bleeding area, and introduce a GAN network. Through the joint discrimination of the global discriminator and the local discriminator, the segmentation results are constrained at both the overall structure and local detail levels, thus completing the dynamic multi-scale medical image segmentation based on morphological boundary condition gating.
[0006] Furthermore, in a preferred embodiment, the preprocessing of the CT images of cerebral hemorrhage in step 1 further includes dividing the CT image dataset of cerebral hemorrhage into a training set and a validation set, wherein the ratio of the training set to the validation set is 8:2.
[0007] Furthermore, a preferred embodiment is provided, in which step 1 further includes the step of building a dynamic multi-scale encoder, wherein the dynamic multi-scale encoder uses three different convolutions as different receptive field branches at multiple scales for feature extraction.
[0008] Furthermore, a preferred implementation is provided, in which the AdaptiveAvgPool2d function is called to perform global average pooling on the feature map obtained by the dynamic multi-scale encoder and stored in the variable gp. Then, the boundary mask map obtained by the boundary refinement module is performed to perform global average pooling to obtain the boundary features and stored in the variable boundary_feat.
[0009] Furthermore, a preferred embodiment is provided, wherein the method for constructing the boundary refinement module in step 2 is as follows: Input a segmentation probability map seg. First, perform morphological operations on the segmentation probability map seg, using 3 Max pooling with a capacity of 3 is used to implement the expansion operation. The erosion operation is performed using average pooling (3x3). The difference between the two is used to obtain the approximate boundary features, which are stored in a boundary. Positions within this boundary that are greater than zero are identified, and a binary boundary mask (boundary_mask) is generated and stored. Then, the input segment is processed using average pooling (3x3). 3. Convolutional layers are used to construct a Laplacian high-pass filter kernel. High-pass filtering is performed to extract high-frequency edge features. These features are then multiplied pixel-by-pixel with the boundary_mask, retaining only the effective edge information within the boundary. The retained edge features are input into a learnable convolutional residual block, which is then passed through a 3×3 convolution, a ReLU activation function, and a 1×1 convolution to obtain a correction value. This correction value is then added pixel-by-pixel to the original input segmentation probability map seg, and the corrected segmentation result, refined, is output.
[0010] Furthermore, a preferred embodiment is provided, wherein step 3 includes the following steps: Step 3.1: Input splicing and feature extraction backbone construction. The cat function of the torch library is called to splice the original medical image and segmentation mask in the channel dimension to form the input tensor; Step 3.2: Perform global average pooling on the feature map (feat) extracted in Step 3.1, compressing the spatial dimension to 1. 1. Preserve global semantic information, using 1 1. Convolution is used to perform channel fusion to generate a scalar output, which is used to determine the overall structural authenticity of the image segmentation result; Step 3.3: Apply 3 to the feature map feat extracted in step 3.1. 3. Convolution extracts the coherence and local morphological consistency information of the segmentation boundary in the local region and outputs a local discrimination score map local_out with a spatial dimension similar to that of the input space. This branch is used to capture the regional boundary detail deviation or local morphological anomaly at the micro scale. Step 3.4, Adversarial Training of Generator and Trainer: The generator is the network jointly constructed in Steps 3.1 and 3.2, and the discriminator is the global and local discriminator constructed in Steps 3.1, 3.2, and 3.3 in Step 3. The discriminator outputs disc_real for the input combination of the original image and the real segmentation image, and outputs disc_fake for the input combination of the original image and the predicted segmentation image. disc_fake participates in the adversarial loss of the generator and the discriminator loss, while disc_real participates in the discriminator loss. Discriminator warm-up is enabled so that the discriminator participates in discrimination after the 15th iteration of model training.
[0011] Option 2: A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method described in Option 1.
[0012] Option 3: A computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor runs the computer program stored in the memory, the processor executes the method described in Option 1.
[0013] The advantages of this invention are: The morphological boundary condition-gated dynamic multi-scale medical image segmentation method of the present invention introduces a multi-scale receptive field structure into the segmentation network and combines a weight generator to adaptively weight the output of each branch. Furthermore, it utilizes the lesion boundary features extracted by morphological erosion, dilation difference and high-pass filtering as conditional gating inputs to achieve dynamic matching of complex local boundary regions by the multi-scale receptive field.
[0014] This invention integrates a morphological boundary residual refinement module into the backbone segmentation network. The extracted boundary features are used for both branch selection condition gating and detailed correction of the final segmentation result, forming an end-to-end closed-loop structure of "boundary extraction - dynamic allocation of branch weights - segmentation result consistency optimization".
[0015] This invention introduces morphological boundary features as conditional gating inputs, which, together with the global features of the lesion, adjust the weights of the multi-branch receptive field, thereby improving the detection capability of small-scale hemorrhage areas and ambiguous boundaries, and reducing missed detections and misjudgments.
[0016] The morphological boundary extraction described in this invention is not only used for branch selection gating, but also for boundary refinement of segmentation results, forming an end-to-end closed structure and improving the consistency of segmentation boundaries.
[0017] This invention combines dynamic segmentation loss, morphological loss, and joint constraints from the global and local discriminators of the GAN network to further optimize the edge coherence and structural consistency of the segmentation results.
[0018] This invention is also applicable to fields such as medical image segmentation. Attached Figure Description
[0019] Figure 1 This is a flowchart of the dynamic multi-scale medical image segmentation method based on morphological boundary condition gating as described in Implementation Method Nine. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them.
[0021] Implementation Method 1: This implementation method proposes a dynamic multi-scale medical image segmentation method based on morphological boundary condition gating. The method includes the following steps: Step 1: Obtain CT images of cerebral hemorrhage and preprocess the CT images of cerebral hemorrhage. The preprocessing involves slicing along the z-axis to generate cross-sectional images and performing image enhancement on the cross-sectional images. Step 2: Input the preprocessed cross-sectional image into the segmentation network, which includes a dynamic multi-branch perception module for extracting multi-scale features using convolutional branches of different sizes or dilatations. A branch weight generator is used to dynamically generate the weights of each branch by combining global information of the input image and boundary features extracted by morphological erosion, dilation difference and high-pass filtering, so as to realize multi-scale adaptive adjustment of receptive field driven by local structural conditions. The boundary refinement module is used to extract edge features using morphological methods and Laplacian high-pass filtering, and to correct the edge consistency of the segmentation results through learnable convolutional residuals. Step 3: Combine the dynamic segmentation loss function, assign different penalty weights according to the size of the bleeding area, and introduce a GAN network. Through the joint discrimination of the global discriminator and the local discriminator, the segmentation results are constrained at both the overall structure and local detail levels, thus completing the dynamic multi-scale medical image segmentation based on morphological boundary condition gating.
[0022] Implementation Method 2: This implementation method further defines the dynamic multi-scale medical image segmentation method based on morphological boundary condition gating described in Implementation Method 1. The preprocessing of the cerebral hemorrhage CT image in step 1 also includes dividing the cerebral hemorrhage CT image dataset into a training set and a validation set, wherein the ratio of the training set to the validation set is 8:2.
[0023] Implementation Method 3: This implementation method further defines the dynamic multi-scale medical image segmentation method based on morphological boundary condition gating described in Implementation Method 1. Step 1 also includes the step of building a dynamic multi-scale encoder, which uses three different convolutions as different receptive field branches for multi-scale feature extraction.
[0024] Implementation Method 4: This implementation method further defines the dynamic multi-scale medical image segmentation method based on morphological boundary condition gating described in Implementation Method 1. The AdaptiveAvgPool2d function is called to perform global average pooling on the feature map obtained by the dynamic multi-scale encoder and stored in the variable gp. Then, global average pooling is performed on the boundary mask map obtained by the boundary refinement module to obtain the boundary features and stored in the variable boundary_feat.
[0025] Implementation Method 5: This implementation method further defines the dynamic multi-scale medical image segmentation method based on morphological boundary condition gating described in Implementation Method 1. The method for constructing the boundary refinement module in step 2 is as follows: Input a segmentation probability map seg. First, perform morphological operations on the segmentation probability map seg, using 3 Max pooling with a capacity of 3 is used to implement the expansion operation. The erosion operation is performed using average pooling (3x3). The difference between the two is used to obtain the approximate boundary features, which are stored in a boundary. Positions within this boundary that are greater than zero are identified, and a binary boundary mask (boundary_mask) is generated and stored. Then, the input segment is processed using average pooling (3x3). 3. Convolutional layers are used to construct a Laplacian high-pass filter kernel. High-pass filtering is performed to extract high-frequency edge features. These features are then multiplied pixel-by-pixel with the boundary_mask, retaining only the effective edge information within the boundary. The retained edge features are input into a learnable convolutional residual block, which is then passed through a 3×3 convolution, a ReLU activation function, and a 1×1 convolution to obtain a correction value. This correction value is then added pixel-by-pixel to the original input segmentation probability map seg, and the corrected segmentation result, refined, is output.
[0026] Implementation Method Six: This implementation method further defines the dynamic multi-scale medical image segmentation method based on morphological boundary condition gating described in Implementation Method One. Step 3 includes the following steps: Step 3.1: Input splicing and feature extraction backbone construction. The cat function of the torch library is called to splice the original medical image and segmentation mask in the channel dimension to form the input tensor; Step 3.2: Perform global average pooling on the feature map (feat) extracted in Step 3.1, compressing the spatial dimension to 1. 1. Preserve global semantic information, using 1 1. Convolution is used to perform channel fusion to generate a scalar output, which is used to determine the overall structural authenticity of the image segmentation result; Step 3.3: Apply 3 to the feature map feat extracted in step 3.1. 3. Convolution extracts the coherence and local morphological consistency information of the segmentation boundary in the local region and outputs a local discrimination score map local_out with a spatial dimension similar to that of the input space. This branch is used to capture the regional boundary detail deviation or local morphological anomaly at the micro scale. Step 3.4, Adversarial Training of Generator and Trainer: The generator is the network jointly constructed in Steps 3.1 and 3.2, and the discriminator is the global and local discriminator constructed in Steps 3.1, 3.2, and 3.3 in Step 3. The discriminator outputs disc_real for the input combination of the original image and the real segmentation image, and outputs disc_fake for the input combination of the original image and the predicted segmentation image. disc_fake participates in the adversarial loss of the generator and the discriminator loss, while disc_real participates in the discriminator loss. Discriminator warm-up is enabled so that the discriminator participates in discrimination after the 15th iteration of model training.
[0027] Implementation Method Seven: This implementation method provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method described in any one of Implementation Methods One to Five. Implementation Method 8: This implementation method provides a computer device, including a memory and a processor. The memory stores a computer program. When the processor runs the computer program stored in the memory, the processor executes the method described in any one of Implementation Methods 1 to 5.
[0028] Implementation Method Nine: This implementation method proposes an example, which is used to explain the above-described implementation methods one through eight. The specific example is as follows: See Figure 1 This implementation method is described with reference to Figure 1 As shown, the method described in this embodiment specifically includes the following steps: Step 1: To segment small hemorrhage areas while avoiding the network's tendency to segment large hemorrhage areas during training, we further improved the traditional multi-scale convolution. Morphological boundary features were introduced as conditional gating input into the branch weight generator. These boundary features were obtained from the coarse segmentation results through the boundary refinement module in Step 2. These boundary features, along with the global features of the input image, were input into the weight generator to dynamically adjust the weights of each scale branch, allowing the receptive field to adaptively match the size of different lesions and boundary complexity.
[0029] Step 2: To further improve the boundary consistency of the segmentation results, a boundary residual refinement module is integrated at the end of the network. This module extracts boundary features through dilation, erosion, and Laplacian high-pass filtering, which are used for gating in Step 1 and for detail compensation of the final segmentation results. Simultaneously, this step calls upon various modules from Step 1 to complete the construction of the backbone network ResUNet.
[0030] Step 3: To improve the robustness of the model and the structural consistency of the segmentation results, a GAN network is introduced. The discriminator adopts a combination of global and local discrimination. Through the adversarial game between the generator and the discriminator, it helps to improve the segmentation accuracy of small targets and complex boundaries.
[0031] Furthermore, step 1 includes the following steps: Step 1.1, Data Preprocessing: First, save the image path using `image_path`, then convert it to grayscale ('L' mode) using `convert`. Finally, resize the image to 256 pixels using the `resize` function. 256. Ensure image dimensions are consistent. Next, call the `relpath` function to obtain the relative path of the image, and save the path as `rel_path`. Based on `rel_path`, obtain the mask path from `mask_dir` (mask directory), and then process it similarly to the image. Use the `array` function from the NumPy library to convert the image and mask into NumPy arrays and normalize them, saving them as `image_np` and `mask_np`. Finally, convert them into Tensor arrays, create a `sample` dictionary to store them, and return it. Encapsulate step 1 into the `HemorrhageDataset` class.
[0032] Step 1.2: Split the dataset: Load the images using the variable `image_paths`, call the `train_test_split` function from the scikit-learn library to split the dataset into training and validation sets in an 8:2 ratio (note: the test set is a separate, new dataset), then call the `HemorrhageDataset` class from Step 1 to process the training and validation sets, saving and returning them as `train_dataset` and `val_dataset`. Define Step 2 as the `load_datasets` function.
[0033] Step 1.3: Load the dataset: Call the `load_datasets` function from Step 2 to divide the dataset and save it as `train_dataset` and `val_dataset`. Then, use the `Dataloader` function from the PyTorch library to create data loaders `train_loader` and `val_loader`, setting `batch_size=4`, `shuffle=True`, and `num_workers=0`.
[0034] Step 1.4: Construct a dynamic multi-scale encoder: Define three different convolutions as branches with different receptive fields at multiple scales. The small_branch branch extracts features from the small receptive field, and the kernel_size is set to 3 (3 3) Set padding to 1 and save the output of this branch using small_out; the medium_branch branch performs feature extraction of the receptive field, and the kernel_size is set to 5 (5 5) Padding is set to 2, and the result of this branch is saved using medium_out; the large_branch branch performs feature extraction with a large receptive field, and kernel_size is set to 3 (3 3) Set padding to 2 and dilation to 2 (dilated convolution), and save the result of this branch using large_brach.
[0035] Step 1.5: Set up boundary gating mechanism: Define the variable `cond_in_channels` and initialize it to the initial input channel `in_channels`. After enabling boundary gating, increment `cond_in_channels` by 1 to ensure that the input dimension and the subsequent concatenation dimension are consistent. Call the `AdaptiveAvgPool2d` function to perform global average pooling on the feature map obtained in Step 1.4, and save it in the variable `gp`. Then, perform global average pooling on the `boundary_mask` (boundary mask map) obtained by the boundary refinement module to obtain boundary features, and save it in the variable `boundary_feat`. Call the `torch.cat` function of the PyTorch library to concatenate the pooled `gp` and `boundary_feat` feature information with `dim=1`.
[0036] Step 1.6: Set up the weight generator: Use two convolutional layers to generate weights. The first layer uses 1... The first layer uses convolutional compression to reduce computational cost. It has `cond_in_channels` as the input channels and `in_channels / 4` as the output channels, then uses the ReLU function for non-linear activation. The second layer uses 1... The convolution with 1 reduces the number of channels again. The input channel is the output channel of the previous layer, and the output channel is 1. The intermediate dimension is mapped to 3 output weights. Softmax (dim=1) is used for normalization to ensure that the sum of the three output weights is 1. These weights are stored in variables w1, w2, and w3.
[0037] Finally, w1 small_out+w2 medium_out+w3 The feature map of the large_out weighted fusion is stored and returned using the fused variable (a four-dimensional tensor).
[0038] Steps 1.4, 1.5, and 1.6 are encapsulated into the DynamicEncoder class.
[0039] Step 1.7: Construct the attention module: Similar to the weight generator in Step 6, this step first calls the AdaptiveAvgPool2d function to perform global average pooling on the input image to extract global features. The first layer uses 1... First, convolutional dimensionality reduction is performed, followed by ReLU nonlinear activation. The second layer uses 1... The convolution with a value of 1 further reduces the dimensionality. Here, the number of output channels is the same as the output channels of each subsequent layer of ResUNet. Finally, the weights are normalized using the sigmoid function and stored in the variable se. The result is x. se (x is the input feature).
[0040] Step 1.7 is encapsulated into the SEBlock class.
[0041] Step 1.8: Build the residual connection module: Determine if the input channel in_channels is equal to the output channel out_channels. If they are not equal, use 1. 1. Convolution changes the number of input channels so that they can be added to the output. Then, BatchNorm2d is used for batch normalization, and the result is stored in the variable `redidual`. If the input channels are equal, no operation is performed. A boolean variable `use_attention` is defined; if True, the `SEBlock` class from step 1.7 is called; if False, the attention mechanism is disabled. A variable `out` is defined to store the feature maps obtained from the two convolutional layers `conv1` and `conv2`. Then, a residual connection is performed, adding the feature maps from `redidual` to `out`. Finally, ReLU is used for non-linear activation, and `out` is returned.
[0042] conv1: The DynamicEncoder class.
[0043] conv2: ConvBlock block, first use 3 3. Convolution is used to extract features, then BatchNorm2d is used for batch normalization, and finally ReLU is called for non-linear activation.
[0044] Step 1.8 is encapsulated into the ResidualBlock class.
[0045] Step 1.9: Encapsulate the encoder and decoder: The encoder sets the `use_boundary_gating` parameter to `True` to enable it and `False` to disable it. First, `MaxPool2d` is called to quickly reduce the spatial size, then the `ResidualBlock` class is called to further perform context modeling and dynamically select receptive fields at low resolution. The decoder calls the `ConvTranspose2d` function to upsample the feature map obtained from the encoder using a convolution with `kernel_size=2` and `stride=2`, increasing the spatial resolution by a factor of 2. Then, for spatial dimension mismatches caused by the upsampling process, the `interpolate` function is called to adjust the resolution through bilinear interpolation. Skip connections are then established, and finally, the concatenated features are fed into `ResidualBlock` for multi-scale receptive field dynamic fusion and boundary gating. `boundary_mask` plays a major role in the decoding stage, using boundary conditions obtained from morphological operations to dynamically adjust the weights of multi-scale branches, enhancing the consistency of local boundaries.
[0046] The encoder is encapsulated as an EncoderBlock class, and the decoder is encapsulated as a DecoderBlock class.
[0047] Furthermore, step 2 includes the following steps: Step 2.1: Construct the boundary refinement module: Input the segmentation probability map seg. First, perform morphological operations on seg, using 3D modeling. MaxPool2d with a capacity of 3 is used to implement the expansion operation. A 3x3 average pooling (AvgPool2d) is used to perform the erosion operation. Subtracting the two values yields an approximate boundary feature, which is stored as a boundary. Positions within this boundary that are greater than zero are identified, and a binary boundary mask (boundary_mask) is generated and saved. Then, a 3x3 average pooling method is applied to the input segment. A Laplacian high-pass filter kernel is constructed using three convolutions to extract high-frequency edge features. These features are then multiplied pixel-by-pixel with the boundary_mask, retaining only valid edge information within the boundary. The retained edge features are then input into a learnable convolutional residual block, sequentially passing through a 3×3 convolution, a ReLU activation function, and a 1×1 convolution to obtain a correction value. This correction value is then added pixel-by-pixel to the original input segment, outputting the refined segmentation result. Finally, refined and boundary_mask are returned for use in branch conditional gating and boundary consistency optimization.
[0048] Step 2.1 encapsulates it into a Boundary class.
[0049] Step 2.2, Input Block and Preliminary Feature Extraction: The original image x is first input into the in_block to extract shallow local features, and the output feature map x1 is used as the basic feature representation in the Encoder stage. The in_block includes 3... 3. Convolution, ReLU activation function, and ResidualBlock, which increases the output channels to 64.
[0050] Step 2.3, Multi-scale feature extraction and boundary mask generation in the Encoder stage: x1 is input into enc1 to obtain x2. enc1 does not use boundary condition gating. x2 is processed by coarse_seg_head. First, convolution and sigmoid activation generate a coarse segmentation probability map, coarse_seg, which is then input into the boundary refinement module in step 2.1 to perform morphological operations and high-pass filtering, generating boundary_mask. Then, x2 and boundary_mask are input into enc2 to obtain x3, and x3 and boundary_mask are input into enc3 to obtain x4.
[0051] enc1, enc2, enc3: Call the EncoderBlock class in step 1.9 of step 1.
[0052] x2, x3, x4: Intermediate feature maps extracted from coding layers of different depths.
[0053] Step 2.4, Decoder Stage Feature Reconstruction and Coarse-to-Fine Cascade Refinement: The deepest encoded feature x4 is input into dec1 and concatenated with the x3 feature output from enc3 using a skip connection. Simultaneously, the boundary_mask is dynamically adjusted via DynamicEncoder to adjust the multi-scale branch weights, outputting the reconstructed feature y1. Then, y1 and x2 are input into dec2 to obtain y2, and y2 and x1 are input into dec3 to obtain y3. After completing the initial feature reconstruction, y3 and coarse_seg are concatenated to form the refine input. Finally, refine is input into refine_block, which refines and compensates for the coarse segmentation result using a learnable residual block, outputting refined_seg.
[0054] refine_block:3 3. Convolution, ReLU nonlinear activation, and ResidualBlock class.
[0055] Step 2.5: Optimize the consistency between the final segmentation output and the morphological boundary: Input refined_seg into the boundary refinement module Boundary to further refine the edge details of refined_seg, and finally output final_out as the final segmentation prediction result of the brain hemorrhage region and return it.
[0056] Furthermore, step 3 includes the following steps: Step 3.1: Input Concatenation and Feature Extraction Backbone Construction: The `cat` function from the `torch` library is used to concatenate the original medical image and the segmentation mask along the channel dimension, forming an input tensor with `in_channels=2` (original image + ground truth segmentation image / predicted segmentation image). This input is processed by a set of 3-layer cascaded convolutional modules to extract multi-layer discriminative features. The intermediate feature maps obtained from the backbone extraction are saved as `feat`, containing multi-scale spatial and texture discrimination information of the target structure.
[0057] The 3-layer cascaded convolution module includes the following: First layer: 4 4 convolutions with a stride of 2 and a base_channels (64) output channel count, activated using LeakyReLU.
[0058] Second layer: 4 4 convolutions with a stride of 2, outputting base_channels 2 (128), Batch normalization and LeakyReLU activation were performed using BatchNorm.
[0059] Third layer: 4 4 convolutions with a stride of 2, outputting base_channels 4 (256), Batch normalization and LeakyReLU activation were performed using BatchNorm.
[0060] Step 3.2, Global Structure Discrimination Branch: Perform global average pooling on the feature map (feat) extracted in Step 3.1, compressing the spatial dimension to 1. 1. Preserve global semantic information. Then use 1 1. Convolution performs channel fusion to generate a scalar output, used to determine the overall structural authenticity of the image segmentation result. This branch outputs global_out, reflecting whether the current output possesses the global consistency characteristics of the true segmentation structure.
[0061] Step 3.3, Local Boundary Discrimination Branch: The feature map *feat* extracted in Step 3.1 is processed using 3... 3. Convolution extracts the coherence of segmentation boundaries and local morphological consistency information in local regions, outputting a local discrimination score map local_out with a spatial dimension similar to the input. This branch is used to capture microscopic deviations in regional boundary details or local morphological anomalies.
[0062] Step 3.4: Adversarial Training of Generator and Trainer: The generator is the network jointly constructed in Steps 1 and 2, and the discriminator is the global + local discriminator constructed in Steps 3.1-3.3 of Step 3. The discriminator outputs `disc_real` for the input combination of the original image and the ground truth segmentation map, and outputs `disc_fake` for the input combination of the original image and the predicted segmentation map. `disc_fake` participates in the adversarial loss of the generator and the discriminator loss, while `disc_real` participates in the discriminator loss. Discriminator warm-up is enabled, allowing the discriminator to participate in discrimination after the 15th iteration of model training.
[0063] Those skilled in the art will understand that the above description is merely a preferred embodiment of the present invention, and the features described in the various embodiments and / or technical solutions of this disclosure can be combined or combined in various ways, even if such combinations or combinations are not explicitly described in this disclosure. This is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
[0064] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended technical solutions are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the present invention. Clearly, those skilled in the art can make various modifications and variations to the present invention without departing from its spirit and scope. Thus, if these modifications and variations of the present invention fall within the scope of the present invention and its equivalents, the present invention also intends to include these modifications and variations.
Claims
1. A dynamic multi-scale medical image segmentation method based on morphological boundary condition gating, characterized in that, The method includes the following steps: Step 1: Obtain CT images of cerebral hemorrhage and preprocess the CT images of cerebral hemorrhage. The preprocessing involves slicing along the z-axis to generate cross-sectional images and performing image enhancement on the cross-sectional images. Step 2: Input the preprocessed cross-sectional image into the segmentation network, which includes: The dynamic multi-branch perception module is used to extract multi-scale features using convolutional branches of different sizes or dilation rates; A branch weight generator is used to dynamically generate the weights of each branch by combining global information of the input image and boundary features extracted by morphological erosion, dilation difference and high-pass filtering, so as to realize multi-scale adaptive adjustment of receptive field driven by local structural conditions. The boundary refinement module is used to extract edge features using morphological methods and Laplacian high-pass filtering, and to correct the edge consistency of the segmentation results through learnable convolutional residuals. Step 3: Combine the dynamic segmentation loss function, assign different penalty weights according to the size of the bleeding area, and introduce a GAN network. Through the joint discrimination of the global discriminator and the local discriminator, the segmentation results are constrained at both the overall structure and local detail levels, thus completing the dynamic multi-scale medical image segmentation based on morphological boundary condition gating.
2. The dynamic multi-scale medical image segmentation method based on morphological boundary condition gating according to claim 1, characterized in that, Step 1, the preprocessing of the CT images of cerebral hemorrhage, also includes dividing the CT image dataset of cerebral hemorrhage into a training set and a validation set, wherein the ratio of the training set to the validation set is 8:
2.
3. The dynamic multi-scale medical image segmentation method based on morphological boundary condition gating according to claim 1, characterized in that, Step 1 also includes the step of building a dynamic multi-scale encoder, which uses three different convolutions as different receptive field branches at multiple scales for feature extraction.
4. The dynamic multi-scale medical image segmentation method based on morphological boundary condition gating according to claim 3, characterized in that, The AdaptiveAvgPool2d function is called to perform global average pooling on the feature map obtained by the dynamic multi-scale encoder and save it in the variable gp. Then, the boundary mask map obtained by the boundary refinement module is performed to perform global average pooling to obtain the boundary features and save them in the variable boundary_feat.
5. The dynamic multi-scale medical image segmentation method based on morphological boundary condition gating according to claim 1, characterized in that, The method for constructing the boundary refinement module in step 2 is as follows: Input a segmentation probability map seg. First, perform morphological operations on the segmentation probability map seg, using 3 Max pooling with a value of 3 is used to implement the expansion operation. The erosion operation is performed using average pooling (3x3). The difference between the two is used to obtain the approximate boundary features, which are stored in a boundary. Positions within this boundary that are greater than zero are identified, and a binary boundary mask (boundary_mask) is generated and stored. Then, the input segment is processed using average pooling (3x3).
3. Convolutional layers are used to construct a Laplacian high-pass filter kernel. High-pass filtering is performed to extract high-frequency edge features. These features are then multiplied pixel-by-pixel with the boundary_mask, retaining only the effective edge information within the boundary. The retained edge features are input into a learnable convolutional residual block, which is then passed through a 3×3 convolution, a ReLU activation function, and a 1×1 convolution to obtain a correction value. This correction value is then added pixel-by-pixel to the original input segmentation probability map seg, and the corrected segmentation result, refined, is output.
6. The dynamic multi-scale medical image segmentation method based on morphological boundary condition gating according to claim 1, characterized in that, Step 3 includes the following steps: Step 3.1: Input splicing and feature extraction backbone construction. The cat function of the torch library is called to splice the original medical image and segmentation mask in the channel dimension to form the input tensor; Step 3.2: Perform global average pooling on the feature map (feat) extracted in Step 3.1, compressing the spatial dimension to 1.
1. Preserve global semantic information, using 1 1. Convolution is used to perform channel fusion to generate a scalar output, which is used to determine the overall structural authenticity of the image segmentation result; Step 3.3: Apply 3 to the feature map feat extracted in step 3.
1.
3. Convolution extracts the coherence and local morphological consistency information of the segmentation boundary in the local region and outputs a local discrimination score map local_out with a spatial dimension similar to that of the input space. This branch is used to capture the regional boundary detail deviation or local morphological anomaly at the micro scale. Step 3.4, Adversarial Training of Generator and Trainer: The generator is the network jointly constructed in Steps 3.1 and 3.2, and the discriminator is the global and local discriminator constructed in Steps 3.1, 3.2, and 3.3 in Step 3. The discriminator outputs disc_real for the input combination of the original image and the real segmentation image, and outputs disc_fake for the input combination of the original image and the predicted segmentation image. disc_fake participates in the adversarial loss of the generator and the discriminator loss, and disc_real participates in the discriminator loss. Discriminator warm-up is enabled, and the discriminator participates in the discrimination after the 15th iteration of training.
7. A computer storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1-6.
8. A computer device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executing the program to implement the method of any one of claims 1-6.
Citation Information
Patent Citations
Prior boundary-fused brain tumor segmentation method
CN113160142A
MRI medical image correction method and system based on convolutional neural network, and computer readable storage medium
CN119963681A
Heart function region modeling method based on deep generative adversarial network
CN120543744A
Medical image segmentation method based on u-shaped network
WO2022199143A1
Computer angiography imaging synthesis method based on multi-scale discrimination
WO2024022485A1
Cited By
Method and device for detecting red and swollen airway mucosa, medium and program product
CN121482001A