Small sample medical image segmentation system and method based on query feature enhancement
Patent Information
- Application Number
- CN202611509659.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-28
- Publication Date
- 2026-10-30
AI Technical Summary
本发明创造所述的基于查询特征增强的小样本医学图像分割系统及方法,注意力增强单元利用查询特征作为显式引导信号,对支持特征进行跨视图的注意力激活与增强,该机制使得支持特征能够动态地适应查询图像的风格与语义上下文,实现了特征空间的高效对齐,从而显著提升了模型在不同模态或差异化较大的器官上的泛化性能;本发明采用区域原型与难例边界原型相结合的多视图原型学习方式,其中,前景区域原型和背景区域原型用于刻画相对稳定的类别语义信息,前景难例边界原型和背景难例边界原型用于刻画前景边界和背景边界中容易发生漏检或误检的困难区域特征,从而提升模型对复杂解剖结构和弱边界区域的表征能力;基于自预测的挖掘机制,通过对比自预测掩码与真实掩码的差异,主动定位模型难以识别的“漏检”与“误检”区域(即弱特征区域),在此基础上经过去噪与精炼处理,生成的难例边界原型,以引导模型更敏锐地识别并学习器官边缘与粘连部位特征,从而缓解医学图像分割中常见的边界平滑过度与细节丢失问题。
Smart Images

