Medical image segmentation method and system based on dynamic bidirectional spatial position coding
Patent Information
- Application Number
- CN202611058015.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-16
- Publication Date
- 2026-10-30
AI Technical Summary
[0005]本申请的目的在于提供一种基于动态双向空间位置编码的医学图像分割方法及系统,以解决或缓解上述现有技术中存在的问题
本申请实施例提供的技术方案,构建出医学图像分割模型(DBSPENet),该模型包括空间位置编码模块(SPEM)和动态双向空间位置编码(DBSPE)模块,其中SPEM模块通过对水平与垂直方向的位置编码参数进行独立初始化与解耦建模,适配医学图像中解剖结构的各向异性特征,使模型能够分别感知血管纵向延伸、器官横向分布等不同维度的空间分布特性;在此基础上,进一步构建动态双向空间位置编码(DBSPE)模块,以SPEM作为基础单元构建双分支位置增强路径,并结合卷积分支的语义提取路径,形成位置特征与语义特征的深度耦合机制,实现对任意分辨率图像中精细化空间拓扑信息的捕获与高效表达;医学图像分割模型整体上采用编码器-瓶颈层-解码器架构,将SPEM模块部署于编码器起始端以注入基础双向空间位置信息,将DBSPE模块部署于编码器的最后一个下采样单元、瓶颈层以及解码器的第1个上采样单元等深层特征处理环节,使空间位置信息的增强与位置-语义耦合贯穿于全局特征抽象、特征压缩传递与特征重建的完整编解码流程,使得该模型能够将空间位置信息引入医学图像分割任务,使空间结构线索以动态自适应、双向独立可学习的方式主动参与特征表达全过程,实现局部细粒度信息与长距离依赖关系的有效结合,在感知全局上下文语义的同时保持对边缘细节与空间拓扑结构的高度敏感性,进而能够在处理不同成像模态、不同解剖部位及不同输入分辨率的医学图像时既能保持稳定又能保证分割准确的分割性能,增强了医学图像分割方法在多样化临床应用场景中的鲁棒性与准确性,为计算机辅助诊断与临床治疗方案制定提供了可靠的技术支撑。
Smart Images

