An improved target segmentation method for few-shot medical images
By introducing independent prototype self-attention and cross-prototype attention modules and optimizing foreground and background prototypes, the segmentation problems of few samples and cross-domain datasets in medical image segmentation are solved, and high-precision and robust medical image segmentation is achieved.
Patent Information
- Application Number
- CN202411776989.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2044-12-05
AI Technical Summary
Existing medical image segmentation methods, when faced with few samples, find it difficult to effectively handle the diversity within the target area, the differences between foreground and background, and the differences between cross-domain datasets, resulting in insufficient segmentation accuracy and robustness, especially in complex backgrounds.
Independent prototype self-attention modules and cross-prototype attention modules are introduced to optimize the foreground and background prototypes through the self-attention mechanism, and the multi-head attention mechanism is combined to learn the differences between the foreground and background. The query image features are updated through the iterative optimization mechanism to achieve high-precision segmentation.
The accuracy and robustness of medical image segmentation have been significantly improved, especially under conditions of few samples and complex backgrounds, with the segmentation accuracy increased by more than 10%. The iterative optimization mechanism has further improved the segmentation accuracy by 15% to 20%, and has demonstrated better generalization capabilities on cross-domain datasets.
Smart Images

Figure CN119722604B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of medical image segmentation, and in particular to an improved few-sample medical image target area segmentation method. Background Art
[0002] Medical image segmentation is a crucial component of medical image processing, widely used in fields such as computer-aided diagnosis, surgical planning, and treatment planning. Its goal is to automatically identify and segment specific anatomical structures in medical images, thereby providing physicians with accurate diagnostic information and treatment recommendations. In recent years, with the rapid development of deep learning technology, deep learning-based medical image segmentation methods have gradually become mainstream and have achieved remarkable results on a variety of medical imaging datasets.
[0003] Early medical image segmentation methods were usually based on low-level image features (such as grayscale, texture, shape, etc.). Due to the complexity and variability of medical images, these traditional methods often have suboptimal segmentation performance when faced with medical images with high noise, low contrast, and complex morphology.
[0004] With the advancement of computer hardware performance, deep learning, particularly convolutional neural networks (CNNs), has demonstrated powerful feature extraction and representation capabilities in the field of computer vision. While deep learning technology has made significant progress in medical image segmentation, its limitations, which rely on large amounts of labeled data, are becoming increasingly apparent. The labeling process for medical image data is not only time-consuming and labor-intensive, but also requires the involvement of a large number of professionals, making it difficult to obtain large amounts of high-quality labeled data.
[0005] To address the aforementioned data scarcity issue, few-shot learning methods have been proposed and have gradually become a research hotspot. Few-shot learning utilizes a small amount of labeled or unlabeled data to train models with strong generalization capabilities. By extracting foreground and background prototypes from a small number of support images, these prototypes are used to guide the segmentation of new images. For example, models such as PANet and SSL-ALPNet use different strategies to generate and optimize prototypes, thereby improving the performance of few-shot segmentation. These models use feature extraction networks to extract features from the support set images and generate foreground and background prototypes. These prototypes are then matched with the features of the query image to achieve accurate image segmentation.
[0006] Although few-shot learning methods have alleviated the problem of scarce labeled data to a certain extent, they still face many challenges in practical applications:
[0007] The features of the target area in medical images are usually not distinct enough, which makes the labeling process complex and difficult. Especially under the condition of few samples, traditional supervised learning algorithms are unable to effectively cope with this challenge.
[0008] Medical image processing faces a serious data scarcity problem. It is difficult to obtain high-quality datasets with detailed pixel-level annotations, which restricts the performance improvement of existing segmentation algorithms.
[0009] Existing technologies are inadequate in dealing with the diversity within the target area and the differences between the target area and the background, resulting in segmentation accuracy that is difficult to meet clinical needs. This problem is particularly prominent when the distinction between foreground and background is complex.
[0010] The significant differences between cross-domain datasets further increase the difficulty of information transfer between support images and query images, resulting in unsatisfactory segmentation results. Summary of the Invention
[0011] In response to the shortcomings and deficiencies in the existing technology, the present invention introduces few-sample learning and prototype attention mechanism to improve the segmentation accuracy and robustness of the target area, thereby achieving efficient and accurate segmentation of medical images, and solving the challenges faced by current technology with an improved few-sample medical image target area segmentation method.
[0012] To achieve the above objectives, the present invention is implemented through the following technical solutions: the improved few-sample medical image target area segmentation method provided by the present invention includes support set processing, prototype production and optimization, cross-prototype learning and optimization, and query set processing and segmentation, and introduces independent prototype self-attention modules and cross-prototype attention modules to perform refined learning and optimization of foreground prototypes and background prototypes in the support set image, thereby enhancing the model's ability to segment complex medical images under few-sample conditions.
[0013] Preferably, the specific steps include:
[0014] S1 support set feature extraction: Using the support prototype generation module, the feature extractor extracts high-dimensional features from the support set image, and then the prototype generator generates the initial prototypes of the foreground and background of the support image;
[0015] S2 Prototype Generation and Optimization: Using an independent prototype self-attention module, the self-attention layer is optimized for the preliminary foreground and background prototypes of the support image generated in step S1. By capturing subtle differences within the prototypes, the ability to handle intra-class diversity is improved, thereby enhancing their expressive power, allowing the prototypes to better express the core features of the support set categories.
[0016] S3 Cross-prototype learning and optimization: Using the cross-prototype attention module, the foreground and background differences of the support image are learned. Through the multi-head attention mechanism, the foreground and background prototypes of the support image optimized in step S2 are cross-matched.
[0017] By exploring the relationship between the supporting foreground and background prototypes, learning the difference knowledge between the foreground prototype and the background prototype for modeling, learning the correlation features between them, and effectively transferring the features to the query foreground and background, continuously iteratively updating, and gradually optimizing the foreground and background feature prototypes in the query image;
[0018] S4 query set processing and segmentation: Iterative segmentation of the query image, applying the optimized foreground prototype and background prototype in step S3 to the query image, matching the pixel features in the query image with the optimized foreground and background prototypes, and determining whether each pixel belongs to the foreground or background category by calculating the similarity between each pixel and the prototype. The category with the highest similarity is selected as the label of the pixel, thereby generating the corresponding segmentation mask.
[0019] Preferably, in step S1, the support prototype generation module specifically extracts high-dimensional feature representations from the support set image through a feature extractor, and generates prototypes of the foreground and background through a prototype generator. The prototypes represent the core features of a specific category in the support set and are the basis for subsequent module optimization and learning;
[0020] In generating the foreground prototype and background prototype sets of the support image and After that, the initial foreground and background prototypes of the query image are estimated. The specific steps include the following:
[0021] Calculate the average of the foreground prototype and background prototype of the support image and Similarity with all pixel features of the query image to construct the initial query foreground mask ,
[0022] This process is done through cosine similarity To quantify, use the following formula: ;
[0023] Further based on Using EM operations to process query features , generate the initial query prospect prototype and background prototype , , where R represents the real number space, R C Belonging to a C-dimensional feature vector, it is used to describe the high-dimensional embedding representation of the feature; therefore, and It is the foreground and background feature representation of the query image. Each representation is encoded into a C-dimensional vector. This C is determined by the feature extraction network and is the number of feature channels output by the network. These vectors are used as input to interact with other modules in subsequent processing (attention calculation or update);
[0024] The entire initial estimation process can be summarized as follows: .
[0025] Preferably, in step S2, the independent prototype self-attention module has a structure consisting of a self-attention layer and a residual connection. The self-attention layer is used to learn the relationship between the foreground and background prototypes, and analyze the relationship within the prototype through the self-attention mechanism. The self-attention layer calculates the relationship weight between each prototype and other prototypes, emphasizing the prototype features that contribute more to the diversity within the class. The residual connection is used to maintain the original feature information to ensure the stability of the model optimization process.
[0026] Preferably, query the prospect prototype Specifically expressed as: projecting it into different spaces through three different linear weight layers to generate 、 and , both size; among them, Query matrix, used to query attention weights; is the Key matrix, and Used together to calculate attention weights; is the Value matrix, which contains the important information to be extracted. The attention map calculated using cosine similarity , describes and The relationship between:
[0027] ;
[0028] Through this attention map, the model is able to adaptively extract and learn Important information in;
[0029] Further, adding residual structure and layer normalization , to optimize the output sequence:
[0030] ;
[0031] Updated Then through the feedforward neural network , the network consists of two linear layers for dimensionality increase and decrease, and a GELU activation layer, while using residual connections and layer normalization:
[0032] .
[0033] Preferably, in step S3, a cross-prototype attention module is provided, wherein the structure of the module includes a multi-head attention mechanism, a position encoder, and a decoder, wherein the multi-head attention mechanism is used to capture the complex relationship between foreground and background prototypes, the position encoder retains spatial position information, and the decoder is responsible for mapping the optimized features back to the query image;
[0034] The cross-prototype attention module explores the relationship between the supporting foreground and background prototypes, learns the correlation features between them, and effectively transfers these features to the query foreground and background to achieve the correction effect. The specific algorithm is as follows:
[0035] ,
[0036] Among them, A1: attention score matrix, used to measure the query feature P q and key features Similarity of P q : Query feature, representing the feature vector of the target image (query set); P k : key feature, representing the feature vector of the support set (annotated data set); C: the dimension of the feature vector, used for normalization to avoid excessive values caused by the dot product of high-dimensional features; the above formula functions: P is calculated by dot product q and similarity and generate an attention score;
[0037] ,
[0038] Mask: A mask used to mask out areas that do not require attention; weight restrictions are imposed on certain pixels or regions to ignore their impact on segmentation; the above formula adds a mask to the original attention score to make the model focus more on specific foreground or background areas;
[0039] ,
[0040] in, : The updated feature vector is the value vector P through the attention score A2 v Weighted; softmax (A2): normalize the attention score to ensure that the sum of the weights is 1; :To P v The feature weights in : Retain the original features to ensure model stability; LN (Layer Normalization): Normalize the updated feature vector to ensure stable distribution and avoid gradient explosion or disappearance;
[0041] The above formula works by weighting and optimizing features through the attention mechanism while preserving the original information. Combined with layer normalization, it enhances the expressiveness of features, enabling the model to more accurately capture the difference between foreground and background. This optimization approach improves segmentation robustness and accuracy in complex backgrounds or with few samples.
[0042] ,
[0043] Among them, FFNN (Feed-Forward Neural Network): for features Perform nonlinear transformation to enhance its expressive power; the above formula functions to further optimize , extracting deeper features through nonlinear activation;
[0044] Then, by applying the softmax function to the attention score A2 and comparing it with the value Combined, the self-update process of the query foreground prototype is completed:
[0045] ;
[0046] Where Q is the query feature matrix; K is the key feature matrix. The above formula is used to recalculate the attention score matrix according to the above principle formula for multiple optimizations.
[0047] The model performs global average pooling on the updated query foreground-background features and calculates cosine similarity with the pixel features of the query image to obtain a new query foreground-background prototype:
[0048] ,
[0049] Among them, P f l+1 and P b l+1 : Optimized foreground prototype and background prototype; F q : Query image features; GAP (Global Average Pooling): Globally pools foreground and background features, extracts global features, and reduces local noise interference; QPG: Prototype Generation function (Query Prototype Generation), combines the pooled foreground and background features with the query image features to generate a new prototype; The above formula functions: Through the interaction of global pooling and query features, the foreground and background prototypes are updated to make segmentation more accurate.
[0050] Preferably, in step S4, query set processing and segmentation, iterative segmentation of the query image, this module consists of a similarity calculator and a segmentation mask generator, the similarity calculator is used to calculate the similarity between the query image pixels and the foreground and background prototypes, and the segmentation mask generator generates the final segmentation result based on the similarity;
[0051] The final query image segmentation module is responsible for applying the optimized prototypes to the query image and generating the final segmentation mask by matching pixels in the query image with the optimized foreground and background prototypes.
[0052] Preferably, a control system is also included, and the control signal of the control system is used to manage the data flow and processing sequence between the modules to ensure that the entire process proceeds in an orderly manner.
[0053] The present invention provides an improved method for target segmentation of small-sample medical images. It has the following beneficial effects:
[0054] Based on existing medical image segmentation technology, this paper introduces independent prototype self-attention modules and cross-prototype attention modules to solve multiple technical problems and significantly improve the accuracy and robustness of segmentation. The main advantages are as follows:
[0055] (1) Independent prototype self-attention module, which refines the foreground and background prototypes through the self-attention mechanism. This method effectively enhances the expressive power of the prototype, especially when the target area is complex in shape and the number of samples is limited, and can better capture the subtle features of the target area. Compared with the existing technology, this processing method of the present invention effectively solves the problem of insufficient intra-class diversity processing, ensuring that the segmentation model can still accurately distinguish different categories of targets under the condition of few samples. Therefore, when processing complex target areas, the segmentation accuracy of the present invention is significantly higher than that of traditional methods.
[0056] (2) The cross-prototype attention module further optimizes the segmentation effect by learning the differences between foreground and background prototypes. In the existing technology, the differences between foreground and background are often difficult to fully capture, which leads to misclassification during the segmentation process. The present invention uses a multi-head attention mechanism to interactively match and optimize foreground and background prototypes, thereby enhancing the segmentation ability of the model in complex backgrounds. It can be seen that the segmentation accuracy and robustness of the present invention are significantly better than traditional methods when processing complex backgrounds and cross-domain datasets, especially showing stronger generalization capabilities in cross-domain applications.
[0057] (3) The present invention introduces an iterative optimization mechanism. By iteratively updating the foreground and background prototypes multiple times, the segmentation results can be gradually optimized. This iterative optimization not only improves the segmentation accuracy but also makes the segmentation process more stable and reliable. Compared with the single optimization method of the prior art, the iterative optimization mechanism of the present invention shows higher segmentation accuracy in long-term applications. In particular, the advantages of iterative optimization are more obvious when processing high-noise data or irregular target areas.
[0058] (4) By introducing independent prototype self-attention modules, cross-prototype attention modules, and iterative optimization mechanisms, the present invention has made significant technological progress in solving problems such as insufficient intra-class diversity, insufficient capture of foreground-background differences, and poor cross-domain segmentation performance. Compared with existing technologies, the present invention has higher segmentation accuracy, stronger robustness, and wider application adaptability, especially under conditions of few samples and complex backgrounds, showing superior performance and practicality.
[0059] (5) In terms of technical effects, the segmentation effect of the present invention under the conditions of few samples and cross-domain is significantly improved compared with the existing technology. Experimental verification shows that the present invention significantly improves the accuracy of medical image segmentation under the condition of scarce data, especially in scenes with complex internal morphology of the target area and significant differences between the background and foreground. The segmentation accuracy is improved by more than 10%, and better generalization ability is demonstrated on cross-domain data sets. The iterative optimization mechanism further improves the segmentation accuracy. Experimental data show that after multiple iterations, the segmentation accuracy is improved by 15% to 20% compared with the first iteration. These results demonstrate the practicality and superiority of the present invention in medical image segmentation, and provide strong technical support for the high-precision segmentation needs in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 This is a schematic diagram of the model framework of the present invention;
[0061] Figure 2 Schematic diagram of the cross-prototype attention module;
[0062] Figure 3 Mask visualization data graph for cross-prototype attention;
[0063] Figure 4 Visualization data graph for SegRap target segmentation;
[0064] Figure 5 Visualization data graph for HECKTOR target segmentation;
[0065] Figure 6 Model performance data graphs for different numbers of labeled datasets;
[0066] Figure 7Data graph showing the impact of the number of prototypes;
[0067] Figure 8 Iterative segmentation visualization of data graph;
[0068] Figure 9 Data graph showing the impact of the number of independent prototype self-attention modules stacked;
[0069] Figure 10 Data graph showing the impact of the number of stacked cross-prototype attention modules; DETAILED DESCRIPTION
[0070] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Example 1
[0071] See also Figure 1-3 The improved few-shot medical image target segmentation method provided by this paper includes support set processing, prototype optimization, cross-prototype learning, and query set processing and segmentation. Through the close integration of these steps, high-precision segmentation of medical images is ultimately achieved. By introducing a more sophisticated prototype generation and optimization mechanism, the goal is to further improve the accuracy and robustness of medical image segmentation, especially in few-shot and cross-domain conditions, achieving more efficient segmentation.
[0072] Although the progress of existing deep learning technology has significantly improved the medical image segmentation effect based on large-scale annotated data, the high dependence of these methods on a large amount of annotated data is a challenge in medical images, because the annotated data is usually difficult to obtain, resulting in poor segmentation effect of existing methods under few-sample conditions. Existing few-sample learning methods are insufficient in dealing with the internal diversity of the target area and the difference between the foreground and the background, which affects the accuracy and robustness of the segmentation. The purpose is to improve the segmentation performance under few-sample conditions, especially in complex backgrounds and cross-domain data sets, to enhance the accuracy and robustness of the segmentation. Through the close combination of these steps, the present invention achieves high-precision segmentation of medical images under few-sample conditions, overcomes the problems of existing methods in dealing with intra-class diversity, insufficient learning of inter-class differences, and limited cross-domain segmentation performance, and demonstrates high practical value and technical advantages, which are described in detail as follows.
[0073] like Figure 1As shown, the improved few-sample medical image target segmentation method of the present invention, the overall structure and workflow of the model are composed of multiple key modules such as support set feature extraction, prototype generation and optimization, foreground and background difference learning, and iterative segmentation of query images. Each module plays a different function in the overall solution and works together to achieve high-precision medical image segmentation. The independent prototype self-attention module and the cross-prototype attention module are introduced to perform refined learning and optimization of the foreground and background prototypes in the support set image, thereby enhancing the model's ability to segment complex medical images under few-sample conditions.
[0074] S1. The support prototype generation module extracts high-dimensional feature representations from the support set images through a feature extractor, and then generates initial prototypes of the foreground and background through a prototype generator.
[0075] S2. The independent prototype self-attention module further optimizes the generated foreground and background prototypes, improving its ability to handle intra-class diversity and enabling the prototypes to better express the core features that support the concentrated category. Specifically, the self-attention mechanism analyzes relationships within the prototypes. The self-attention layer calculates the relationship weights between each prototype and other prototypes, emphasizing prototype features that contribute significantly to intra-class diversity. Residual connections are used to preserve the original information, ensuring the stability of the optimization process and enhancing the expressive power of the prototypes.
[0076] S3. Figure 2 As shown in the figure, the Cross-Prototype Attention Module is responsible for optimizing the differences between foreground and background prototypes, improving the model's segmentation performance for complex backgrounds and cross-domain data. Specifically, through a multi-head attention mechanism, foreground and background prototypes are cross-matched to learn their differences. This process, through continuous iterative updates, gradually optimizes the foreground and background features in the query image, ultimately generating more accurate segmentation results.
[0077] S4. Final query image segmentation module: This module segments the query image using the optimized prototypes to generate the final foreground and background segmentation masks. Specifically, the optimized prototypes are matched to pixels in the query image using similarity calculations, each pixel's class is determined, and the corresponding segmentation mask is generated.
[0078] The improved few-sample medical image target segmentation method of the present invention has the following working principles:
[0079] Support set processing is the first step of the entire technical solution. The core of the support prototype generation module is believed to be to extract high-dimensional feature representations from the support set image through a feature extractor, and then generate initial prototypes of the foreground and background through a prototype generator. The above prototypes represent the core features of a specific category in the support set. Subsequently, the extracted features are processed through methods such as clustering or average pooling to generate foreground and background prototypes. These prototypes are simplified expressions of the features of a specific category in the support set, which serve to summarize and condense the category features, laying the foundation for subsequent optimization and learning processes. In this way, the support prototype generation module preliminarily solves the problem of how to effectively represent category features under few-sample conditions.
[0080] During the prototype optimization step, the generated preliminary foreground and background prototypes are fed into the independent prototype self-attention module for optimization. This module analyzes the relationships within the prototypes through a self-attention mechanism. The self-attention layer calculates the relationship weights between each prototype and other prototypes, highlighting those prototype features that contribute significantly to intra-class diversity. Residual connections are used to preserve the original information and ensure the stability of the optimization process. Through this mechanism, the independent prototype self-attention module effectively enhances the expressive power of the prototypes, addressing the problem of insufficient handling of intra-class diversity in existing technologies.
[0081] like Figure 2The cross-prototype attention module is shown in the figure. Cross-prototype learning is a key innovation of this invention. The structure and operating principle of the cross-prototype attention module are described. Using a multi-head attention mechanism, after optimization by the independent prototype self-attention module, the foreground and background prototypes are input into the cross-prototype attention module for further learning and optimization. The cross-prototype attention module then uses a multi-head attention mechanism to cross-match the foreground and background prototypes, capturing the complex relationships between them and learning their differences. The cross-prototype attention module models the differences between foreground and background and gradually optimizes the foreground and background prototypes in the query image. During this process, the prototypes are continuously updated and interact with each other, gradually accumulating optimization effects and optimizing the foreground and background features in the query image. Ultimately, optimized prototypes are formed that accurately reflect the differences between foreground and background, significantly improving segmentation accuracy and ultimately generating more accurate segmentation results. By learning the differences between foreground and background and focusing on the correlations between features, the model can more accurately separate foreground and background. The cross-prototype attention module improves segmentation accuracy, especially in complex backgrounds. Query set processing and segmentation are the final step of the technical solution and a key step in achieving the ultimate goal. The pixel features of the query image are matched against the optimized foreground and background prototypes. The similarity between each pixel and the prototype is calculated to determine whether the pixel belongs to the foreground or background. The category with the highest similarity is selected as the label for that pixel, and the corresponding segmentation mask is generated. Spatial position information is introduced to ensure that the model can account for the influence of different locations when learning the relationship between foreground and background. The decoder's role is to map the optimized features back to the query image for the final segmentation operation.
[0082] To further improve segmentation accuracy, the system undergoes multiple iterative updates. In each iteration, the optimized prototype is reapplied to the query image, gradually improving segmentation accuracy. Through this iterative update mechanism, the query image segmentation results are continuously optimized, ultimately achieving highly accurate medical image segmentation, especially under conditions with few samples and complex backgrounds.
[0083] The improved few-sample medical image target area segmentation method of the present invention starts with the support set image input during the data flow process. The data first passes through the feature extractor to extract high-dimensional features and generate foreground and background prototypes. The initially generated prototype flows to the independent prototype self-attention module, and after optimization by the self-attention layer, it continues to flow to the cross-prototype attention module. In the cross-prototype attention module, the foreground and background prototypes are interactively learned through the multi-head attention mechanism, and the optimized prototypes are passed to the query image segmentation module. Finally, the pixels of the query image are matched with the optimized prototypes, a segmentation mask is generated, and the segmentation results are output. The control signal of the system is mainly used to manage the data flow and processing order between the modules to ensure that the entire process proceeds in an orderly manner. Example 2
[0084] like Figure 1-Figure 2 As shown, the improved few-sample medical image target region segmentation method of the present invention specifically includes the following steps:
[0085] S1 support set feature extraction: Using the support prototype generation module, the feature extractor extracts high-dimensional features from the support set image, and then generates an initial prototype set of the foreground and background of the support image through the prototype generator; next, the initial foreground and background prototypes of the query image are estimated.
[0086] First, the support prototype generation module extracts high-dimensional feature representations from the support set images through the feature extractor, and generates foreground and background prototypes through the prototype generator. The prototype represents the core features of a specific category in the support set and is the basis for subsequent module optimization and learning. In this way, the support prototype generation module preliminarily solves the problem of how to effectively represent category features under few-sample conditions.
[0087] In generating the foreground and background prototype sets of support images and After that, the initial foreground and background prototypes of the query image are estimated. The specific steps include: calculating the average value of the support prototypes and Similarity with all pixel features of the query image to construct the initial query foreground mask ,
[0088] This process is done through cosine similarity To quantify, use the following formula: ;
[0089] Further based on Use EM operations to process query features , generate the initial query prospect prototype and background prototype ,in , where R represents the real number space, R C Belonging to a C-dimensional feature vector, it is used to describe the high-dimensional embedding representation of the feature; therefore, and It is the foreground and background feature representation of the query image. Each representation is encoded into a C-dimensional vector. This C is determined by the feature extraction network and is the number of feature channels output by the network. These vectors are used as input to interact with other modules in subsequent processing (attention calculation or update);
[0090] The entire initial estimation process can be summarized as follows: .
[0091] S2 Prototype Generation and Optimization: Using an independent prototype self-attention module, after generating preliminary foreground and background prototypes of the support image in step S1, the prototype is optimized through the self-attention layer. By capturing subtle differences within the prototype, the ability to handle intra-class diversity is improved to enhance its expressive power.
[0092] The independent prototype self-attention module consists of a self-attention layer and a residual connection. The self-attention layer is used to learn the relationship between prototypes and analyze the relationship within the prototype through the self-attention mechanism. The self-attention layer calculates the relationship weight between each prototype and other prototypes, emphasizing the prototype features that contribute more to the diversity within the class. The residual connection is used to maintain the original feature information to ensure the stability of the model optimization process.
[0093] Query Prospect Prototype The specific expression is as follows:
[0094] It is projected into different spaces through three different linear weight layers to generate 、 and , both size; among them, Query matrix, used to query attention weights; is the Key matrix, and Used together to calculate attention weights; is the Value matrix, which contains the important information to be extracted. The attention map calculated using cosine similarity , describes and The relationship between:
[0095] .
[0096] Through this attention map, the model is able to adaptively extract and learn Important information in.
[0097] Further, adding residual structure and layer normalization , to optimize the output sequence:
[0098] .
[0099] Updated Then through the feedforward neural network , the network consists of two linear layers for dimensionality increase and reduction, and a GELU activation layer, while using residual connections and layer normalization:
[0100] .
[0101] S3 cross-prototype learning and optimization: The cross-prototype attention module is used to learn the differences between the foreground and background of the support image. Through the multi-head attention mechanism, the foreground and background prototypes of the support image optimized in step S2 are cross-matched. By exploring the relationship between the support foreground and background prototypes, the difference knowledge between the foreground prototype and the background prototype is learned for modeling, the correlation features between them are learned, and the features are effectively transferred to the query foreground and background. It is continuously iterated and updated, and the foreground and background feature prototypes in the query image are gradually optimized to achieve the correction effect. The optimized prototypes are passed to the query image segmentation module, and finally a more accurate segmentation result is generated.
[0102] The Cross-Prototype Attention Module significantly improves segmentation accuracy by enhancing the ability to distinguish between foreground and background. This module further optimizes the foreground and background prototypes in the query image by learning the differences between them. The module's structure comprises a multi-head attention mechanism, a position encoder, and a decoder. The multi-head attention mechanism captures the complex relationship between foreground and background prototypes, the position encoder preserves spatial location information, and the decoder maps the optimized features back to the query image.
[0103] The cross-prototype attention module explores the relationship between the supporting foreground and background prototypes, learns the correlation features between them, and effectively transfers these features to the query foreground and background to achieve the correction effect.
[0104] ,
[0105] Among them, A1: attention score matrix, used to measure the query feature P q and key features Similarity of P q : Query feature, representing the feature vector of the target image (query set); P k: key feature, representing the feature vector of the support set (annotated data set); C: the dimension of the feature vector, used for normalization to avoid excessive values caused by the dot product of high-dimensional features; the above formula functions: P is calculated by dot product q and similarity and generate an attention score;
[0106] ,
[0107] Mask: A mask used to mask out areas that do not require attention; weight restrictions are imposed on certain pixels or regions to ignore their impact on segmentation; the above formula adds a mask to the original attention score to make the model focus more on specific foreground or background areas;
[0108] ,
[0109] in, : The updated feature vector is the value vector P through the attention score A2 v Weighted; softmax (A2): normalize the attention score to ensure that the sum of the weights is 1; :To P v The feature weights in : retain the original features to ensure model stability; LN layer normalization: normalize the updated feature vector to ensure stable distribution and avoid gradient explosion or disappearance;
[0110] The above formula works by weighting and optimizing features through the attention mechanism while preserving the original information. Combined with layer normalization, it enhances the expressiveness of features, enabling the model to more accurately capture the difference between foreground and background. This optimization approach improves segmentation robustness and accuracy in complex backgrounds or with few samples.
[0111] ,
[0112] Among them, FFNN feedforward neural network: for features Perform nonlinear transformation to enhance its expressive power; the above formula functions to further optimize , extracting deeper features through nonlinear activation;
[0113] Then, by applying the softmax function to the attention score A2 and comparing it with the value Combined, the self-update process of the query foreground prototype is completed:
[0114] ;
[0115] Where Q is the query feature matrix; K is the key feature matrix. The above formula is used to recalculate the attention score matrix according to the above principle formula for multiple optimizations.
[0116] The model performs global average pooling on the updated query foreground-background features and calculates cosine similarity with the pixel features of the query image to obtain a new query foreground-background prototype:
[0117] ,
[0118] Among them, P f l+1 and P b l+1 : Optimized foreground prototype and background prototype; F q : Query image features; GAP global average pooling: Globally pool the foreground and background features, extract global features, and reduce local noise interference; QPG: Prototype generation function, combines the pooled foreground and background features with the query image features to generate a new prototype; The above formula functions: Through the interaction of global pooling and query features, the foreground and background prototypes are updated to make the segmentation more accurate.
[0119] Finally, if Figure 3 The mask visualization in the Cross-Prototype Attention module clearly shows the mask generated by the Cross-Prototype Attention module, which is used to distinguish foreground and background areas. The mask intuitively reflects the model's segmentation of foreground and background in the image, that is, which pixels belong to the foreground and which belong to the background. This visualization demonstrates the model's ability to accurately segment complex areas, demonstrating the efficiency and accuracy of the Cross-Prototype Attention module in distinguishing foreground and background.
[0120] S4 Query Set Processing and Segmentation: Iterative segmentation of the query image. This module consists of a similarity calculator and a segmentation mask generator. The similarity calculator is used to calculate the similarity between the query image pixels and the foreground and background prototypes, while the segmentation mask generator generates the final segmentation result based on the similarity.
[0121] The optimized foreground prototype and background prototype in step S3 are applied to the query image, and the pixel features in the query image are matched with the optimized foreground and background prototypes. By calculating the similarity between each pixel and the prototype, the category of each pixel is determined to be foreground or background. The category with the highest similarity is selected as the label of the pixel, thereby generating the corresponding segmentation mask, generating the final segmentation mask, and outputting the segmentation result.
[0122] Application Examples
[0123] The improved few-sample medical image target region segmentation method of the present invention is applied to specific few-sample medical image target region segmentation, SegRap target region segmentation, and HECKTOR target region segmentation. The specific results are as follows:
[0124]
[0125] Table 1 Comparative experimental results using the SegRap dataset as a query set
[0126] result Figure 4 The SegRap target segmentation visualization clearly demonstrates the model's performance on the SegRap dataset. The visualization demonstrates the model's precise segmentation of the target region, successfully identifying the boundaries of the target region within complex images. Even with few-shot learning, the model still achieves high segmentation accuracy, demonstrating its strong adaptability in data-scarce scenarios.
[0127] The comparative experimental results using the SegRap dataset as the query set in Table 1 further demonstrate that our model performs better than other segmentation methods on the SegRap dataset, primarily evaluating them based on metrics such as segmentation accuracy and robustness. The table shows that our segmentation method outperforms traditional methods across all metrics, demonstrating particularly strong performance under low-sample conditions. This demonstrates that the model's independent prototype self-attention module and cross-prototype attention module effectively improve segmentation accuracy for complex target areas, maintaining high accuracy and generalization even with limited sample data.
[0128]
[0129] Table 2 Comparative experimental results using the HECKTOR2022 dataset as a query set
[0130] Combine Figure 5 The HECKTOR target segmentation visualization data shown in the figure shows that the segmentation performance of the model on the HECKTOR2022 dataset is similar to the results of the SegRap dataset. This visualization also verifies the generalization performance of the model. Figure 5 The results in
[15] show that the model can adapt to target segmentation tasks in different datasets, demonstrating its robustness in cross-domain segmentation tasks. The model performs well in identifying image boundaries and segmenting details, accurately segmenting the target area and avoiding misclassifying the background as foreground.
[0131] Combined with the comparative experimental results using the HECKTOR2022 dataset as the query set in Table 2, we can see that the segmentation performance of the model of the present invention's segmentation method is compared with that of other methods on the HECKTOR2022 dataset. The experimental results show that the model of the present invention's segmentation method significantly outperforms the comparison methods on multiple evaluation metrics, especially in complex backgrounds and diverse sample conditions, demonstrating higher segmentation accuracy and robustness. This demonstrates that the model's multi-level attention mechanism adapts to the differences in cross-domain datasets, helping to improve the model's generalization ability, enabling it to handle feature differences between different datasets, and enhancing its practical application value in medical image segmentation.
[0132]
[0133] Table 3 Effect of prototype position order
[0134] From the data on the influence of the prototype position order in Table 3, we can obtain: This table analyzes the influence of the position order of foreground and background prototypes on the model segmentation effect. The results show that although the adjustment of the position order in the segmentation method of the present invention has limited effect on the segmentation effect, proper optimization of the prototype position order can improve the segmentation accuracy to a certain extent, especially in fine-grained segmentation tasks, it can improve the recognition accuracy of specific areas. This table shows the flexibility of the model of the segmentation method of the present invention in processing different samples and target area features, so that the optimization of the prototype position order in the segmentation process slightly improves the actual effect.
[0135] Depend on Figure 6 The model performance data graph under different numbers of labeled data sets shown in the figure can be obtained: the segmentation performance of the model under different numbers of labeled data conditions. As the number of labeled data increases, the segmentation accuracy of the model gradually improves, indicating that the model can effectively utilize more labeled data for optimization. However, even when the amount of labeled data is small, the model still shows a high segmentation accuracy, reflecting its advantage in few-shot learning. Overall, Figure 6 The consistency and robustness of the segmentation effect of the model under the conditions of scarce and sufficient labeled data are verified.
[0136] Depend on Figure 7 The effect diagram of the number of prototypes shown here illustrates the impact of the number of foreground and background prototypes on model performance in the segmentation method of the present invention. Experimental results show that appropriately increasing the number of prototypes enhances the model's ability to represent different foreground and background features, thereby improving segmentation accuracy. However, when the number of prototypes is too large, the model's computational cost increases significantly, and even slightly decreases segmentation accuracy. This indicates that a balance should be struck between accuracy and efficiency to optimize segmentation results.
[0137] Depend on Figure 8The iterative segmentation visualization shown in the figure shows the segmentation results after multiple iterations of optimization, demonstrating the gradual improvement of the model during iterative updates. As the number of iterations increases, the model's segmentation results become more accurate and the segmentation boundaries become clearer. This iterative optimization mechanism allows the model to improve segmentation accuracy through gradual correction, especially in complex backgrounds. The segmentation effect can be continuously improved through iteration, making the segmentation mask more accurate and stable.
[0138] Depend on Figure 9 The data graph shows the impact of the number of stacked independent prototype self-attention modules on the segmentation performance of the model in this segmentation method. Increasing the number of stacked independent prototype self-attention modules improves the model's ability to capture foreground and background features, thereby enhancing segmentation accuracy. However, when the number of stacked layers reaches a certain level, the performance improvement gradually slows down and even decreases slightly, indicating that excessive stacking increases model complexity with diminishing benefits. Therefore, it is important to appropriately set the number of stacked layers during model design to achieve a balance between segmentation accuracy and computational cost.
[0139] Depend on Figure 10 The figure shows the impact of the number of stacked cross-prototype attention modules on model segmentation performance. Increasing the number of stacked layers of this module significantly improves foreground and background differentiation, especially in complex backgrounds. The multi-layer attention mechanism better captures feature differences and improves segmentation accuracy. However, excessive stacking can also lead to excessive computational overhead and saturation or even degradation of model performance. Therefore, optimizing the number of layers in practical applications is necessary to achieve optimal segmentation results.
[0140] The above data detection results show that the segmentation method of the present invention has the following advantages in terms of technical effects: the improved few-sample medical image target segmentation method of the present invention has significantly improved segmentation effects under few-sample and cross-domain conditions compared with the existing technology. The present invention significantly improves the accuracy of medical image segmentation when data is scarce, especially in scenes with complex internal morphology of the target area and significant differences between the background and foreground. The segmentation accuracy is improved by more than 10%, and better generalization ability is demonstrated on cross-domain data sets. The iterative optimization mechanism further improves the segmentation accuracy. Experimental data show that after multiple iterations, the segmentation accuracy is improved by 15% to 20% compared with the first iteration. These results demonstrate the practicality and superiority of the present invention in medical image segmentation, and provide strong technical support for the high-precision segmentation needs in practical applications.
[0141] In the improved few-sample medical image target segmentation method of the present invention, support set processing is the first step of the entire technical solution. The core task of this step is to extract effective features from the support set image and generate preliminary prototypes of the foreground and background. Specifically, the support set image first passes through a feature extractor to extract high-dimensional deep features. These features represent the main feature information of each category in the support set. Subsequently, the extracted features are processed by methods such as clustering or average pooling to generate foreground and background prototypes. These prototypes are simplified expressions of specific category features in the support set, which play the role of summarizing and condensing category features, laying the foundation for subsequent optimization and learning processes.
[0142] During the prototype optimization step, the generated preliminary foreground and background prototypes are input into the independent prototype self-attention module for optimization. This module refines the foreground and background prototypes using a self-attention mechanism. Specifically, the self-attention mechanism calculates the relationship weights between each prototype and other prototypes, highlighting those prototype features that contribute significantly to intra-class diversity, thereby enhancing the expressive power of the prototypes. Furthermore, residual connections are used to preserve the original feature information, ensuring the stability of the optimization process. Through this optimization, the generated foreground and background prototypes better express the diversity of intra-class features, thereby improving the accuracy of subsequent segmentation.
[0143] Cross-prototype learning is a key innovation of the present invention. After being optimized by the independent prototype self-attention module, the foreground and background prototypes are input into the cross-prototype attention module for further learning and optimization. The working principle of this module is to cross-match the foreground prototype and the background prototype through a multi-head attention mechanism to learn the differences between them. The cross-prototype attention module gradually optimizes the foreground and background prototypes in the query image by modeling the knowledge of the differences between the foreground and background. In this process, the prototypes continuously interact with each other through iterative updates, and the optimization effect gradually accumulates, eventually forming an optimized prototype that can accurately reflect the differences between the foreground and background, thereby greatly improving the segmentation accuracy, especially under complex background conditions.
[0144] Query set processing and segmentation is the last step of the technical solution and a key step to achieving the ultimate goal. The optimized foreground and background prototypes are used for the segmentation of the query set image. The specific operation is to match the pixel features of the query image with the optimized foreground and background prototypes, and determine whether the pixel belongs to the foreground or background by calculating the similarity between each pixel and the prototype. The category with the highest similarity is selected as the label of the pixel, and the corresponding segmentation mask is generated. In order to further improve the accuracy of the segmentation, the system will perform multiple iterative updates. In each iteration, the optimized prototype will be reapplied to the query image, thereby gradually improving the accuracy of the segmentation. Through this iterative update mechanism, the segmentation results of the query image can be continuously optimized, and ultimately achieve high-precision medical image segmentation.
[0145] In summary, the improved few-sample medical image target segmentation method of the present invention includes support set processing, prototype optimization, cross-prototype learning, and query set processing and segmentation. Through the close integration and synergy of these steps, high-precision segmentation of medical images is ultimately achieved. On the basis of existing medical image segmentation technology, by introducing independent prototype self-attention modules and cross-prototype attention modules, multiple technical difficulties are solved, and the accuracy and robustness of segmentation are significantly improved. In particular, more efficient segmentation is achieved under few-sample and cross-domain conditions, which has significant practical value and technical advantages.
[0146] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any technician familiar with the technical field, within the technical scope disclosed by the present invention, who makes equivalent replacements or changes based on the technical solution and inventive concept of the present invention, should be covered by the scope of protection of the present invention.
Claims
1. An improved few-sample medical image target segmentation method, characterized in that: This includes support set processing, prototype generation and optimization, cross-prototype learning and optimization, and query set processing and segmentation. It introduces independent prototype self-attention modules and cross-prototype attention modules to fine-tune the learning and optimization of foreground and background prototypes in support set images, enhancing the model's ability to segment complex medical images with few samples. The specific steps are as follows: S1 support set feature extraction: Using the support prototype generation module, the feature extractor extracts high-dimensional features from the support set image, and then the prototype generator generates the initial prototypes of the foreground and background of the support image; S2 Prototype Generation and Optimization: Using an independent prototype self-attention module, the self-attention layer is optimized for the preliminary foreground and background prototypes of the support image generated in step S1. By capturing subtle differences within the prototypes, the ability to handle intra-class diversity is improved, thereby enhancing their expressive power, allowing the prototypes to better express the core features of the support set categories. The independent prototype self-attention module consists of a self-attention layer and residual connections. The self-attention layer is used to learn the relationship between foreground and background prototypes. It analyzes the relationship within the prototypes through the self-attention mechanism. The self-attention layer calculates the relationship weight between each prototype and other prototypes, emphasizing the prototype features that contribute most to the diversity within the class. The residual connection is used to maintain the original feature information to ensure the stability of the model optimization process. Query Prospect Prototype Specifically expressed as: projecting it into different spaces through three different linear weight layers to generate 、 and , both size; among them, Query matrix, used to query attention weights; is the Key matrix, and Used together to calculate attention weights; is the Value matrix, which contains the important information to be extracted; the attention map calculated using cosine similarity , describes and The relationship between: ; Through this attention map, the model is able to adaptively extract and learn Important information in; Further, adding residual structure and layer normalization , to optimize the output sequence: ; Updated Then through the feedforward neural network , the network consists of two linear layers for dimensionality increase and decrease, and a GELU activation layer, while using residual connections and layer normalization: ; S3 Cross-prototype learning and optimization: Using the cross-prototype attention module, the foreground and background differences of the support image are learned. Through the multi-head attention mechanism, the foreground and background prototypes of the support image optimized in step S2 are cross-matched. By exploring the relationship between the supporting foreground and background prototypes, learning the difference knowledge between the foreground prototype and the background prototype for modeling, learning the correlation features between them, and effectively transferring the features to the query foreground and background, continuously iteratively updating, and gradually optimizing the foreground and background feature prototypes in the query image; The cross-prototype attention module consists of a multi-head attention mechanism, a position encoder, and a decoder. The multi-head attention mechanism is used to capture the complex relationship between foreground and background prototypes. The position encoder retains spatial location information, and the decoder is responsible for mapping the optimized features back to the query image. The cross-prototype attention module explores the relationship between the supporting foreground and background prototypes, learns the correlation features between them, and effectively transfers these features to the query foreground and background to achieve the correction effect. The specific algorithm is as follows: , Among them, A1: attention score matrix, used to measure the query feature P q and key features Similarity of P q : query feature, representing the feature vector of the query set; Pk: key feature, representing the feature vector of the support set; C: dimension of the feature vector, used for normalization to avoid excessive values caused by high-dimensional feature dot products; the above formula functions: calculate P by dot product q and similarity and generate an attention score; , Mask: A mask used to mask out areas that do not require attention; weight restrictions are imposed on certain pixels or regions to ignore their impact on segmentation; the above formula adds a mask to the original attention score to make the model focus more on specific foreground or background areas; , in, : The updated feature vector is the value vector P through the attention score A2 v Weighted; softmax (A2): normalize the attention score to ensure that the sum of the weights is 1; :To P v The feature weights in : Retain the original features to ensure model stability; LN: Layer normalization, normalizes the updated feature vector to ensure stable distribution and avoid gradient explosion or disappearance; The above formula performs weighted optimization on features through the attention mechanism while preserving the original information. Combined with layer normalization, it enhances the expressiveness of features, enabling the model to more accurately capture the difference between foreground and background. This optimization method improves the robustness and accuracy of segmentation in complex backgrounds or with few samples. , Among them, FFNN: feedforward neural network, features Perform nonlinear transformation to enhance its expressive power; the above formula functions to further optimize , extracting deeper features through nonlinear activation; Then, by applying the softmax function to the attention score A2 and comparing it with the value Combined, the self-update process of the query foreground prototype is completed: ; Where Q is the query feature matrix; K is the key feature matrix. The above formula is used to recalculate the attention score matrix according to the above principle formula for multiple optimizations. The model performs global average pooling on the updated query foreground-background features and calculates cosine similarity with the pixel features of the query image to obtain a new query foreground-background prototype: , Among them, P f l+1 and P b l+1 : Optimized foreground prototype and background prototype; F q : query image features; GAP global average pooling: global pooling of foreground and background features, extracting global features and reducing local noise interference; QPG: prototype generation function, combining the pooled foreground and background features with the query image features to generate new prototypes; the above formula functions: through the interaction of global pooling and query features, the foreground and background prototypes are updated to make the segmentation more accurate; S4 query set processing and segmentation: Iterative segmentation of the query image, applying the optimized foreground prototype and background prototype in step S3 to the query image, matching the pixel features in the query image with the optimized foreground and background prototypes, and determining whether each pixel belongs to the foreground or background category by calculating the similarity between each pixel and the prototype. The category with the highest similarity is selected as the label of the pixel, thereby generating the corresponding foreground and background segmentation masks.
2. The improved few-sample medical image target region segmentation method according to claim 1, characterized in that: In step S1, the support prototype generation module specifically extracts high-dimensional feature representations from the support set image through a feature extractor, and generates foreground and background prototypes through a prototype generator. The prototypes represent the core features of a specific category in the support set and are the basis for subsequent module optimization and learning; In generating the foreground prototype and background prototype sets of the support image and After that, the initial foreground and background prototypes of the query image are estimated. The specific steps include the following: Calculate the average of the foreground prototype and background prototype of the support image and Similarity with all pixel features of the query image to construct the initial query foreground mask , This process is done through cosine similarity To quantify, use the following formula: ; Further based on Using EM operations to process query features , generate the initial query prospect prototype and background prototype ,in , where R represents the real number space, R C Belonging to a C-dimensional feature vector, it is used to describe the high-dimensional embedding representation of the feature; therefore, and It is the foreground and background feature representation of the query image. Each representation is encoded into a C-dimensional vector. This C is determined by the feature extraction network and is the number of feature channels output by the network. These vectors interact with other modules as input in attention calculation or update; The entire initial estimation process can be summarized as follows: .
3. The improved few-sample medical image target segmentation method according to claim 1, characterized in that: In step S4, query set processing and segmentation, iterative segmentation of the query image, this module consists of a similarity calculator and a segmentation mask generator. The similarity calculator is used to calculate the similarity between the query image pixels and the foreground and background prototypes, while the segmentation mask generator generates the final segmentation result based on the similarity; The final query image segmentation module is responsible for applying the optimized prototypes to the query image and generating the final segmentation mask by matching pixels in the query image with the optimized foreground and background prototypes.
4. The improved few-sample medical image target segmentation method according to claim 1, characterized in that: It also includes a control system, whose control signals are used to manage the data flow and processing sequence between modules to ensure that the entire process proceeds in an orderly manner.
Citation Information
Patent Citations
Small sample image semantic segmentation method based on feature separation and recombination
CN116805368A