Figure CN123015580A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology, and in particular relates to a small sample medical image segmentation system and method based on query feature enhancement. Background Technology
[0002] Medical image segmentation, as one of the key technologies in the field of medical image analysis, aims to accurately identify and depict anatomical or pathological structures of interest from complex medical images. Few-sample image segmentation methods demonstrate their advantages in image processing; their core idea is to utilize features from a small number of supporting samples to guide the segmentation of similar targets in the query image.
[0003] The key to few-shot image segmentation (FSS) methods is mining and learning the similarity features between the support image and the query image. Existing few-shot medical image segmentation methods can be developed along three technical routes: one type enhances the segmentation of the query image by constructing prompts based on the support image, such as using a two-branch structure with an interactive mechanism to achieve explicit guidance between support and query features; another type focuses on establishing a feature-level correspondence between the support image and the query image, mainly through similarity modeling of discriminative features shared by the recognizer, with typical representative methods including attention modules and graph networks; in addition, there is a type of method based on prototype learning, which extracts stable and representative category-level prototypes from the support samples and uses the similarity measure between the prototypes and the query image features to achieve accurate depiction of the target region. Among these methods, the prototype learning-based method uses stable and representative category features for cross-sample matching, which can effectively cope with and handle common situations in medical images such as variable target morphology and category overlap or imbalance, and therefore has become the mainstream method for handling few-shot medical image segmentation tasks.
[0004] However, medical images exhibit significant individual differences and structural heterogeneity. Organ size, shape, location, and texture distribution can vary considerably among different patients; even within the same patient, the boundary morphology and tissue density of the target region can change across different slices, imaging stages, or pathological states. These differences can make it difficult for the prototypes extracted from supporting images to adequately represent the target region in the query image. Existing prototype-based learning methods often employ masked average pooling to generate a single foreground or background prototype. This approach tends to smooth out local details, making it difficult to effectively characterize structural differences within the target region, weak boundary regions, and similar background regions. While some methods construct multiple prototypes, they remain insufficient in prototype selection, boundary difficulty modeling, and foreground-background differentiation representation, easily leading to problems such as missed segmentation, missegmentation, and blurred boundaries.
[0005] Furthermore, existing methods for segmenting small-sample medical images generally employ convolutional networks such as ResNet as feature extractors. While these networks offer advantages in local texture modeling, their ability to model global contextual information and long-range dependencies is limited. In recent years, large-scale visual models and their encoders have demonstrated strong general feature representation capabilities in both natural and medical image tasks; for example, the SAM image encoder can provide rich global semantic information. However, when directly using the output features of a Transformer-based encoder for medical image segmentation, a mismatch may still exist between its spatial granularity and the subsequent prototype construction process based on mask pooling. Further enhancements are needed to improve local spatial continuity and the representation of boundary details.
[0006] Meanwhile, modeling the semantic association between the supporting image and the query image remains a key issue in small-sample medical image segmentation. If the supporting features cannot adaptively adjust according to the semantic context of the current query image, they may be affected by patient differences, slice differences, and imaging differences, resulting in insufficient matching between the constructed prototype and the target region of the query image. Therefore, how to enhance the expressive power of medical image features under the condition of a small number of labeled samples, establish a more effective semantic association between the supporting image and the query image, and construct a multi-view prototype that can simultaneously characterize the semantics of the region and the boundary difficulties are problems that current small-sample medical image segmentation methods urgently need to solve. Summary of the Invention
[0007] In view of this, the present invention aims to provide a small-sample medical image segmentation system and method based on query feature enhancement. By enhancing support features through query features, the system utilizes mask differences to locate difficult-to-segment regions and generate boundary prototypes. Combined with clustering and gridding, the system obtains region prototypes. Finally, based on the similarity matching between the multi-view prototypes and query features, the system achieves accurate segmentation of medical images and effectively improves segmentation performance under small-sample conditions.
[0008] To achieve the above objectives, the technical solution created by this invention is implemented as follows: A query feature enhancement-based few-sample medical image segmentation system is used for image segmentation of medical images. The system includes: a feature encoding and adaptation unit, which encodes the query image to be segmented and the support image used to guide segmentation, respectively, to obtain adapted query features and support features; an attention enhancement unit, which uses the query features to perform multi-head attention-based feature enhancement processing on the support features, resulting in query-enhanced enhanced support features; a hard example boundary prototype generation unit, which uses the enhanced support features and the true support mask of the support features to generate a self-predicted foreground probability map of the support image; and a hard example foreground region that is actually foreground but predicted as background, and a hard example foreground region that is actually background but predicted as background, based on the self-predicted foreground probability map and the true support mask. The system identifies the difficult-example background region as the foreground. Constraints and sampling are applied to both the difficult-example foreground and background regions to obtain corresponding difficult-example foreground and background boundary prototypes. A region prototype generation unit clusters multiple foreground local cluster prototypes in the ground support mask. Based on enhanced support features, attention filtering and fusion are performed on these foreground local cluster prototypes to obtain foreground region prototypes. Based on support features, the background region in the ground support mask is divided into grids to obtain background region prototypes. A segmentation unit calculates the similarity response between each of the two boundary prototypes and two region prototypes and the query feature. Based on the similarity response, the system generates the category probability distribution of the foreground and background in the query image, obtaining the final segmentation result of the query image.
[0009] Furthermore, the feature encoding and adaptation unit includes: a SAM image encoder, which encodes the query image and the support image respectively to obtain the original query features and the original support features; a Token adapter, which performs depth convolution operations on the two features under different receptive fields, and then fuses the multi-receptive field features of the two features to obtain the local structure enhancement features of the receptive fields respectively; and fuses the two local structure enhancement features with the original query features and the original support features to obtain the query features and support features respectively.
[0010] Furthermore, in the attention enhancement unit: the support features are divided into first and second features along the channel dimension; the query features are convolved to obtain the third feature; the second and third features are subjected to depthwise convolution to obtain the query vector and key vector respectively; the first feature is subjected to depthwise convolution and global average pooling operations in sequence, and then the processed features are processed in parallel with two branches; in each branch, the input features are subjected to convolution at different scales in sequence; the features obtained from the two branches are weighted and fused to obtain the value vector; the query vector, key vector, and value vector are rearranged in multiple dimensions, and then the three rearranged vectors are processed by the attention head of the corresponding channel; the features output by the attention head of each channel are fused and then residually fused with the support features to obtain the enhanced support features.
[0011] Furthermore, within the attention head of each channel: based on the query vector and key vector of the corresponding channel, the channel similarity matrix of the current channel is calculated using the following formula: ; Among them, A m This represents the channel similarity matrix of the m-th attention head. and Let Q represent the query vector Q for the m-th attention head. m and bond vector K m The query vector and key vector after normalization along the spatial dimension, τ m This represents the corresponding learning temperature coefficient; based on the supporting features, the channel similarity matrix of the current channel is subjected to Top-k sparse filtering to obtain the corresponding sparse channel similarity matrix; after the sparse channel similarity matrix is processed by softmax, it is multiplied with the value vector of the corresponding channel to obtain the output feature of the attention head of the current channel.
[0012] Furthermore, in the hard example boundary prototype generation unit: the enhanced support features are masked average pooled using the true support mask to generate a global foreground prototype; the global foreground prototype is concatenated with the enhanced support features, and the resulting self-predictive features are decoded to obtain the self-predictive foreground probability map of the support image; the binary self-predictive mask is obtained from the self-predictive foreground probability map using the following formula: ; in, S represents a binary self-predictive mask. s The method represents a self-predicted foreground probability map; it compares the binary self-predicted mask with the true support mask to locate the difficult foreground and difficult background regions; it performs morphological erosion and morphological dilation operations on the true support mask, and then performs difference operations between the true support mask and the corresponding eroded and dilated masks to obtain the foreground side boundary band and background side boundary band; it uses the foreground side boundary band and background side boundary band to constrain the difficult foreground and difficult background regions respectively, and then samples the corresponding difficult foreground boundary candidate regions and difficult background boundary candidate regions to obtain difficult foreground boundary candidate features and difficult background boundary candidate features respectively; based on the true support mask, it performs semantic consistency screening on the difficult foreground boundary candidate features and difficult background boundary candidate features respectively to obtain the difficult foreground boundary prototype and difficult background boundary prototype.
[0013] Furthermore, in the region prototype generation unit, attention filtering and fusion are performed on the foreground local cluster prototypes based on the enhanced support features to obtain the foreground region prototypes. This process includes: calculating the semantic relevance between the enhanced support features and each foreground local cluster prototype to obtain the class attention weight corresponding to each foreground local cluster prototype; using the class attention weight to perform weighted fusion of the foreground local cluster prototypes to obtain the foreground semantic fusion features; and using the true support mask to perform masked average pooling on the foreground semantic fusion features to obtain the foreground region prototypes.
[0014] Furthermore, in the region prototype generation unit, based on support features, the background region in the real support mask is divided into grids to obtain a background region prototype. This process includes: dividing the background region into grids and pooling within each grid region to obtain the initial background region prototype corresponding to each grid region; performing mask average pooling on each initial background region prototype using support features to obtain the corresponding initial background prototype; forming a background prototype set from the obtained initial background prototypes and calculating the autocorrelation matrix of the background prototype set; retaining the elements with strong correlation in the autocorrelation matrix to obtain the background adjustment matrix, and then using the background adjustment matrix to calibrate the background prototype set to obtain the background region prototype.
[0015] Furthermore, in the segmentation unit, the category probability distributions of the foreground and background in the query image are generated based on the similarity responses to obtain the final segmentation result of the query image. This process includes: dividing the two boundary prototypes and two region prototypes into foreground prototypes and background prototypes according to the region categories; weighting and fusing the similarity responses of the corresponding foreground prototypes according to the prototype confidence weights of all foreground prototypes to obtain the foreground response map; weighting and fusing the similarity responses of the corresponding background prototypes according to the prototype confidence weights of all background prototypes to obtain the background response map; concatenating the foreground response map and the background response map, and generating the category probability distribution through the Softmax function; obtaining the final binary segmentation mask of the query image using the following formula to complete the final segmentation of the query image: ; in, M represents the final binary segmentation mask. q This represents the probability distribution of categories.
[0016] A few-sample medical image segmentation method based on query feature enhancement includes: S1: Obtain the medical image dataset and divide the medical images and their corresponding masks into datasets of support images, real support masks of support images, query images, and real query masks of query images. Preprocess the datasets to obtain the training set. S2: Construct a medical image segmentation system as provided in this invention; S3: Using the training set obtained in step S1, train the medical image segmentation system constructed in step S2 according to the few-sample segmentation Episode training paradigm to obtain the medical image segmentation model. S4: Use the medical image to be segmented as the query image and the image with segmentation annotations as the support image; input the query image, support image, and the segmentation mask of the support image into the medical image segmentation model obtained in step S3 to obtain the predicted segmentation result of the image to be segmented.
[0017] Furthermore, in step S3, the medical image segmentation system is trained using the joint loss function of the following formula: L total =λ1L CE +λ2L Dice +λ3L align +λ4L ssp ; Among them, L total L represents the joint loss function. CE L represents the cross-entropy loss between the predicted query mask output by the medical image segmentation system and its corresponding ground truth query mask. Dice L represents the Dice loss between the predicted query mask and its corresponding true query mask. align L represents the prototype alignment loss. ssp λ represents the self-prediction consistency loss, and λ1~λ4 represent the loss weights; The prototype alignment loss is: ; Among them, M s (h,w) represents the element at position (h,w) in the actual support mask, where H and W represent the width and height. and These represent the probabilities that positions (h, w) are predicted as foreground and background when using the query image to predict the support image in reverse; The self-predictive consistency loss is: ; in, and These represent the probabilities of being predicted as foreground and background in the self-predicted foreground probability map, respectively.
[0018] Compared with the prior art, the present invention can achieve the following beneficial effects: This invention creates a few-sample medical image segmentation system and method based on query feature enhancement. The attention enhancement unit uses query features as explicit guiding signals to perform cross-view attention activation and enhancement on supporting features. This mechanism enables supporting features to dynamically adapt to the style and semantic context of the query image, achieving efficient alignment of the feature space and significantly improving the model's generalization performance across different modalities or organs with significant differences. This invention employs a multi-view prototype learning approach combining region prototypes and hard-example boundary prototypes. The foreground region prototype and background region prototype are used to characterize relatively stable category semantic information. The foreground and background difficult-to-identify boundary prototypes are used to characterize the features of difficult regions in the foreground and background boundaries that are prone to missed or false detections, thereby improving the model's ability to represent complex anatomical structures and weak boundary regions. Based on the self-predictive mining mechanism, by comparing the difference between the self-predictive mask and the real mask, the model actively locates the "missed detection" and "false detection" regions (i.e. weak feature regions) that are difficult to identify. On this basis, after denoising and refining, the generated difficult-to-identify boundary prototypes guide the model to more accurately identify and learn the features of organ edges and adhesion sites, thereby alleviating the common problems of boundary smoothing and loss of detail in medical image segmentation. Attached Figure Description
[0019] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments and descriptions of the invention are used to explain the invention and do not constitute an undue limitation of the invention. In the drawings: Figure 1 A schematic diagram of the overall system for small-sample medical image segmentation based on query feature enhancement as described in an embodiment of the present invention; Figure 2 A schematic diagram illustrating the processing procedure of the Token adapter as described in an embodiment of the present invention; Figure 3 A schematic diagram illustrating the processing procedure of the attention enhancement unit described in an embodiment of the present invention; Figure 4 This is a flowchart illustrating the query feature-enhanced small-sample medical image segmentation method described in an embodiment of the present invention. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not constitute a limitation thereof. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0021] In the description of this invention, it should be understood that the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined with "first," "second," etc., may explicitly or implicitly include one or more of that feature. In the description of this invention, unless otherwise stated, "a plurality of" means two or more.
[0022] The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0023] like Figure 1 As shown in the embodiment of the present invention, the query feature-enhanced few-sample medical image segmentation system is used for image segmentation of medical images. It includes a feature encoding and adaptation unit, an attention enhancement unit, a hard example boundary prototype generation unit, a region prototype generation unit, and a segmentation unit. The feature encoding and adaptation unit encodes the query image to be segmented and the support image used to guide segmentation, respectively, to obtain adapted query features and support features. The attention enhancement unit uses the query features to perform multi-head attention-based feature enhancement processing on the support features, obtaining enhanced support features after query enhancement. The hard example boundary prototype generation unit uses the enhanced support features and the true support mask of the support features to generate a self-predicted foreground probability map of the support image; based on the self-predicted foreground probability map and the true support mask, it determines hard example foreground regions that are actually foreground but predicted as background, and hard example background regions that are actually background but predicted as foreground; it constrains and samples the hard example foreground regions and hard example background regions, respectively, to obtain hard example foreground boundary prototypes and hard example background boundary prototypes. The region prototype generation unit clusters multiple foreground local cluster prototypes in the real support mask, and performs attention filtering and fusion on the foreground local cluster prototypes based on enhanced support features to obtain foreground region prototypes. Based on support features, the background region in the real support mask is divided into grids to obtain background region prototypes. The segmentation unit calculates the similarity response between each prototype and the query feature in the two boundary prototypes and two region prototypes; based on the similarity response, it generates the category probability distribution of the foreground and background in the query image to obtain the final segmentation result of the query image. It is understood that the input images (i.e., the query image and the support image) of the system provided by this invention are both medical images.
[0024] In some embodiments, the feature encoding and adaptation unit includes a SAM image encoder and a Token adapter. The SAM image encoder encodes the query image and the support image respectively to obtain the original query features and the original support features. The Token adapter performs depthwise convolution operations on the two features at different receptive fields, and then fuses the multi-receptive field features of the two features to obtain the local structure enhancement features of each receptive field. The two local structure enhancement features are then fused with the original query features and the original support features to obtain the query features and support features.
[0025] In this embodiment of the invention, a frozen SAM encoder based on a Transformer structure is used as the SAM image encoder. Specifically, a pre-trained SAM image encoder is used on the MedSA dataset, and the SAM image encoder parameters are frozen during the training phase following a Highly Efficient Parameter Fine-tuning Strategy (PEFS). The SAM image encoder is mainly based on a Transformer structure, and its output features have strong global semantic representation capabilities. However, when directly used for prototype generation based on mask pooling, the representation of local spatial continuity and boundary details still needs further enhancement. Therefore, this invention inputs the original support features and original query features into a Token adapter for feature adaptation to alleviate the shortcomings of the Transformer structure's output features in terms of local spatial continuity, resulting in mutually adapted support features and query features.
[0026] Since the token adapter processes the original query features and the original supported features in the same way, this embodiment of the invention provides the token adapter's processing procedure for one of the features, such as... Figure 2 As shown, it specifically includes: First, the input feature F is processed by a 1×1 convolution. in Channel compression is performed to obtain the dimensionality-reduced feature F. r : F r =σ(GN(Conv 1×1 (F in ))); Among them, Conv 1×1 denoted as a convolution operation with a kernel size of 1×1, GN represents a grouping normalization operation, and σ represents a nonlinear activation function.
[0027] Subsequently, multiple parallel deep convolutions are used to reduce the dimensionality of the feature F. r Local structure modeling is performed under different receptive fields. The outputs of the three branches are concatenated along the channel dimension and fused through 1×1 convolution to obtain the local structure enhancement feature F. l The process is as follows: F l =Conv1×1 ([σ(BN(DWConv 3×3 (F r )));σ(BN(DWConv 5×5 (F r )));σ(BN(DWConv 7×7 (F r )))]); Among them, DWConv 3×3 DWConv 5×5 and DWConv 7×7 The numbers represent depthwise convolution operations with kernel sizes of 3×3, 5×5, and 7×7, respectively. BN stands for batch normalization, and [;] represents channel concatenation. The 3×3 kernel-sized depthwise convolution focuses on recovering fine textures within each channel, the 5×5 kernel-sized depthwise convolution smooths feature transitions within local regions, and the 7×7 kernel-sized depthwise convolution aims to supplement structural continuity within the neighborhood.
[0028] Finally, the local structural enhancement feature F l With input features F in Perform residual fusion according to the following formula to obtain the adaptation feature F output by the Token adapter. out : F out =F in +α×F l ; Here, α represents the learnable scaling factor, used to control the influence of local structural enhancement features on the original features. In this embodiment of the invention, the learnable scaling factor α is initialized to 0 to ensure that the output features of the pre-trained SAM image encoder are kept as stable as possible during the initial training phase of the system.
[0029] In some embodiments, the feature processing in the attention enhancement unit includes: dividing the support features into a first feature and a second feature along the channel dimension; performing a convolution operation on the query feature to obtain a third feature; performing depthwise convolution on the second feature and the third feature respectively to obtain a query vector and a key vector; performing a hybrid projection process on the first feature to obtain a value vector. The hybrid projection process includes: sequentially performing depthwise convolution and global average pooling on the first feature, and then performing dual-branch parallel processing on the processed features; in each branch, sequentially performing convolution processing on the input features at different scales; performing weighted fusion on the features obtained from the two branches to obtain a value vector; performing multi-head dimensional rearrangement on the query vector, key vector, and value vector, and then performing attention head processing on the three rearranged vectors for the corresponding channels; fusing the features output by the attention heads of each channel after processing, and then performing residual fusion with the support features to obtain enhanced support features. The attention enhancement unit uses the semantic features of the query image as a guiding signal to dynamically filter and enhance the channel signals in the support features that are relevant to the task, thereby suppressing the noise caused by the differences within each segmentation result in the query image.
[0030] The processing procedure of the attention enhancement unit in this embodiment of the invention is as follows: Figure 3 As shown, it specifically includes: First, for the supporting feature F s After performing a 1×1 convolution operation to complete the channel projection, the channel is then divided into the first feature f1 and the second feature f2 along the channel dimension, as shown in the following formula: ; Where Split represents partitioning along the channel dimension; the first feature f1 is used to calculate the support feature F. s With query feature F q The semantic similarity between them is used, and the second feature f2 is used for subsequent weighted aggregation.
[0031] For query feature F q A 1×1 convolution operation is performed to complete channel projection, yielding the third feature f3. The third feature f3 resides in the same channel semantic space as the first feature f1. Depthwise convolutions with a 3×3 kernel are then performed on the second feature f2 and the third feature f3, respectively, to obtain the query vector and key vector. A hybrid projection is then performed on the first feature f1 to obtain the value vector. Depthwise convolution is used to supplement local spatial information, thus preserving certain local structural information before calculating channel similarity.
[0032] The process of performing hybrid projection processing on the first feature f1 specifically includes: performing depthwise convolution with a kernel size of 3×3 on the first feature f1 sequentially, followed by global average pooling, and then performing parallel processing on the processed features in two branches; in each branch, performing convolution with kernel sizes of 3×3 and 1×1 sequentially on the input features; and then weighting and fusing the features obtained from the two branches with weight β to obtain a value vector. It should be noted that although the structures of the two branches are the same, the parameters obtained by each branch are different during actual training, so the two branches are essentially different.
[0033] The query vector, key vector, and value vector are rearranged using a multi-head dimension rearrangement to obtain the query vector Q of the m-th attention head. m Key vector K m Sum vector V m Then, perform attention head processing on the three rearranged vectors for their corresponding channels; finally, process the feature F output by the attention heads of all processed channels. m The concatenated features are then stitched together, and a 1×1 convolution is used to map the stitched features back to the original channel dimensions; finally, the mapped features are compared with the support features F. s Perform residual fusion according to the following formula to obtain enhanced support features. : ; Where M represents the total number of attention heads, and γ represents the learnable scaling factor, which is used to control the impact of query-guided enhancement features on the original support features.
[0034] In some embodiments, the feature processing of the attention head for each channel includes: calculating the channel similarity matrix of the current channel based on the query vector and key vector of the corresponding channel using the following formula: ; Among them, A m This represents the channel similarity matrix of the m-th attention head. and Let Q represent the query vector Q for the m-th attention head. m and bond vector K m The query vector and key vector after normalization along the spatial dimension, τ m This represents the corresponding learning temperature coefficient, used to adjust the scale of the similarity distribution; To suppress redundant channel connections and irrelevant background responses, a Top-k sparse filter is performed on the channel similarity matrix of the current channel based on the supporting features to obtain the corresponding sparse channel similarity matrix. Through the Top-k sparse filter operation, only the query semantic channels that are strongly related to the current supporting channels are retained, thereby reducing the interference of irrelevant channel responses on the supporting feature enhancement process. After normalizing the sparse channel similarity matrix using softmax, it is multiplied by the value vector of the corresponding channel to obtain the output feature of the attention head of the current channel.
[0035] In this embodiment of the invention, the Top-k sparse screening process includes: Global average pooling and nonlinear activation operations are performed on the first feature after gating function processing to obtain the sparse control coefficients ρ, as shown in the following equation: ρ=σ(GAP(g(f1))); Where g represents a lightweight gate function consisting of convolutional layers, and GAP represents the global average pooling operation; Based on the sparsity control coefficient, the number of relevant connections to be retained in the channel similarity matrix is determined by the following formula: ; Where, k m d represents the number of relevant connections for the m-th attention head. m This represents the channel dimension of the m-th attention head. This indicates the rounding up operation; Based on the number of relevant connections, the corresponding channel similarity matrix is subjected to sparse filtering using the following formula: ; Among them, A m,ij Let represent the element in the i-th row and j-th column of the channel similarity matrix of the m-th attention head. This represents the element in the i-th row and j-th column of the sparse channel similarity matrix of the m-th attention head, Top-k. m (A m,i: ) represents the k-th largest value in the i-th row of the channel similarity matrix of the m-th attention head before sparse filtering. m Each element.
[0036] The difficult example boundary prototype generation unit is used to locate the difficult example boundary region based on the prediction bias of the supporting image, and further generate difficult example foreground boundary prototypes and difficult example background boundary prototypes. In some embodiments, the feature process in the difficult example boundary prototype generation unit includes: The enhanced support features are subjected to masked average pooling using the true support mask to generate a global foreground prototype. In this embodiment of the invention, since the spatial dimensions of the true support mask and the enhanced support features are inconsistent, the true support mask is first adjusted to the same spatial dimension as the enhanced support features, and then masked average pooling is performed using the following formula to generate the global foreground prototype: ; in, Represents the global foreground prototype. Indicates enhanced support features The element at position (h,w) in the middle, M s (h,w) represents the true support mask M. s The value at this position, ε, represents the constant term to prevent the denominator from being zero; The global foreground prototype is concatenated with the enhanced support features, and the resulting self-predictive features are decoded to obtain the self-predictive foreground probability map of the support image; in this embodiment of the invention, the global foreground prototype... Extended to enhanced support features Same spatial dimensions, and the resulting features With enhanced support features By concatenating along the channel dimension, the self-predictive feature F is obtained. sp The process is as follows: ; The obtained self-predictive features F sp Decode the image to obtain the supporting image F. s Self-predicted prospect probability map S s In this embodiment of the invention, the self-predictive feature F is specifically calculated using the following formula. sp Decode: S s =D s (FPM(F sp );ξ); Among them, D s (;ξ) represents the support feature decoder consisting of a set of trainable parameters ξ, and FPM represents the feature preprocessing operation, used to perform channel adaptation and preliminary feature enhancement on the input self-predicted features; in this embodiment of the invention, an existing support feature decoder based on the ASPP structure is selected to process the self-predicted features F sp Decoding is performed (from "Jiang, J., Zhang, H., 2025. Concentrate on weakness: Mining hard prototypes for few-shot medical image segmentation. In: Proceedings of the Thirty-Fourth International Joint Conference on Artificial Intelligence. pp. 1242–1250.", the corresponding source code is provided in this file).
[0037] The binary self-predictive mask is obtained from the self-predictive foreground probability map using the following formula: ; in, Represents a binary self-predictive mask, where This indicates that the position (h, w) is predicted as the foreground. This indicates that the location (h, w) is predicted as background; By performing a difference comparison between the binary self-predictive mask and the true support mask, the hard example foreground region and hard example background region are located. In this embodiment of the invention, the difference comparison is performed according to the following formula to obtain the hard example foreground region. and difficult case background area : ; To ensure that the boundary prototypes primarily originate from the vicinity of the target boundary, rather than from all predicted error regions, this invention further constructs foreground-side boundary bands and background-side boundary bands based on the true support mask. Specifically, morphological erosion and morphological dilation operations are performed on the true support mask, and then the true support mask is differentially analyzed with the corresponding eroded and dilated masks to obtain a foreground-side boundary band located inside the target region and close to the target contour, and a background-side boundary band located outside the target region and close to the target contour. The foreground-side boundary band is mainly used to constrain hard-example foreground regions that are actually foreground but predicted as background, and the background-side boundary band is used to constrain hard-example foreground regions that are actually background but predicted as foreground. The difficult example foreground region and difficult example background region are constrained by the foreground side boundary band and background side boundary band, respectively. Then, the corresponding difficult example foreground boundary candidate region and difficult example background boundary candidate region are sampled to obtain the difficult example foreground boundary candidate feature and difficult example background boundary candidate feature. In this embodiment of the invention, the difficult example foreground region and difficult example background region are constrained by the following formula: ; ; in, and These represent the foreground side boundary band and the background side boundary band, respectively. and These represent the candidate regions for the foreground boundary of difficult examples and the candidate regions for the background boundary of difficult examples, respectively. This indicates element-wise multiplication. When the number of effective pixels in the candidate region of the foreground boundary or the candidate region of the background boundary of a difficult example is insufficient, the foreground side boundary band or the background side boundary band can be used as supplementary candidate regions to reduce the possibility of noise introduction in the subsequent prototype sampling process of the difficult example boundary. Based on enhanced support features The following sampling is performed on the candidate regions for the foreground and background boundaries of difficult examples, respectively, to obtain the candidate features for the foreground and background boundaries of difficult examples: ; ; in, and These represent candidate features for the foreground boundary of difficult examples and candidate features for the background boundary of difficult examples, respectively. and These represent the corresponding number of samples, with Sample indicating random sampling. If the number of sampleable features in the candidate region is insufficient, it is supplemented by repeated sampling. Based on the true support mask, semantic consistency screening is performed on the candidate features of the foreground boundary and the background boundary of the difficult example, respectively, to obtain the prototype of the foreground boundary and the prototype of the background boundary of the difficult example.
[0038] To reduce noise samples that may exist in the prediction error region, this embodiment of the invention uses a global foreground prototype and a global background prototype to perform semantic consistency screening on the sampled boundary candidate features. Specifically, the semantic consistency screening process includes: Extract the true support mask M s The background part (1-M) s ), and utilize the background portion (1-M) s Enhanced support features Perform masked average pooling as follows to generate the global background prototype. : ; Candidate features for the foreground boundary of difficult cases are selected using the following formula. Central and global foreground prototypes The cosine similarity between them is higher than the preset foreground threshold θ fg Feature x1 is used to obtain the prototype of the hard case foreground boundary after filtering. : ; Where cos represents the cosine similarity calculation; Candidate features for difficult example background boundaries are selected using the following formula. In the context of the global background prototype The cosine similarity between them is higher than the preset background threshold θ bg The feature x2 is used to obtain the filtered difficult example background boundary prototype. : .
[0039] In this embodiment of the invention, θ fg =θ bg =0.90.
[0040] The region prototype generation unit is used to generate foreground region prototypes and background region prototypes respectively based on the feature distribution differences between the foreground and background regions using a differentiated strategy. Specifically, in some embodiments, the process of obtaining the foreground region prototype in the region prototype generation unit includes: calculating the semantic relevance between the enhanced support features and each foreground local cluster prototype to obtain the class attention weight corresponding to each foreground local cluster prototype; using the class attention weight to perform weighted fusion of the foreground local cluster prototypes to obtain foreground semantic fusion features; and using the true support mask to perform masked average pooling on the foreground semantic fusion features to obtain the foreground region prototype.
[0041] In this embodiment of the invention, the actual support mask M is achieved through the following formula. s Within the defined region, multiple foreground local cluster prototypes are discovered using clustering: ; in, This represents the prototype of the k-th foreground local cluster. Indicates the true support mask M s The mask corresponding to the kth foreground local cluster obtained after clustering; This invention introduces an attention-based filtering mechanism to enhance support features. As features to be matched, the prototypes of each foreground local cluster As a semantic reference, the semantic relevance between each location within the foreground region and the foreground local cluster prototype is calculated. : ; The similarity of different foreground local cluster prototypes is normalized using the Softmax function to obtain the class attention weights; The foreground local cluster prototypes are weighted and fused using class attention weights to obtain foreground semantic fusion features. This process corresponds to the QKV class attention and prototype slice convolution ideas mentioned above, that is, using the foreground local cluster prototypes as semantic references to weighted recombine the foreground regions in the enhanced support features. To reduce the impact of outlier noise in the foreground region on the prototype representation, embodiments of the present invention further filter the foreground region in the true support mask based on the semantic relevance of the foreground similarity map using the following formula: ; Among them, M f II represents the filtered true support mask, and II represents the indicator function. τ represents the similarity between the enhanced support feature at position (h,w) and the k-th foreground local cluster prototype. fThis represents the filtering threshold. This operation is used to retain foreground features that are highly semantically related to the local cluster prototypes in the foreground and to suppress outlier responses in the foreground region. Using the filtered true support mask M f The foreground semantic fusion features are then subjected to masked average pooling as follows to obtain the foreground region prototype: ; Where, p f Represents the prototype of the foreground region. ε represents the foreground semantic fusion feature, and ε represents the constant term to prevent the denominator from being zero.
[0042] For the background region, since the background of medical images typically contains complex information such as adjacent tissues, similar organ structures, and imaging noise, using only a single background prototype for representation can easily lead to insufficient background representation. Therefore, this invention divides the background region into grids based on the support features without query enhancement and the background portion in the true support mask, and performs average pooling within each background grid region to obtain multiple background region prototypes. Specifically, in some embodiments, the process of obtaining background region prototypes in the region prototype generation unit includes: dividing the background region into grids and performing pooling within each grid region to obtain an initial background region prototype corresponding to each grid region; performing masked average pooling on each initial background region prototype using support features to obtain a corresponding initial background prototype; forming a background prototype set from the obtained initial background prototypes and calculating the autocorrelation matrix of the background prototype set; retaining the elements with strong correlation in the autocorrelation matrix to obtain a background adjustment matrix, and then using the background adjustment matrix to calibrate the background prototype set to obtain the background region prototype.
[0043] In this embodiment of the invention, each initial background region prototype is obtained by performing masked average pooling on the following formula: ; in, This represents the initial background prototype corresponding to the j-th grid region. Indicates true support mask M s The mask corresponding to the j-th grid region; The initial background prototype will be obtained. Composition of background prototype set Background Prototype Collection This is used to preserve the spatial distribution differences and texture diversity of the background area; to further decouple the complex background texture distribution, the background prototype set is calculated using the following formula. The autocorrelation matrix A b : ; Where Norm represents the normalization operation, and the autocorrelation matrix A b Used to describe the degree of correlation between different channels in the background prototype; To eliminate redundant channel dependencies, this embodiment of the invention introduces a sparse channel mask M. sparse Specifically, the sparse channel mask M sparse For autocorrelation matrix A b Binary matrices of the same dimension, both having dimensions D×D, where D represents the number of feature channels and M is the sparse channel mask. sparse The rules for the values of elements at each position in the table satisfy the following relationship: ; Where (i,j) represents the position index of the element in the matrix, corresponding to the i-th and j-th feature channels, and r represents the preset neighborhood radius, used to control the range of retained associations between channels. In this embodiment of the invention, the preset neighborhood radius r=1, that is, only the associations of each channel itself and its left and right adjacent channels are retained. At this time, the sparse channel mask presents a tri-diagonal band structure: the main diagonal element (i=j) and the upper and lower adjacent secondary diagonal elements (|ij|=1) are 1, and the elements at other positions are 0; The background adjustment matrix is obtained by retaining the elements with strong correlations in the autocorrelation matrix using the following formula. : ; Where μ represents the learnable adjustment coefficient; Adjust the background matrix With background prototype collection Multiply, as shown in the following formula, to complete the background adjustment matrix. For the background prototype set The calibration yields the prototype p of the background region. b : .
[0044] Through the above processing, the background region prototype can suppress redundant background responses while preserving background diversity, and improve the ability to distinguish similar tissues and complex background regions outside the target.
[0045] The foreground region prototype obtained by the region prototype generation unit focuses on maintaining the stable semantic expression of the target subject region, while the background region prototype focuses on depicting the complex texture distribution of non-target regions. Together with the aforementioned foreground hard example boundary prototype and background hard example boundary prototype, they form a multi-view prototype set.
[0046] In some embodiments, the segmentation unit generates the category probability distributions of the foreground and background in the query image based on the similarity response to obtain the final segmentation result of the query image. This process includes: Based on region categories, the two boundary prototypes and the two region prototypes are divided into foreground prototypes and background prototypes; Based on the prototype confidence weights corresponding to all foreground prototypes, the similarity responses of the corresponding foreground prototypes are weighted and fused to obtain the foreground response map. Based on the prototype confidence weights corresponding to all background prototypes, the similarity responses of the corresponding background prototypes are weighted and fused to obtain the background response map. The foreground response map and background response map are stitched together, and the category probability distribution is generated by using the Softmax function; The final binary segmentation mask of the query image is obtained using the following formula, thus completing the final segmentation of the query image: ; in, M represents the final binary segmentation mask. q This represents the probability distribution of categories.
[0047] In this embodiment of the invention, the data processing procedure in the segmentation unit includes: The foreground boundary prototype of the difficult example obtained above Difficult example foreground boundary prototype Foreground region prototype p f and background area prototype p b By concatenating the prototypes along the dimension of quantity, we obtain a multi-view prototype set P. all As shown in the following formula: ; The query feature F is calculated using the following formula. q With the multi-view prototype set P all The cosine similarity between the prototypes is used to obtain the original similarity response: ; in, Represents a multi-view prototype set P all The nth prototype With query feature F q Cosine similarity between them; Multi-view prototype set P is sorted by region category all The prototypes in the model are divided to obtain the foreground prototype set P. fg and background prototype set P bg ; respectively set the foreground prototype set P fg and background prototype set P bg The corresponding similarity responses are adaptively weighted and fused along the prototype dimension as follows to obtain the foreground response map. and background response map : ; ; Foreground response map Background response map The data is concatenated along the channel dimension to obtain dual-channel category response features; normalization is performed along the category channel dimension using the Softmax function to generate a pixel-level binary classification probability distribution; then, the final binary segmentation mask of the query image is obtained through category index extraction, completing the semantic segmentation of the query image. The above process is as follows: .
[0048] This invention also provides a few-sample medical image segmentation method based on query feature enhancement, combined with Figure 1 and Figure 4 ,include: S1: Obtain the medical image dataset and divide the medical images and their corresponding masks into datasets of support images, real support masks of support images, query images, and real query masks of query images. Preprocess the datasets to obtain the training set.
[0049] In this embodiment of the invention, the existing publicly available Synapse-CT, CHAOS-MRI, and CMR datasets are mixed to obtain the medical image dataset used in this embodiment of the invention, thereby improving the robustness of model training. Furthermore, to adapt to the model input, this embodiment of the invention divides the three-dimensional medical image into two-dimensional slices along the axis and uniformly adjusts the two-dimensional slices to a preset resolution; subsequently, it performs normalization processing so that the pixel values are distributed within the [0,1] interval.
[0050] S2: Construct a medical image segmentation system as provided in this invention.
[0051] S3: Using the training set obtained in step S1, train the medical image segmentation system constructed in step S2 according to the few-sample segmentation Episode training paradigm to obtain the medical image segmentation model.
[0052] To enable end-to-end training of the model, this invention constructs a joint loss function to collaboratively constrain the query image segmentation results, the support image self-prediction results, and the support-query prototype consistency. Specifically, in some embodiments, the medical image segmentation system is trained using the following joint loss function: L total =λ1L CE +λ2L Dice +λ3L align +λ4L ssp ; Among them, L total L represents the joint loss function.CE L represents the cross-entropy loss between the predicted query mask output by the medical image segmentation system and its corresponding ground truth query mask. Dice L represents the Dice loss between the predicted query mask and its corresponding true query mask. align L represents the prototype alignment loss. ssp λ1~λ4 represent the self-prediction consistency loss, and λ1~λ4 represent the loss weights. In this embodiment of the invention, λ1=λ2=λ3=1, λ4=0.3.
[0053] The prototype alignment loss is: ; Where H and W represent width and height, and represents the probability that position (h, w) is predicted as foreground and background when using the query image to predict the support image. This loss can constrain the prototype representation between the support image and the query image to remain consistent, reducing the impact of the difference in support-query feature distributions on the segmentation results.
[0054] The self-prediction consistency loss is calculated based on the self-prediction results of the support images in the hard example boundary prototype generation unit, providing stable prediction bias information for hard example boundary region localization. Specifically, the self-prediction consistency loss is: ; in, and and represent the probabilities of being predicted as foreground and background respectively in the self-predicted foreground probability map. This loss does not directly affect the final query image segmentation result, but is used to improve the reliability of the self-predicted mask supporting the image, making the localization of missed and false detection regions more stable.
[0055] In this embodiment of the invention, the cross-entropy loss L CE Specifically: ; Where Mq(h,w) represents the value of the actual query mask at position (h,w). and Let represent the probability that position (h, w) is predicted as foreground or background. This loss is used to measure the difference between the pixel-level prediction of the query image and the true mask.
[0056] In this embodiment of the invention, the Dice loss specifically L Dice for: .
[0057] By introducing Dice loss, the impact of the imbalance in the number of pixels in the foreground and background regions of medical images on model training can be mitigated.
[0058] Furthermore, in this embodiment of the invention, the PyTorch framework can be used to construct the training and training model. The optimizer used in the training process is the SGD or AdamW optimizer, with a batch size of Batch_size=1, an initial learning rate of 1e-3, a learning rate decay of 0.0005, and a training iteration count of epoch=100. In other embodiments, the above training hyperparameters can be preset and modified according to the size of the medical image dataset and the memory conditions.
[0059] S4: Use the medical image to be segmented as the query image and the image with segmentation annotations as the support image; input the query image, support image, and the segmentation mask of the support image into the medical image segmentation model obtained in step S3 to obtain the predicted segmentation result of the image to be segmented.
[0060] It should be understood that the various forms of processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this invention disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this invention can be achieved, and this is not limited herein.
[0061] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A query feature-enhanced few-sample medical image segmentation system for segmenting medical images, characterized in that, include: The feature encoding and adaptation unit encodes the query image to be segmented and the support image used to guide the segmentation, respectively, to obtain the matching query features and support features. The attention enhancement unit uses query features to perform multi-head attention-based feature enhancement processing on support features, resulting in enhanced support features after query enhancement. The difficult example boundary prototype generation unit generates a self-predicted foreground probability map of the support image by using enhanced support features and the true support mask of the support features; based on the self-predicted foreground probability map and the true support mask, it determines the difficult example foreground region that is actually foreground but is predicted as background, and the difficult example background region that is actually background but is predicted as foreground. Constraints and sampling are performed on the foreground region and background region of the difficult example respectively to obtain the foreground boundary prototype and background boundary prototype of the difficult example. The region prototype generation unit clusters multiple foreground local cluster prototypes in the real support mask. Based on enhanced support features, it performs attention filtering and fusion on these foreground local cluster prototypes to obtain the foreground region prototype. Support features are used to divide the background region in the real support mask into a grid to obtain the background region prototype; The segmentation unit calculates the similarity response between each of the two boundary prototypes and two region prototypes and the query feature; based on the similarity response, it generates the category probability distribution of the foreground and background in the query image, and obtains the final segmentation result of the query image.
2. The small-sample medical image segmentation system based on query feature enhancement according to claim 1, characterized in that, The feature encoding and adaptation unit includes: The SAM image encoder encodes the query image and the support images respectively to obtain the original query features and the original support features; The Token adapter performs depthwise convolution operations on the two features at different receptive fields, then fuses the multi-receptive field features of the two features to obtain the local structure enhancement features of each receptive field. The two local structure enhancement features are then fused with the original query features and the original support features to obtain the query features and support features.
3. The small-sample medical image segmentation system based on query feature enhancement according to claim 1, characterized in that, In the attention enhancement unit: The supporting features are divided into first features and second features along the channel dimension. The query features are convolved to obtain the third feature. The second and third features are then subjected to depthwise convolution to obtain the query vector and key vector, respectively. The first feature is sequentially processed by depthwise convolution and global average pooling, and then the processed feature is processed in parallel with two branches. In each branch, the input feature is sequentially processed by convolution at different scales. The features obtained from the two branches are weighted and fused to obtain a value vector. The query vector, key vector, and value vector are rearranged in multiple dimensions, and then the attention head processing of the corresponding channels is performed on the three rearranged vectors. The features output from the attention head of each channel after processing are fused together, and then residual fusion is performed with the support features to obtain the enhanced support features.
4. The small-sample medical image segmentation system based on query feature enhancement according to claim 3, characterized in that, In the attention head of each channel: Based on the query vector and key vector of the corresponding channel, the channel similarity matrix of the current channel is calculated using the following formula: ; Among them, A m This represents the channel similarity matrix of the m-th attention head. and Let Q represent the query vector Q for the m-th attention head. m and bond vector K m The query vector and key vector after normalization along the spatial dimension, τ m This represents the corresponding learning temperature coefficient; Based on the supporting features, the channel similarity matrix of the current channel is subjected to Top-k sparse filtering to obtain the corresponding sparse channel similarity matrix; After performing softmax processing on the sparse channel similarity matrix, it is multiplied with the value vector of the corresponding channel to obtain the output feature of the attention head of the current channel.
5. The small-sample medical image segmentation system based on query feature enhancement according to claim 1, characterized in that, In the difficult example boundary prototype generation unit: The enhanced support features are masked average pooling using the true support mask to generate a global foreground prototype. The global foreground prototype is concatenated with the enhanced support features, and the resulting self-predictive features are decoded to obtain the self-predictive foreground probability map of the support image. The binary self-predictive mask is obtained from the self-predictive foreground probability map using the following formula: ; in, S represents a binary self-predictive mask. s This represents a self-predicted prospect probability diagram; By comparing the binary self-predictive mask with the true support mask, the hard example foreground region and hard example background region are located. Morphological erosion and morphological dilation operations are performed on the real support mask. Then, the real support mask is subtracted from the corresponding eroded and dilated masks to obtain the foreground and background side boundary bands. The foreground and background regions of difficult examples are constrained by the foreground and background side boundary bands, respectively. Then, the corresponding candidate regions of the foreground and background boundaries of difficult examples are sampled to obtain the candidate features of the foreground and background boundaries of difficult examples. Based on the true support mask, semantic consistency screening is performed on the candidate features of the foreground boundary and the background boundary of the difficult example, respectively, to obtain the prototype of the foreground boundary and the prototype of the background boundary of the difficult example.
6. The small-sample medical image segmentation system based on query feature enhancement according to claim 1, characterized in that, In the region prototype generation unit, attention filtering and fusion are performed on the foreground local cluster prototypes based on enhanced support features to obtain the foreground region prototypes. This process includes: Calculate the semantic relevance between the enhanced support features and each foreground local cluster prototype to obtain the class attention weight corresponding to each foreground local cluster prototype; We use class attention weights to perform weighted fusion of foreground local cluster prototypes to obtain foreground semantic fusion features; The foreground semantic fusion features are masked and averaged using the real support mask to obtain the foreground region prototype.
7. The small-sample medical image segmentation system based on query feature enhancement according to claim 1, characterized in that, In the region prototype generation unit, based on support features, the background region in the real support mask is divided into grids to obtain the background region prototype. This process includes: The background region is divided into grids, and pooling is performed within each grid region to obtain the initial background region prototype corresponding to each grid region; Each initial background region prototype is masked average pooling using supporting features to obtain the corresponding initial background prototype. The initial background prototypes are combined into a background prototype set, and the autocorrelation matrix of the background prototype set is calculated. The background adjustment matrix is obtained by retaining the elements with strong correlation in the autocorrelation matrix. The background prototype set is then calibrated using the background adjustment matrix to obtain the background region prototype.
8. The small-sample medical image segmentation system based on query feature enhancement according to claim 1, characterized in that, In the segmentation unit, the class probability distributions of the foreground and background in the query image are generated based on the similarity response to obtain the final segmentation result of the query image. This process includes: Based on region categories, the two boundary prototypes and the two region prototypes are divided into foreground prototypes and background prototypes; Based on the prototype confidence weights corresponding to all foreground prototypes, the similarity responses of the corresponding foreground prototypes are weighted and fused to obtain the foreground response map. Based on the prototype confidence weights corresponding to all background prototypes, the similarity responses of the corresponding background prototypes are weighted and fused to obtain the background response map. The foreground response map and background response map are stitched together, and the category probability distribution is generated by using the Softmax function; The final binary segmentation mask of the query image is obtained using the following formula, thus completing the final segmentation of the query image: ; in, M represents the final binary segmentation mask. q This represents the probability distribution of categories.
9. A few-sample medical image segmentation method based on query feature enhancement, characterized in that, include: S1: Obtain the medical image dataset and divide the medical images and their corresponding masks into datasets of support images, real support masks of support images, query images, and real query masks of query images. Preprocess the datasets to obtain the training set. S2: Construct the medical image segmentation system as described in any one of claims 1 to 8; S3: Using the training set obtained in step S1, train the medical image segmentation system constructed in step S2 according to the few-sample segmentation Episode training paradigm to obtain the medical image segmentation model. S4: Use the medical image to be segmented as the query image and the image with segmentation annotations as the supporting image; Input the query image, supporting images, and the segmentation mask of the supporting images into the medical image segmentation model obtained in step S3 to obtain the predicted segmentation result of the image to be segmented.
10. The few-sample medical image segmentation method based on query feature enhancement according to claim 9, characterized in that, In step S3, the medical image segmentation system is trained using the joint loss function of the following formula: L total =λ1L CE +λ2L Dice +λ3L align +λ4L ssp ; Among them, L total L represents the joint loss function. CE L represents the cross-entropy loss between the predicted query mask output by the medical image segmentation system and its corresponding ground truth query mask. Dice L represents the Dice loss between the predicted query mask and its corresponding true query mask. align L represents the prototype alignment loss. ssp λ represents the self-prediction consistency loss, and λ1~λ4 represent the loss weights; The prototype alignment loss is: ; Among them, M s (h,w) represents the element at position (h,w) in the actual support mask, where H and W represent the width and height. and These represent the probabilities that positions (h, w) are predicted as foreground and background when using the query image to predict the support image in reverse; The self-predictive consistency loss is: ; in, and These represent the probabilities of being predicted as foreground and background in the self-predicted foreground probability map, respectively.