Figure CN123015973A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer vision technology, and in particular to a medical image segmentation method and system based on dynamic bidirectional spatial location coding. Background Technology
[0002] Medical image segmentation (MIS) aims to assign semantic labels to each pixel in an image, thereby achieving accurate descriptions of anatomical structures and lesion regions. MIS plays an indispensable and crucial role in computer-aided diagnosis, clinical treatment planning, and drug development. Therefore, the problem of medical image segmentation has received widespread attention. Traditional segmentation methods include thresholding, histogram-based methods, K-means clustering, watershed algorithms, active contour models, graph cut algorithms, conditional Markov random fields, and sparsity-based correlation techniques. However, these methods fail to effectively extract image features, ultimately leading to unsatisfactory segmentation results.
[0003] The development of artificial intelligence technology has propelled convolutional neural networks (CNNs) to become a core technology for medical image segmentation. The UNet series and improved models have further enhanced segmentation accuracy, but the inherent limitations of the local receptive field of convolutional kernels make it difficult to capture long-range dependencies, becoming a key bottleneck for model performance breakthroughs. To overcome the limitations of convolutional operations on local receptive fields, Transformers have been introduced into medical image segmentation tasks, but they incur high computational costs when processing high-resolution images. While the Swin-Transformer can reduce computational cost, it weakens the ability to model global features, and the pure attention mechanism is insufficiently sensitive to local fine-grained features. In recent years, researchers have integrated existing CNNs with Transformer architectures to fully integrate local fine-grained information and long-range dependencies. For example, KW Huang et al. transferred knowledge from the SegmentAnything Model (SAM) to a convolutional neural network student model through semi-supervised knowledge distillation, achieving a paradigm shift in pre-trained knowledge transfer. The GlandSAM model proposed by QX Zhang et al., based on SAM, solves the over-segmentation and under-segmentation problems of SAM in gland segmentation tasks by injecting gland morphology knowledge. It supports unsupervised training and inference, providing a new approach for the application of basic models in medical professional scenarios. XS Li et al. used the hybrid feature extraction unit TransXNetBlock as the encoder and introduced deformable convolution and multi-scale modules into the decoder to enhance the ability to extract local details and edge features. ZY Huang et al. used PVT-v2 as the encoder to carry out global multi-scale feature modeling, and integrated dilated convolution, coordinate attention and self-attention mechanisms to achieve global-local feature alignment, improving the completeness of feature representation. The above articles are all from top journals in the field of medical image segmentation, such as IEEE Transactions on Medical Imaging and Computerized Medical Imaging and Graphics (2025). However, since the above methods do not consider the impact of spatial location information on medical image segmentation tasks, they still have problems in obtaining local fine-grained information and long-distance dependencies.
[0004] In medical image segmentation tasks, spatial relationships are a core prerequisite for determining segmentation accuracy and clinical usability. Spatial information such as the direction of blood vessel bifurcation and the morphology of lesion edges is crucial for the model to achieve accurate segmentation. The lack of such information will lead to distorted segmentation results, failing to meet the actual needs of clinical diagnosis. However, existing medical image segmentation methods generally treat medical images as discrete sets of pixels, relying on the local receptive field of convolutional kernels or self-attention mechanisms to perform pixel-level scanning. This causes these key spatial structural clues to be submerged in homogeneous feature representations, making it difficult to transform them into explicit prior information to guide accurate segmentation. While multilayer perceptrons and Transformers possess the ability to acquire spatial location information, these methods suffer from two inherent drawbacks: First, rigid resolution constraints mean that predefined sinusoidal or learnable location codes only adapt to a single input resolution. When processing high-resolution medical images such as 960×960 fundus images, these fixed codes cannot cover the complete feature space, resulting in the loss of location information in edge regions. Second, unidirectional information fusion means that most existing location codes employ two-dimensional fusion strategies, failing to decouple and separately model the location information in the height and width dimensions. This makes it difficult to accurately capture the anisotropic features of anatomical structures in medical images, such as the longitudinal extension of blood vessels and the lateral distribution of organs. More critically, medical image segmentation tasks have extremely high requirements for dynamic adaptability. Different imaging modalities and anatomical locations exhibit significant differences in image resolution. Fixed-size location codes can lead to over-cropping or under-filling, which not only severely reduces segmentation accuracy but also directly hinders the clinical application of this technology. Summary of the Invention
[0005] The purpose of this application is to provide a medical image segmentation method and system based on dynamic bidirectional spatial location coding, so as to solve or alleviate the problems existing in the prior art.
[0006] To achieve the above objectives, this application provides the following technical solution: This application provides a medical image segmentation system based on dynamic bidirectional spatial location coding, including: The segmentation processing unit is used to segment the medical image to be segmented based on the trained medical image segmentation model and obtain the segmentation result; The medical image segmentation model adopts an encoder-bottleneck layer-decoder architecture, wherein the encoder includes a spatial location encoding SPEM module and multiple downsampling units; The last downsampling unit of the encoder, the bottleneck layer, and the first upsampling unit of the decoder all include a dynamic bidirectional spatial location coding (DBSPE) module, and a DBSPE module is connected after the first upsampling unit of the decoder; wherein the last downsampling unit of the encoder and the first upsampling unit of the decoder correspond to deep feature processing of medical images. The SPEM module is configured to receive a first input feature map, initialize independent learnable horizontal position encoding parameters and vertical position encoding parameters respectively; dynamically and adaptively adjust the horizontal and vertical position encoding parameters according to the actual height and width of the input feature map, and fuse the adjusted parameters with the first input feature map through a residual connection method to output a feature map injected with bidirectional spatial position information. The DBSPE module is configured to receive a second input feature map and process it separately through parallel location enhancement paths and semantic paths to obtain mixed location features and local semantic features. The location enhancement path includes two SPEM branches with independent parameters. Each branch is used to independently perform spatial location encoding enhancement and nonlinear transformation on the second input feature map. The nonlinearly transformed location features are then concatenated and mixed through channels to obtain the mixed location features. The semantic path includes a convolutional branch used to extract local semantic features from the second input feature map. Finally, the DBSPE module concatenates and mixes the mixed location features with the local semantic features through channels to output location-semantic coupled features.
[0007] Preferably, the SPEM module initializes independent learnable horizontal position encoding parameters and vertical position encoding parameters, including: The SPEM module fixes the vertical dimension of the horizontal position encoding parameter to 1 and the horizontal dimension of the vertical position encoding parameter to 1, respectively; it uses a truncated normal distribution to independently initialize the horizontal and vertical position encoding parameters, as shown in the following expression: , In the formula, This indicates a truncated normal distribution. , To initialize the obtained horizontal and vertical position encoding parameters, , These are the actual height and width, respectively.
[0008] Preferably, the SPEM module dynamically and adaptively adjusts the horizontal and vertical position encoding parameters according to the actual height and width of the input feature map, including: , , In the formula, , These are the adaptively adjusted horizontal and vertical position encoding parameters. , The horizontal and vertical position encoding parameters were initialized. For the predefined maximum adaptive size, concat(.) represents the concatenation operation.
[0009] Preferably, the step of fusing the adjusted parameters with the first input feature map via a residual connection to output a feature map infused with bidirectional spatial location information includes: Extend the adjusted parameters to match the first input feature. Figure 1 Batch dimensions and corresponding spatial dimensions: , , Then, the result of batch dimension expansion is added element-wise to the first input feature map to output a feature map infused with bidirectional spatial location information: , In the formula, To inject bidirectional spatial location information into the feature map, , These are the adjusted horizontal and vertical position encoding parameters, respectively, and X is the first input feature map.
[0010] Preferably, before performing position enhancement and semantic extraction in parallel, the DBSPE module transforms the second input feature map in the following manner: , In the formula, The transformed feature map, The second input feature map is used as input. This indicates that the first and second dimensions of the tensor are transposed. For channel dimension, For batch dimension, , These are the height and width of the second input feature map, respectively; The transformed feature map Parallel input is fed into two independent parameter SPEM branches and a convolutional branch to perform positional augmentation and semantic extraction.
[0011] Preferably, in the DBSPE module, the convolutional branches are configured with depthwise convolution and pointwise convolution in sequence; Local semantic features are extracted from the second input feature map through convolutional branches, including: transforming the feature map... The input is fed into the convolutional branch, where depthwise convolution and pointwise convolution are performed sequentially to obtain local semantic features.
[0012] Preferably, the encoder further includes an initial convolutional block located before the SPEM module, which is used to perform convolution processing on the input medical image and output the first input feature map.
[0013] Preferably, the plurality of downsampling units are configured with a max pooling layer; The upsampling unit of the decoder is configured to upsample the input features through a bilinear interpolation layer; The medical image segmentation model also includes a skip connection path, which is configured to concatenate the feature map of the decoder at the current scale with the feature map of the encoder at the corresponding scale by channel dimension. The decoder is connected to a segmentation mapping unit, which is configured to generate a segmentation mask for the medical image through 1×1 convolution.
[0014] This embodiment provides a medical image segmentation method based on dynamic bidirectional spatial location coding. The method is applied to the medical image segmentation system based on dynamic bidirectional spatial location coding provided in any of the above embodiments, and includes the following steps: The trained medical image segmentation model is used to segment the medical image to be segmented, and the segmentation result is obtained. The medical image segmentation model adopts an encoder-bottleneck layer-decoder architecture, wherein the encoder includes a spatial location encoding SPEM module and multiple downsampling units; The last downsampling unit of the encoder, the bottleneck layer, and the first upsampling unit of the decoder all include a dynamic bidirectional spatial location coding (DBSPE) module, and a DBSPE module is connected after the first upsampling unit of the decoder; wherein the last downsampling unit of the encoder and the first upsampling unit of the decoder correspond to deep feature processing of medical images. The SPEM module is configured to receive a first input feature map, initialize independent learnable horizontal position encoding parameters and vertical position encoding parameters respectively; dynamically and adaptively adjust the horizontal and vertical position encoding parameters according to the actual height and width of the input feature map, and fuse the adjusted parameters with the first input feature map through a residual connection method to output a feature map injected with bidirectional spatial position information. The DBSPE module is configured to receive a second input feature map and perform position enhancement and semantic extraction in parallel: it performs spatial position encoding enhancement and nonlinear transformation on the second input feature map through two independent parameter SPEM branches, respectively; it concatenates and mixes the nonlinearly transformed position features to obtain mixed position features; it extracts local semantic features from the second input feature map through a convolution branch; and finally, it concatenates and mixes the mixed position features with the local semantic features to output position-semantic coupled features.
[0015] Beneficial effects: The technical solution provided in this application constructs a medical image segmentation model (DBSPENet). This model includes a Spatial Position Encoding (SPEM) module and a Dynamic Bidirectional Spatial Position Encoding (DBSPE) module. The SPEM module independently initializes and decouples the position encoding parameters in the horizontal and vertical directions to adapt to the anisotropic features of anatomical structures in medical images, enabling the model to perceive spatial distribution characteristics in different dimensions, such as the longitudinal extension of blood vessels and the lateral distribution of organs. Based on this, a Dynamic Bidirectional Spatial Position Encoding (DBSPE) module is further constructed. Using SPEM as the basic unit, a dual-branch position enhancement path is built, and combined with the semantic extraction path of the convolutional branch, a deep coupling mechanism between positional features and semantic features is formed, realizing the capture and efficient expression of refined spatial topological information in images of any resolution. The medical image segmentation model as a whole adopts an encoder-bottleneck layer-decoder architecture, with the SPEM module deployed at the beginning of the encoder to inject basic bidirectional spatial positioning parameters. By incorporating spatial location information, the DBSPE module is deployed in deep feature processing stages such as the last downsampling unit of the encoder, the bottleneck layer, and the first upsampling unit of the decoder. This enhances spatial location information and integrates position-semantic coupling throughout the entire encoding and decoding process of global feature abstraction, feature compression and transfer, and feature reconstruction. This allows the model to introduce spatial location information into medical image segmentation tasks, enabling spatial structural cues to actively participate in the entire feature expression process in a dynamic, adaptive, bidirectional, and independently learnable manner. It achieves an effective combination of local fine-grained information and long-distance dependencies, maintaining high sensitivity to edge details and spatial topology while perceiving global contextual semantics. Consequently, it can maintain stable and accurate segmentation performance when processing medical images with different imaging modalities, anatomical locations, and input resolutions. This enhances the robustness and accuracy of medical image segmentation methods in diverse clinical application scenarios, providing reliable technical support for computer-aided diagnosis and clinical treatment planning. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the structure of the medical image segmentation model (DBSPENet).
[0017] Figure 2 This is a schematic diagram of the SPEM structure.
[0018] Figure 3 This is a schematic diagram of the DBSPE structure.
[0019] Figure 4 This is a schematic diagram of the medical image segmentation results obtained using the method provided in this embodiment.
[0020] Figure 5 This is a schematic diagram illustrating the construction process of DBSPENet according to some embodiments of this application. Detailed Implementation
[0021] The embodiments of this application will now be described with reference to the accompanying drawings.
[0022] Example 1 This embodiment provides a medical image segmentation system based on dynamic bidirectional spatial location coding. The segmentation processing unit is used to segment the medical image to be segmented based on a trained medical image segmentation model (abbreviated as DBSPENet model) to obtain the segmentation result. like Figure 1 As shown, the medical image segmentation model adopts an encoder-bottleneck layer-decoder architecture. The encoder includes a Spatial Positional Encoding Module (SPEM) and multiple downsampling units. The last downsampling unit of the encoder, the bottleneck layer, and the first upsampling unit of the decoder all include a Dynamic Bidirectional Spatial Positional Encoding (DBSPE) module, and a DBSPE module is connected after the first upsampling unit of the decoder; the last downsampling unit of the encoder and the first upsampling unit of the decoder correspond to deep feature processing of medical images. The SPEM module is configured to receive the first input feature map, initialize independent learnable horizontal and vertical position encoding parameters respectively, dynamically adjust the horizontal and vertical position encoding parameters according to the actual height and width of the input feature map, and fuse the adjusted parameters with the first input feature map through residual connection to output a feature map injected with bidirectional spatial position information. The DBSPE module is configured to receive a second input feature map and perform position enhancement and semantic extraction in parallel: it performs spatial position encoding enhancement and nonlinear transformation on the second input feature map through two independent parameter SPEM branches, respectively, and concatenates and blends the nonlinearly transformed position features to obtain the blended position features; it extracts local semantic features from the second input feature map through a convolution branch; finally, it concatenates and blends the blended position features and local semantic features to output position-semantic coupled features.
[0023] In this embodiment, the encoder employs a convolutional neural network (CNN) structure, such as one built upon a UNet network, to extract multi-scale features from the input medical image to be segmented. The medical image to be segmented can originate from imaging modalities commonly used in clinical diagnosis, including but not limited to ultrasound images, endoscopic images, dermoscopic images (such as skin lesion images from the ISIC2018 dataset), fundus retinal images, and glandular tissue pathology images. The medical image to be segmented can be a grayscale image or a color image, and its spatial resolution is not fixed; for example, it can be... Fundus images or The model uses dermoscopic images and employs a dynamic size adaptation mechanism to accommodate inputs of arbitrary resolution. The goal of this application's segmentation task is to assign the correct anatomical structure or lesion region label to each pixel in the image, thereby achieving accurate delineation of regions of interest (such as organ boundaries, blood vessel orientation, tumor regions, etc.).
[0024] In this embodiment, the medical image to be segmented is used as the original input image of the DBSPENet model. Multi-scale feature extraction is performed by the encoder to obtain feature representations at different scales from shallow to deep layers.
[0025] Furthermore, the encoder also includes an initial convolutional block, located before the SPEM module, which performs convolution processing on the input medical image and outputs a first input feature map.
[0026] The encoder has multiple downsampling units configured with max pooling layers; the decoder has upsampling units configured to upsample the input features through bilinear interpolation layers; the medical image segmentation model also includes a skip connection path, which is configured to concatenate the feature map of the current scale of the decoder with the feature map of the corresponding scale of the encoder along the channel dimension; the decoder ends with a segmentation mapping unit, which is configured to generate a segmentation mask for the medical image through 1×1 convolution.
[0027] It should be noted that UNet, as a classic image segmentation framework, holds an important position in the field of medical image segmentation. However, traditional UNet has the following shortcomings: First, in the encoding stage, while consecutive convolutions and max pooling operations can expand the receptive field and extract deep semantic information, they also gradually weaken the spatial location information in the feature maps. For medical images, lesion regions, organ edges, and tissue structures often have significant location dependencies. If the model only focuses on local texture and semantic response without modeling the location of the target, problems such as blurred boundaries, missed detection of small targets, and missegmentation of similar tissues can easily occur. Second, in the deeper layers of the network, due to the multiple downsampling of features, the spatial resolution is significantly reduced. Although the semantic information is richer, the ability to accurately locate the target in space is further weakened. Finally, in the decoding stage, although skip connections can supplement shallow detail information, if the decoding end lacks an effective location-semantic fusion mechanism, it is still difficult to fully recover the boundaries and spatial continuity of complex structures.
[0028] Based on the above analysis, this embodiment introduces the SPEM module and the DBSPE module into the UNet framework to enhance the network's ability to model spatial relationships. The SPEM module is primarily used to inject basic two-dimensional spatial location information into convolutional features in the early stages of the encoder; the DBSPE module further strengthens the dynamic fusion between positional encoding and semantic features in deeper layers of the network and the decoding stage. Both modules act on features at different levels, forming a spatial modeling mechanism that progresses from shallow to deep, from basic positional encoding to dynamic position-semantic coupling. In this embodiment, the overall structure of the proposed medical image segmentation model (DBSPENet) is as follows: Figure 1 As shown, the model consists of an encoder, a bottleneck layer, a decoder, and skip connections. The encoder contains four convolutional stages (the first convolutional stage is only used for feature extraction) and performs feature downsampling step by step through four max pooling operations. The bottleneck layer is located between the encoder and the decoder and is used to fuse the spatial location and semantic information of the deepest features. The decoder consists of three core decoding convolutional stages and performs feature upsampling through four bilinear interpolations. Finally, a 1×1 convolution is used to generate a segmentation result with the same size as the input image.
[0029] Let the input medical image be ,in, Indicates batch size, Indicates the number of channels in the input image. and These represent the height and width of the input image, respectively. In this embodiment, the medical image segmentation model first feeds the input medical image into the encoder for hierarchical feature extraction, where the first... Each encoding stage can be represented as: (1) in, Indicates the first Features output by each encoding stage Indicates the first Each encoding convolutional module consists of convolution, batch normalization, and ReLU activation. It should be noted that when... hour, At this point, only convolution processing is involved. After each encoding stage, max pooling is used to reduce the spatial resolution of the feature map. (2) Max pooling can expand the receptive field of a network, allowing the model to gradually transition from local texture features to higher-level semantic features. However, pooling operations also lead to a loss of spatial location information. To mitigate this issue, in this embodiment, in the encoder's normal... After the convolutional module (i.e. the initial convolutional block), SPEM is introduced. Its function is to inject positional encoding in the height and width directions into the feature map when the feature has just completed local convolution extraction, so that the subsequent downsampling process can not only transmit semantic information, but also retain accurate spatial information.
[0030] Therefore, the process of introducing SPEM into the encoder can be represented as: (3) in, This represents the encoded features enhanced by spatial location coding.
[0031] The SPEM module is placed after the initial convolutional block, rather than after max pooling, for two main reasons: First, the features output by the initial convolutional block still maintain relatively high spatial resolution, allowing for more accurate pixel-level spatial mapping in the image when positional encoding is injected. Second, if pooling is performed before positional encoding, some fine-grained positional information is lost during downsampling, making it difficult to fully recover later. Therefore, integrating SPEM into the convolutional features early in the encoder process helps preserve more accurate spatial structure information before feature compression.
[0032] Functionally, the SPEM module in the encoder primarily serves to enhance basic spatial localization. Traditional convolution focuses more on texture, edge, and grayscale variations within the local neighborhood, while SPEM, through height and width positional encoding, ensures that the features at each spatial location not only contain local semantic responses but also their positional information within the entire feature map. This allows the medical image segmentation model to better distinguish structures with similar textures but different locations during subsequent downsampling, thereby reducing common missegmentation problems in medical images.
[0033] After the encoder undergoes three downsampling operations, the features enter the first DBSPE module in the fourth downsampling unit. This module effectively enhances the acquired positional information. The features then enter the bottleneck layer, located at the deepest part of the network. At this point, the feature map has the smallest spatial size but the strongest semantic information. Traditional UNet bottleneck layers typically only extract high-level semantic features through convolution. This application introduces DBSPE into the bottleneck layer because: after multiple downsampling operations, shallow spatial details are significantly reduced. While deep features have strong semantic expressive power, their precise localization ability is insufficient. If only ordinary convolution is used for deep semantic modeling, the model may struggle to accurately recover the spatial relationships of target boundaries and complex structures. Therefore, introducing DBSPE into the bottleneck layer can re-enhance spatial position modeling at the strongest semantic feature level and fully integrate positional encoding with deep semantic features. The bottleneck layer processing can be represented as follows: (4) in, This represents the deep features after the encoder's fourth downsampling. This represents the bottleneck feature after DBSPE enhancement. DBSPE is placed before the 4th downsampling or at the bottleneck layer because the features at this point already have a large receptive field and can contain richer contextual semantic information. Introducing DBSPE at this stage allows the module to remodel spatial relationships in a global or near-global semantic context, thereby helping the network understand the overall layout between complex anatomical structures.
[0034] Compared to SPEM, DBSPE goes beyond simply injecting positional encoding; it further achieves dynamic coupling between positional and semantic features. Internally, DBSPE obtains complementary spatial location enhancement features through two SPEM-layer MLP branches, while simultaneously extracting local deep semantic features using depthwise convolution and pointwise convolution. Finally, it achieves adaptive fusion of positional and semantic features through channel concatenation and channel mixing. Therefore, DBSPE in the bottleneck layer enables deep features to possess both strong semantic discriminative and spatial localization capabilities, providing a more reliable feature foundation for subsequent decoding stages.
[0035] The main task of the decoder is to progressively recover the spatial resolution of the feature maps and generate the final segmentation result. The decoding stage first uses bilinear interpolation for upsampling: (5) in, This indicates a bilinear interpolation upsampling operation. This represents the output features from the previous decoding stage. Subsequently, the decoder fuses the corresponding scale features from the encoder with the upsampled features through skip connections: (6) in, This represents the encoder features corresponding to the spatial scale of the current decoding stage. This indicates channel-level splicing. Skip connections can pass edge, texture, and spatial detail information preserved in the shallow layers of the encoder to the decoder, thereby compensating for any lack of detail that may occur during upsampling.
[0036] However, relying solely on skip connections still presents problems: while the shallow features of the encoder contain rich boundary details, their semantic level is low; the deep features of the decoder have strong semantic information but lack spatial details. After simple concatenation, without further dynamic fusion mechanisms, the model may not be able to fully utilize the complementary relationships between features at different levels. Therefore, this application introduces a DBSPE module after the first upsampling layer and the upsampling layer in the decoding stage, enabling the decoded features to undergo position-semantic fusion again before convolutional reconstruction. Finally, the high-resolution features output by the decoder are processed... Convolution yields the predicted segmentation map: (7) in, This represents the output features of the last stage decoder. This represents the segmentation result predicted by the network. The purpose of convolution is to map the decoder output features to the number of target class channels without changing the spatial resolution.
[0037] The SPEM module and DBSPE module provided in this embodiment will be described in detail below.
[0038] First, the structure and processing flow of the SPEM module are described.
[0039] As mentioned above, the medical image segmentation model provided in this application adopts an encoder-bottleneck layer-decoder architecture. The encoder first extracts shallow local features (first input feature map) through an initial convolutional block (e.g., a 3×3 convolutional block). Then, the spatial location encoding (SPEM) module models the image location information of the shallow local features. In order to achieve arbitrary size, the SPEM module initializes independent learnable horizontal and vertical location encoding parameters, which are configured to: fix the vertical dimension of the horizontal location encoding parameter to 1 and fix the horizontal dimension of the vertical location encoding parameter to 1, respectively; and use a truncated normal distribution to independently initialize the horizontal and vertical location encoding parameters.
[0040] Then, based on the relationship between the actual height and width of the input feature map and the predefined maximum adaptive size, dynamic size adaptive adjustment is performed on the horizontal and vertical position encoding parameters. The adjustment strategy is as follows: when the actual height or width is greater than the predefined maximum adaptive size, newly generated parameters are concatenated to expand the encoding length; when the actual height or width is not greater than the predefined maximum adaptive size, parameter segments of the corresponding length are truncated. The adaptive horizontal and vertical position encoding parameters are then expanded to match the input feature map. Figure 1 The batch and spatial dimensions are determined, and the feature map is added element-wise to the input feature map through residual connection to output a feature map that fuses bidirectional location information.
[0041] To adapt to the multi-resolution features of medical images and accurately capture key spatial location information, this application proposes a spatial location encoding module for performing tasks such as... Figure 2 The steps shown are as follows: The SPEM module first splits the image horizontally (i.e., height) and vertically (i.e., width), and randomly generates initial orientation and position encoding parameters (including horizontal and vertical directions) according to a truncated normal distribution. Then, it dynamically and adaptively adjusts the initial orientation and position encoding parameters according to the actual size H / W (through expansion or cropping operations), and finally obtains the static parameters of the target H / W dimension.
[0042] It should be noted that the target dimension H / W here refers to the actual height H and actual width W of the first input feature map of the SPEM module, according to... Figure 1 The DBSPENet structure shown can use input feature maps that come from 3×3 convolutional blocks or feature maps input to DBSPE modules. Feature map obtained after conversion The DBSPE module then calls the SPEM module to model arbitrary image location information.
[0043] Specifically, such as Figure 2 As shown, the SPEM module focuses on the image's horizontal (height) dimension through three steps: splitting the horizontal / vertical dimensions, dynamic size adaptation, and orientation encoding fusion. ) and image vertical (width, It dynamically adjusts the size of the encoding parameters in two dimensions to match the actual resolution of the input feature map, and integrates the orientation and position information into the feature map through residual connections, thereby achieving accurate modeling of image position information and improving the accuracy of pixel-level position localization.
[0044] SPEM first splits the height and width dimensions, then initializes the orientation-aware parameters and dynamically adapts the size for the height and width dimensions respectively, and finally performs orientation encoding fusion to achieve accurate modeling of image position information.
[0045] (1) Split the horizontal / vertical dimensions.
[0046] First, horizontal / vertical dimension splitting is performed. Then, independent parameter initialization operations are performed for both the horizontal and vertical directions. The purpose of this is to achieve the desired height. ,width Decoupling modeling of dimensional location information, where... , These are the actual dimensions of the first input feature map. SPEM represents the target height. and target width Initialize independent learnable location encoding parameters separately to avoid mutual interference between location information of different dimensions.
[0047] set up The number of channels in the feature map. For example, a predefined maximum adaptive size, Set to 2048 to cover mainstream medical image resolutions such as 960×960 and 1024×1024.
[0048] Target height The processing involves setting horizontal position encoding parameters. This represents the positional information of each channel at height, and the width dimension is fixed at 1 to achieve directional constraints; for the target width Processing, position encoding parameters Focusing on the width positional information, the height is fixed at 1 to eliminate interference from irrelevant dimensions. Collectively referred to as orientation and position encoding parameters, these parameters are used to ensure the stability of initial values and the convergence of training. All adopt a truncated normal distribution Initialize as shown in the following formula: (8) In the formula, This indicates a truncated normal distribution that follows a normal distribution with a mean of 0 and a variance of 0.02.
[0049] (2) Dynamic size adaptive adjustment.
[0050] Next, a dynamic size adaptive adjustment operation is performed based on the relationship between the actual height and width of the first input feature map and the predefined maximum adaptive size.
[0051] Let the input feature map be ,in Batch Size. SPEM targets the target. and It performs dynamic size adaptation, dynamically adjusts the size of encoding parameters, breaks through the limitations of fixed-size encoding, and meets the positional positioning requirements of medical images of any resolution.
[0052] First, adaptive design for the height dimension. Based on the actual height... and Based on the size relationship, the dimensions of the horizontal position encoding parameters are adaptively adjusted as follows: like Then the initial horizontal position encoding parameters To extend this further, specifically: first, generate a new location encoding parameter according to the same truncated normal distribution. Then With new parameters The positions are concatenated to extend the positional encoding and ensure the consistency of the distribution of the extended positional information. The extended encoding parameters are shown in formula (9). (9) In the formula, concat(.) represents the concatenation operation.
[0053] like Then the parameters Cut to front The positions are matched to the current height to avoid redundant parameters introducing position noise. The encoding parameters are shown in formula (10): (10) This embodiment will be based on and Adjust the expansion / trimming parameters based on the quantitative relationship. Collectively referred to as adaptive adjustment, These are called the adaptive parameters. Indicates before cutting With one parameter and the other dimensions remaining unchanged, the parameter dimensions become: .
[0054] Combining formulas (9) and (10) yields the overall expression for the adaptive adjustment of the height dimension parameter: (11) Next, the adaptive adjustment of the width dimension parameter is performed as follows: The implementation logic for adaptive width is exactly the same as that for the horizontal dimension, only affecting the width. Make corresponding adjustments to the adaptive width dimension position encoding parameters. Depend on and The quantitative relationships are determined as shown in formula (12): (12) Then, the adaptive parameters Extending to input features Figure 1 The batch dimension and spatial dimension, namely the batch B dimension, are the same as those of the batch B dimension. Adjust to be the same as the input feature map The tensor is ensured to be perfectly aligned with the size of the input feature map, as shown in formula (13): (13) in, This represents the tensor expansion operation. It is a full-1 tensor, which ensures that the batch dimension of the expanded positional encoding is consistent with the input feature map.
[0055] Expand the width dimension parameter to the input features. Figure 1 The batch dimension and spatial dimension are determined as shown in formula (14): (14) Finally, directional encoding fusion is performed, which involves element-wise addition of the batch dimension-expanded result to the first input feature map, resulting in a feature map that injects bidirectional spatial location information. .
[0056] In the directional encoding fusion stage, SPEM uses residual connections to adaptively adjust the height and width position encoding parameters (i.e., , The feature map X is element-wise added to the first input feature map X to output a feature map that fuses bidirectional positional information. This achieves precise coupling between directional location information and semantic features. The fusion logic is shown in formula (15): (15) Formula (15) has two advantages in using residual connection for directional encoding fusion: First, it achieves the fusion of location information in a lightweight way, introducing only the computational overhead of element-wise addition (the number of parameters increases by <1%), ensuring the inference efficiency of the module; Second, it avoids destroying the distribution characteristics of the original semantic features, so that the directional location information can participate in end-to-end training through backpropagation, improving the effectiveness of pixel-level location positioning.
[0057] While SPEM can inject two-dimensional spatial positional information into feature maps through positional encoding in the height and width directions, its output mainly relies on residual positional encoding superposition, and the interaction between positional encoding and deep semantic features remains relatively direct. For anatomical structures in medical images that are complex in shape, have blurred boundaries, and exhibit significant spatial distribution differences, simply adding the positional encoding to the input features as residuals may not be sufficient to fully explore the deep correlation between positional and semantic features. To achieve efficient coupling between the extracted spatial positional information and the deep semantic feature extraction module, and to improve the ability of positional information to represent complex anatomical structures, this embodiment designs a Dynamic Bidirectional Spatial Positional Encoding (DBSPE) module based on the SPEM module to enhance the coupling capability between spatial positional encoding and deep semantic features. This module is embedded in the encoder's fourth-level downsampling unit (the last downsampling unit), the bottleneck layer, and the decoder, and its structure is as follows: Figure 3 As shown, the working process of this module can be summarized as follows: through feature format conversion, bidirectional spatial location encoding injection, feature format restoration and deep semantic transformation, the natural integration of location encoding and semantic feature extraction is achieved.
[0058] The DBSPE module is configured to receive the second input feature map and process it separately through parallel position enhancement and semantic paths to obtain the mixed positional features and local semantic features. It should be noted that the second input feature map here refers to all input feature maps of the DBSPE module. For example, it could be the input feature map of the last downsampling unit of the encoder, the input feature map of the bottleneck layer, the input feature map of the first upsampling unit in the decoder, or the input feature map of the DBSPE module directly connected to the first upsampling unit.
[0059] In this embodiment, the location enhancement path includes two SPEM branches with independent parameters. Each branch performs spatial location encoding enhancement and nonlinear transformation on the second input feature map, and performs channel concatenation and channel mixing on the nonlinearly transformed location features to obtain the mixed location features. The semantic path includes a convolutional branch used to extract local semantic features from the second input feature map. Finally, the DBSPE module performs channel concatenation and channel mixing on the mixed location features and local semantic features to output location-semantic coupled features.
[0060] like Figure 3As shown, DBSPE consists of two main paths: the upper path is the location enhancement path, which mainly consists of two SPEM branches with independent parameters, both used for spatial location enhancement modeling. This involves performing spatial location encoding enhancement and nonlinear transformation on the second input feature map, respectively. The nonlinearly transformed location features are then concatenated and mixed to obtain the mixed location features. Each SPEM branch consists of sequentially connected SPEM and layered MLP. The lower path, also known as the semantic path, includes a convolutional branch used to extract local semantic features from the second input feature map. This convolutional branch consists of depthwise convolution and pointwise convolution. Finally, the DBSPE module fuses the two location enhancement features (i.e., the mixed location features) with the local semantic features through channel concatenation and mixing, resulting in output features that possess both spatial localization and semantic discriminative capabilities.
[0061] Let the input of DBSPE be sequence-type features, i.e., the second input feature map be denoted as... ,in, Indicates batch size, Indicates the sequence length. This represents the number of channels. Since the input sequence is obtained by unfolding a two-dimensional feature map, therefore... ,in, and These represent the height and width of the feature map, respectively. To perform spatial location encoding, DBSPE first needs to reconstruct the sequence features into a two-dimensional feature map form: (16) in, The transformed feature map, This represents transposing the first and second dimensions of the tensor to make the channel dimension... Adjust it to the desired position in the feature map format; This indicates a dimension reshaping operation; after this step, we obtain... This transformation restores the original one-dimensional sequence to a two-dimensional spatial feature map with height and width, providing an input basis for the spatial location encoding of subsequent SPEM.
[0062] Subsequently, The data is fed into two parallel SPEM branches, collectively referred to as the location augmentation path, denoted as... and : (17) (18) in, and Both have the same structure, including height-direction position encoding, width-direction position encoding, dynamic scale adaptation, and direction encoding fusion processes. However, they use independent learnable parameters, thus enabling spatial location enhancement of input features from two different parameter spaces.
[0063] In this embodiment, the DBSPE module uses two parallel SPEM branches to construct two complementary spatial location enhancement representations, enabling the model to capture the relationship between spatial location and image structure from different perspectives.
[0064] After SPEM, the output of each branch already contains basic two-dimensional spatial location information. However, the fusion method of SPEM mainly injects the location encoding into the input features by adding residuals, and its expressive power is still mainly linear superposition. In order to further enhance the nonlinear expressive power of the location encoding features and enable the spatial features to be dynamically adjusted according to the input content, DBSPE introduces a Level-MLP after each SPEM branch. The Level-MLP is configured as follows: it receives the features output by the corresponding SPEM branch and inputs them into two parallel MLP sub-branches. Each MLP sub-branch contains a multilayer perceptron MLP, an activation function layer, and another multilayer perceptron MLP in sequence. The outputs of the two MLP sub-branches are added element-wise with the features output by the corresponding SPEM branch. Then, the added features are sequentially subjected to channel concatenation, layer normalization, and channel mixing to output the location features after nonlinear transformation.
[0065] The outputs of the two SPEM branches are as follows: and Use it as input to the layered MLP and execute: (19) (20) in, and These represent the positional characteristics of the nonlinear transformation of the two SPEM branch outputs, also known as the characteristics enhanced by the Dynamic Offset Residual (MLP).
[0066] It should be noted that, as Figure 3 As shown, the layered MLP performs nonlinear transformations through two parallel MLP sub-branches. Each MLP sub-branch includes an MLP-activation-MLP structure, and the two parallel MLP sub-branches respectively process the input features ( / Perform a nonlinear transformation and combine the result of the nonlinear transformation with the input features ( / The element-level addition (residual addition) is performed to retain the original input information. Then, the feature integration is completed through channel concatenation, layer normalization and channel mixing. This design enables each location feature to not only retain the spatial location code injected by SPEM, but also to further learn the dynamic relationship between the location code and the context semantics.
[0067] When the two-way position enhancement feature and After generation, the DBSPE module first concatenates them along the channel dimension: (twenty one) in, This indicates concatenation along the channel dimension. If... and The number of channels is The features after splicing The dimensions are: (twenty two) At this point, the splicing operation merely places the two spatial location enhancement features side by side, without truly establishing the connection between these features. Therefore, DBSPE further adaptively reassembles the spliced features through channel blending operations: (twenty three) in, This indicates a channel blending operation in the position branch, which can be performed by... Convolution, or an equivalent linear mapping, is used to achieve this. This operation does not change the spatial size of the feature map, but rather performs a learnable weighted combination of information from different channels at each spatial location. For any location Its output number Each channel can be represented as: (twenty four) in, Indicates position Batch aisle Enhanced features, Indicates the first The input channel for the first... The weights of each output channel, This indicates the bias term.
[0068] Through this process, the model can automatically learn the complementary relationship between the two SPEM branches and the layered MLP branches, and determine which enhancement channels should be retained, which channels should be weakened, and which channels should be combined to form new spatial representations.
[0069] In parallel with the location enhancement path, the convolutional branch at the bottom of the DBSPE module is used to extract local deep semantic features. While SPEM and layered MLPs can enhance spatial localization capabilities, lesion identification and tissue boundary determination in medical images still rely on local texture, edge, and morphological features. Therefore, the transformed feature map... Simultaneously, both depthwise convolution and pointwise convolution are performed: (25) (26) in, This represents depthwise convolution, used to capture local spatial patterns within each channel; This represents pointwise convolution, i.e. Convolution is used to integrate different semantic responses along the channel dimension. Through this branch, the model can obtain deep semantic features that include edge, texture, and local structural information. .
[0070] DBSPE then augments the location features. With local semantic features Perform channel splicing: (27) at this time, It simultaneously contains two types of information: one type comes from the two SPEM paths above and the layered MLP branches, mainly describing spatial relationships; the other type comes from the bottom convolutional branch, mainly describing local texture and semantic content. However, simple concatenation can only retain two types of features and cannot achieve deep interaction. To truly couple positional and semantic features, DBSPE uses channel blending operations again: (28) in, This represents the channel mixing operation in the final fusion stage. For any spatial location... Its output number Each channel can be represented as: (29) in, The number of channels represents the location-enhanced features. This represents the number of channels for semantic features. The formula shows that each channel in the final output can be determined by both the spatial location channel and the local semantic channel. Therefore, the model can adaptively learn the correspondence between location and semantic structure at each spatial location.
[0071] Finally, to meet the requirements of subsequent deep semantic transformation units for sequential input, DBSPE restores the two-dimensional output features to sequential form: (30) in, This indicates that the two-dimensional space dimension Flattened into sequence dimension , This indicates that the tensor dimension is adjusted to... Ultimately obtained .
[0072] Through the above process, DBSPE achieves a complete process from sequence features to two-dimensional spatial features, from dual-path spatial location enhancement to local semantic extraction, and finally to location-semantic fusion output. Specifically, SPEM is the basic location encoding unit, responsible for completing location modeling in the height and width directions within a single path; DBSPE is an enhanced location-semantic fusion module built on top of SPEM. It obtains complementary location enhancement representations through two independent SPEM branches, then utilizes layered MLP to improve the nonlinear expressive power of location features, and introduces local semantic information through convolutional branches. Finally, DBSPE achieves adaptive coupling of location and semantic features through channel concatenation and channel blending, thereby enhancing the model's ability to represent anatomical structures, lesion boundaries, and spatial distribution relationships in complex medical images.
[0073] It is important to note that the channel concatenation and channel mixing involved in the DBSPE described above are independent three-level operations, each acting on features at different levels, with no functional overlap: The first level is located within the layered MLP following each SPEM branch, used to integrate the features obtained by adding the residuals of the two MLP sub-branches of that branch through channel concatenation, layer normalization, and channel mixing, into a single location feature after nonlinear transformation; the second level is located in the location enhancement path, used to merge the two location features output from the two SPEM branches through their respective layered MLPs through channel concatenation and channel mixing, resulting in a mixed location feature; the third level is located in the final fusion stage, used to merge the mixed location feature with the local semantic features output from the convolutional branch through channel concatenation and channel mixing, achieving location-semantic coupling. In other words, these three levels of operations sequentially complete single-branch internal integration, dual-branch complementary fusion, and location-semantic coupling, and are not a repetition of the same channel concatenation and channel mixing process.
[0074] After completing the DBSPENet construction, in order to obtain the mapping relationship between medical images and segmentation results, it is necessary to set a loss function, which is shown in the following formula.
[0075] (31) In the formula, It is Dice's loss. It is cross-entropy loss. and For balancing parameters, and They were set to 1.0 and 0.5 respectively.
[0076] In this embodiment, DBSPENet is trained using six datasets with different features, data volume, and image resolution: BUSI, CVC-ClinicDB, CVC-ColonDB, ISIC 2018, CHASEDB1, and GlaS.
[0077] The experimental hardware environment consisted of an Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz processor, 64GB of memory, and an NVIDIA RTX4090 graphics card; the software environment consisted of CUDA 11.6, Python 3.8, and PyTorch 1.13.0.
[0078] Model training employs the Adam optimizer combined with a cosine annealing learning rate scheduler, with the minimum learning rate set to 10 for all datasets. -4 When training on the ISIC2018, CVC-ColonDB, and CVC-ClinicDB datasets, the batch size was set to 8; the batch size for the other three datasets was fixed at 4. The total number of training epochs for all datasets was 400. Each dataset was randomly divided into an 80% training set and a 20% validation set.
[0079] Figure 4 The results of medical image segmentation obtained using the method provided in this embodiment are shown. Figure 4 As can be seen, the method provided in this embodiment can accurately segment the target region in medical images, and the boundaries are clear and complete.
[0080] To verify the performance of the medical image segmentation model proposed in this application, the DBSPENet model was compared with existing medical image segmentation models, including the UNet model published in Medical Image Computing and Computer-Assisted Intervention in 2015. The following models were developed: GlandSAM, based on the Segment Anything Model, published in IEEE Transactions on Medical Imaging (a top journal in medical image processing) in 2025; MSDUNet, based on the UNet framework, published in IEEE Transactions on Medical Imaging (a top journal in medical image processing) in 2025; UCTransUNet, based on UNet and Transformer, published at AAAI in 2022; CoBiNet, based on UNet, published in IEEE Transactions on Neural Networks and Learning Systems (a top journal in the field of medical image processing) in 2025; UNeXt, published in Medical Image Computing and Computer Assisted Intervention in 2022; and Rolling-UNet (R-UNet), published in Proceedings of the AAAI Conference on Artificial Intelligence in 2024.
[0081] Table 1 shows a quantitative comparison of the medical image segmentation model provided in this embodiment with existing advanced medical image segmentation models on the ISIC 2018, GlaS, and BUSI datasets, respectively. Table 1 is as follows: Table 1 Comparison of Quantitative Results
[0082] In Table 1, the best quantitative results are shown in bold. As can be seen, the DBSPENet proposed in this embodiment is only slightly inferior to R-UNet (Rolling-UNet, 2024, AAAI) on the HD95 metric of the BUSI dataset, and is superior to existing models on all other metrics.
[0083] Based on the same inventive concept, this embodiment provides a medical image segmentation method based on dynamic bidirectional spatial location coding. This medical image segmentation method based on dynamic bidirectional spatial location coding is applied to the medical image segmentation system based on dynamic bidirectional spatial location coding provided in any of the above embodiments, and includes the following steps: The trained medical image segmentation model is used to segment the medical image to be segmented, and the segmentation result is obtained. The medical image segmentation model adopts an encoder-bottleneck layer-decoder architecture. The encoder includes a spatial location encoding SPEM module and multiple downsampling units. The last downsampling unit of the encoder, the bottleneck layer, and the first upsampling unit of the decoder all include a dynamic bidirectional spatial location coding (DBSPE) module, and a DBSPE module is connected after the first upsampling unit of the decoder; the last downsampling unit of the encoder and the first upsampling unit of the decoder correspond to deep feature processing of medical images. The SPEM module is configured to receive the first input feature map, initialize independent learnable horizontal and vertical position encoding parameters respectively, dynamically adjust the horizontal and vertical position encoding parameters according to the actual height and width of the input feature map, and fuse the adjusted parameters with the first input feature map through residual connection to output a feature map injected with bidirectional spatial position information. The DBSPE module is configured to receive a second input feature map and perform position enhancement and semantic extraction in parallel: it performs spatial position encoding enhancement and nonlinear transformation on the second input feature map through two independent parameter SPEM branches, respectively, and concatenates and blends the nonlinearly transformed position features to obtain the blended position features; it extracts local semantic features from the second input feature map through a convolution branch; finally, it concatenates and blends the blended position features and local semantic features to output position-semantic coupled features.
[0084] like Figure 5As shown, in this embodiment, to obtain a medical image segmentation model, the following steps are included: designing a SPEM, constructing a DBSPE, building a DBSPENet model, and training the DBSPENet model. First, a Spatial Position Encoding Module (SPEM) is designed to decouple height-width encoding and model anatomical anisotropy. Second, based on the designed SPEM, a Dynamic Bidirectional Spatial Position Encoding (DBSPE) module is constructed to capture refined spatial topological information of images at arbitrary resolutions. Then, based on the UNet structure, the designed SPEM and DBSPE are fused to build a network (DBSPENet) for medical image segmentation, achieving effective fusion of local fine-grained information and long-range dependencies. Finally, the DBSPENet is trained by designing a loss function and a robust training strategy to obtain the mapping relationship between the medical image and the segmentation result. This invention innovatively introduces spatial position information into the medical image segmentation task and enhances the robustness and accuracy of the medical image segmentation method in processing images of different resolutions by effectively combining local fine-grained information and long-range dependencies. For a detailed description of the specific execution process of each step, please refer to the medical image segmentation system based on dynamic bidirectional spatial location coding; it will not be repeated here.
[0085] In summary, this application proposes a medical image segmentation system based on dynamic bidirectional spatial location coding and constructs a corresponding DBSPENet model. The dynamic bidirectional spatial location coding module (DBSPE module) achieves decoupled modeling and deep fusion of height and width spatial location information through parallel height and width spatial location encoders. At the same time, it embeds a dynamic size adaptation mechanism, which can adaptively match medical images of different resolutions, solving the problems of edge information loss and orientation confusion in traditional coding methods. Moreover, this module can form an efficient synergy with convolutional neural networks and multilayer perceptrons, and capture long-distance dependencies at the bottleneck layer, thereby effectively realizing the fusion of fine-grained local information and long-distance dependencies, providing explicit prior guidance for accurate segmentation.
[0086] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A medical image segmentation system based on dynamic bidirectional spatial location coding, characterized in that, include: The segmentation processing unit is used to segment the medical image to be segmented based on the trained medical image segmentation model and obtain the segmentation result; The medical image segmentation model adopts an encoder-bottleneck layer-decoder architecture, wherein the encoder includes a spatial location encoding SPEM module and multiple downsampling units; The last downsampling unit of the encoder, the bottleneck layer, and the first upsampling unit of the decoder all include a dynamic bidirectional spatial location coding (DBSPE) module, and a DBSPE module is connected after the first upsampling unit of the decoder; wherein the last downsampling unit of the encoder and the first upsampling unit of the decoder correspond to deep feature processing of medical images. The SPEM module is configured to receive a first input feature map, initialize independent learnable horizontal position encoding parameters and vertical position encoding parameters respectively; dynamically and adaptively adjust the horizontal and vertical position encoding parameters according to the actual height and width of the input feature map, and fuse the adjusted parameters with the first input feature map through a residual connection method to output a feature map injected with bidirectional spatial position information. The DBSPE module is configured to receive a second input feature map and process it separately through parallel location enhancement paths and semantic paths to obtain mixed location features and local semantic features. The location enhancement path includes two SPEM branches with independent parameters. Each branch is used to independently perform spatial location encoding enhancement and nonlinear transformation on the second input feature map. The nonlinearly transformed location features are then concatenated and mixed through channels to obtain the mixed location features. The semantic path includes a convolutional branch used to extract local semantic features from the second input feature map. Finally, the DBSPE module concatenates and mixes the mixed location features with the local semantic features through channels to output location-semantic coupled features.
2. The system according to claim 1, characterized in that, The SPEM module initializes independent learnable horizontal and vertical position encoding parameters, including: The SPEM module fixes the vertical dimension of the horizontal position encoding parameter to 1 and the horizontal dimension of the vertical position encoding parameter to 1, respectively; it uses a truncated normal distribution to independently initialize the horizontal and vertical position encoding parameters, as shown in the following expression: , In the formula, This indicates a truncated normal distribution. , To initialize the obtained horizontal and vertical position encoding parameters, , These represent the actual height and width of the input feature map, respectively.
3. The system according to claim 2, characterized in that, The SPEM module dynamically and adaptively adjusts the horizontal and vertical position encoding parameters based on the actual height and width of the input feature map, including: The dynamic size adaptive adjustment is represented as follows: , , In the formula, , These are the adaptively adjusted horizontal and vertical position encoding parameters. , The horizontal and vertical position encoding parameters were initialized. For the predefined maximum adaptive size, concat(.) represents the concatenation operation.
4. The system according to claim 3, characterized in that, The step of fusing the adjusted parameters with the first input feature map via residual connection to output a feature map injected with bidirectional spatial location information includes: The adjusted parameters are expanded to the same batch dimension and corresponding spatial dimension as the first input feature map: , , Then, the result of batch dimension expansion is added element-wise to the first input feature map to output a feature map infused with bidirectional spatial location information: , In the formula, To inject bidirectional spatial location information into the feature map, , These are the adjusted horizontal and vertical position encoding parameters, respectively, and X is the first input feature map.
5. The system according to claim 1, characterized in that, Before processing the second input feature map separately via parallel location enhancement paths and semantic paths, the DBSPE module transforms the second input feature map in the following manner: , In the formula, The transformed feature map, The second input feature map is used as input. This indicates that the first and second dimensions of the tensor are transposed. For channel dimension, For batch dimension, , These are the height and width of the second input feature map, respectively; The transformed feature map Parallel input is fed into two independent parameter SPEM branches and a convolutional branch to perform positional augmentation and semantic extraction.
6. The system according to claim 5, characterized in that, In the DBSPE module, each of the two independent parameter SPEM branches is sequentially connected to the SPEM module and the layered MLP. The layered MLP is configured to receive the features output by the corresponding SPEM branch and input them into two parallel MLP sub-branches. Each MLP sub-branch sequentially includes a multilayer perceptron MLP, an activation function layer, and another multilayer perceptron MLP. The outputs of the two MLP sub-branches are element-wise added to the features of the corresponding SPEM branch outputs. Then, channel concatenation, layer normalization, and channel mixing are performed on the added features in sequence to output the positional features after nonlinear transformation.
7. The system according to claim 5, characterized in that, In the DBSPE module, the convolutional branches are configured with depthwise convolution and pointwise convolution in sequence; Local semantic features are extracted from the second input feature map through convolutional branches, including: transforming the feature map... The input is fed into the convolutional branch, where depthwise convolution and pointwise convolution are performed sequentially to obtain local semantic features.
8. The system according to claim 1, characterized in that, The encoder also includes an initial convolutional block, which is located before the SPEM module, and is used to perform convolution processing on the input medical image and output the first input feature map.
9. The system according to claim 8, characterized in that, The plurality of downsampling units are configured with a max pooling layer; The upsampling unit of the decoder is configured to upsample the input features through a bilinear interpolation layer; The medical image segmentation model further includes a skip connection path, which is configured to concatenate the feature map of the decoder at the current scale with the feature map of the encoder at the corresponding scale by channel dimension. The decoder is connected to a segmentation mapping unit, which is configured to generate a segmentation mask for the medical image through 1×1 convolution.
10. A medical image segmentation method based on dynamic bidirectional spatial location coding, characterized in that, The method, when applied to the medical image segmentation system based on dynamic bidirectional spatial location coding as described in any one of claims 1 to 9, includes the following steps: The trained medical image segmentation model is used to segment the medical image to be segmented, and the segmentation result is obtained. The medical image segmentation model adopts an encoder-bottleneck layer-decoder architecture, wherein the encoder includes a spatial location encoding SPEM module and multiple downsampling units; The last downsampling unit of the encoder, the bottleneck layer, and the first upsampling unit of the decoder all include a dynamic bidirectional spatial location coding (DBSPE) module, and a DBSPE module is connected after the first upsampling unit of the decoder; wherein the last downsampling unit of the encoder and the first upsampling unit of the decoder correspond to deep feature processing of medical images. The SPEM module is configured to receive a first input feature map, initialize independent learnable horizontal position encoding parameters and vertical position encoding parameters respectively; dynamically and adaptively adjust the horizontal and vertical position encoding parameters according to the actual height and width of the input feature map, and fuse the adjusted parameters with the first input feature map through a residual connection method to output a feature map injected with bidirectional spatial position information. The DBSPE module is configured to receive a second input feature map and perform position enhancement and semantic extraction in parallel: it performs spatial position encoding enhancement and nonlinear transformation on the second input feature map through two independent parameter SPEM branches, respectively; it concatenates and mixes the nonlinearly transformed position features to obtain mixed position features; it extracts local semantic features from the second input feature map through a convolution branch; and finally, it concatenates and mixes the mixed position features with the local semantic features to output position-semantic coupled features.
