Medical image segmentation method based on fungus growth optimization algorithm
By combining fungal growth optimization algorithms with the Transformer architecture and employing dynamic multi-attention fusion and cross-attention mechanisms, the problems of large model parameters and high computational complexity in medical image segmentation are solved, thereby improving the segmentation accuracy and robustness of complex lesion edges.
Patent Information
- Application Number
- CN202510854736.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-24
- Publication Date
- 2025-11-11
AI Technical Summary
Existing medical image segmentation methods suffer from problems such as large number of model parameters, high computational complexity, and insufficient segmentation accuracy for irregular lesion edges, especially in low-contrast lesion areas and complex anatomical structures.
We employ a self-attention mechanism based on fungal growth optimization algorithms, combined with the Swin Transformer or PVT_v2 backbone network. Through dynamic multi-attention fusion, hyphal bifurcation-inspired local path optimization, and cross-attention mechanism, we simulate fungal growth characteristics, enhance the model's focus on high semantic regions, and improve its boundary sensitivity to complex lesions.
It achieves lightweight model and real-time inference speed, while significantly improving the segmentation accuracy of low-contrast lesion areas and complex anatomical structures, enhancing the ability to identify small lesions and robustness to geometric transformations such as image rotation and scaling.
Smart Images

Figure CN120931918A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing methods, and in particular to a medical image segmentation method based on a fungal growth optimization algorithm. Background Technology
[0002] Medical image segmentation technology aims to accurately extract target anatomical structures or lesion regions from complex medical image data, providing crucial quantitative evidence for clinical applications such as disease diagnosis, surgical navigation, and efficacy evaluation. With the increasing resolution of medical imaging equipment and the growing complexity of pathological morphologies, existing segmentation algorithms face significant challenges in terms of generalization, robustness, and detail preservation. Traditional segmentation methods, such as thresholding, region growing, and graph cut algorithms, while computationally efficient, heavily rely on manual feature design and struggle to address the prevalent issues in medical images, such as uneven grayscale, blurred boundaries, and the coexistence of multi-scale structures.
[0003] In recent years, deep learning methods centered on Convolutional Neural Networks (CNNs) have demonstrated significant advantages in tasks such as pancreas segmentation and tumor delineation through end-to-end feature learning mechanisms. Encoder-decoder architectures, exemplified by UNet, achieve multi-scale feature fusion through skip connections, becoming the benchmark framework for medical image segmentation. With the groundbreaking advancements of Transformers in natural language processing, researchers have begun to introduce self-attention mechanisms into medical image analysis, enhancing the ability to model irregular lesions by establishing global dependencies. Vision Transformer (ViT) and its variants overcome the local receptive field limitations of traditional CNNs through sequence modeling, demonstrating advantages in capturing long-range contextual information in tasks such as cardiac MRI segmentation.
[0004] However, existing deep learning-based medical image segmentation methods still face significant bottlenecks: First, fixed-structure attention mechanisms struggle to adaptively adjust the feature response weights of different tissues in medical images, leading to missed detections of minute lesions. Second, Transformers are prone to overfitting when medical data is limited, and their quadratic computational complexity restricts their application in high-resolution images. Furthermore, existing model parameter optimization largely relies on gradient descent, which easily gets trapped in local optima in non-convex loss function spaces, affecting the ability to represent complex pathological features. To address these issues, researchers have attempted to combine deformable convolution with attention mechanisms to improve deformation adaptability, or to use knowledge distillation to compress model size; however, these improvements still have limitations in feature redundancy suppression and global optimization efficiency.
[0005] Current cutting-edge research in medical image segmentation focuses on three directions: 1) developing lightweight attention modules to balance computational efficiency and feature discriminativity; 2) constructing multi-scale feature fusion mechanisms under anatomical prior constraints; and 3) exploring synergistic optimization paradigms of bio-inspired optimization algorithms and deep learning. Among these, metaheuristic optimization algorithms (such as genetic algorithms and particle swarm optimization) have begun to be used for neural network hyperparameter tuning and architecture search due to their global search capabilities in complex solution spaces. However, existing methods still need improvement in terms of dynamic adaptability and convergence speed in the medical image feature space. This provides an innovative opportunity for this invention to combine the Fungal Growth Optimization (FGO) algorithm with the Transformer architecture—FGO simulates the adaptive growth mode of fungi in complex environments, and its parallel exploration mechanism and chemotactic feedback characteristics provide a new solution path for multi-objective optimization problems in medical image segmentation. Summary of the Invention
[0006] To address the technical problems of existing UNet networks in medical image segmentation tasks, such as large model parameters, high computational complexity, and insufficient segmentation accuracy for irregular lesion edges, this invention proposes a medical image segmentation method based on a fungal growth optimization algorithm. This method, through the synergistic design of a biomimetic optimization algorithm and a dynamic attention mechanism, significantly improves the segmentation accuracy for low-contrast lesion regions and complex anatomical structures while ensuring lightweight model and real-time inference speed.
[0007] To achieve the above-mentioned objectives, the present invention employs the following technical solution: a medical image segmentation method based on a fungal growth optimization algorithm, comprising the following steps:
[0008] Step 1: Preprocess the input image dataset, perform data augmentation, and divide the dataset into training, test, and validation sets in an 8:1:1 ratio;
[0009] Step 2: Construct a feedforward neural network based on a self-attention mechanism using a fungal growth optimization algorithm. The encoder-decoder network based on the fungal growth optimization algorithm and Transformer uses the fungal growth optimization algorithm to replace the LPA attention machine in Transformer, further enhancing the accuracy of the network and solving the problems of insignificant features and blurred boundaries caused by imaging devices.
[0010] Step 3: Input the preprocessed image dataset into a feedforward neural network based on a self-attention mechanism using a fungal growth optimization algorithm for training, and obtain the optimal model.
[0011] Step 4: After training, input the image dataset into the obtained optimal model to detect the segmentation results of the medical image dataset.
[0012] The specific process in step 1 is as follows:
[0013] Step 1.1: Divide the medical image dataset into a training set and a validation set in a ratio of 8:1:1.
[0014] Step 1.2: Load the images and masks from the training and test sets of the medical image dataset using cv2, and resize the images and masks to 256×256.
[0015] Step 1.3: The mask was grayscaled before being converted to a PIL image, and then the pixel values were normalized to [0,1] by dividing by 255. The grayscale and normalization formulas are as follows:
[0016]
[0017] Where R, G, and B are the values of the red, green, and blue channels of the image, respectively, and Out is the image after grayscale conversion and normalization.
[0018] Step 1.4: Convert the image from BGR format to RGB format.
[0019] Step 1.5: Perform data augmentation and preprocessing on the training set data by performing random scaling, random horizontal flipping, random vertical flipping, random cropping, and labeling. This data augmentation process, by introducing diversity and uncertainty, not only improves the robustness and generalization ability of the model but also increases attention to the details of the target, making the model more adaptable to slight changes in data distribution. Mean = (0.402, 0.402, 0.402), Std = (0.298, 0.298, 0.298), and the standardization formula is as follows:
[0020]
[0021] Where Input is the input image, Mean is the mean, Std is the standard deviation, and Normalized is the image after standardization.
[0022] Step 2 is specifically as follows:
[0023] Step 2.1: Due to the advantages of Transformer in capturing long-range dependencies, we replace the traditional convolutional operation with a Transformer encoder block. We construct a multi-scale feature encoding network, choosing either Swing Transformer or PVT_v2 as the backbone network. The Swing_L version output channels are [192,384,768,1536], the Swing_B version output channels are [128,256,512,1024], and the PVT_v2_b2 version output channels are [64,128,320,512]. When loading pre-trained weights, parameter filtering is performed, retaining only the parameters of convolutional and normalized layers that match the current network structure.
[0024] Step 2.2: Perform dynamic multi-channel feature fusion, construct a feature pyramid structure, and establish feature interaction through upsampling operations, as follows.
[0025] F′4=Conv 3×3 (F4)
[0026] F′3=Upsample(F′4)⊙Conv 3×3 (F3)
[0027] F′2=Upsample(F′3)⊙Conv 3×3 (F2)
[0028] F′1=Upsample(F′2)⊙Conv 3×3 (F1)
[0029] After fusion, the feature map set {F′1, F′2, F′3, F′4} is obtained.
[0030] Step 2.3: Block-based reconstructed local path attention, first dividing the input feature map into blocks according to space, and then... The region is divided into 2×2 sub-regions along both its height and width, and then independent attention is calculated. For each sub-region, a self-attention mechanism based on the fungal growth optimization algorithm, FGAttention, is applied.
[0031] F′ ij =FGAttention(F ij )
[0032] The processed sub-regions are then stitched together to form a complete feature map.
[0033]
[0034] Step 2.4: Implementation of the channel attention mechanism (FGAttention submodule) to simulate longitudinal hyphal growth.
[0035] αc =σ(W2·δ(W1·Avg(F)))
[0036] in Let δ be the MLP weight matrix, δ be the ReLU activation function, and σ be the Sigmoid activation function.
[0037] Step 2.5: Implementation of spatial attention mechanism (FGAttention submodule) to simulate the lateral expansion of hyphae.
[0038] α s =σ(Conv3×3(F))
[0039] Where MaxPool is max pooling, AvgPool is average pooling, and Conv... 3×3 For convolution operations
[0040] Step 2.6: The implementation method of the cross-attention module is as follows: simulating mycelial network interconnection.
[0041] Input feature map dimensionality transformation:
[0042] x permuted =permute(x, [0, 2, 3, 1])
[0043] x seq =reshape(x) permuted [B, H·W, C])
[0044] Multi-head attention calculation:
[0045] attn out =MHA(x seq x seq x seq )
[0046] Restoring spatial dimensions:
[0047] x out =permute(attn) out [0, 2, 1])
[0048] x out =reshape(x) out [B, C, H, W])
[0049] Step 2.7: The implementation of its fungal growth optimization algorithm includes:
[0050] Step 2.7.1 Calculate the characteristic variance for each attention branch as an indicator of nutrient concentration:
[0051] richness=var(fm,dim=(1,2,3))
[0052] Where fm is the input feature map
[0053] Formula for calculating weight increment:
[0054] Δ=γ·richness·w i
[0055] Where γ is the learnable base growth rate, w i The mycelial weight of the current branch
[0056] Weight update formula:
[0057] W new =w i ·η+Δ
[0058] Where η is the learnable nutrient consumption rate.
[0059] The parameter constraints of the hyphal network weight allocator include:
[0060] The nutrient consumption rate η ranges from [0.9, 1.0], with an initial value of 0.95; the basal growth rate γ ranges from [0.05, 0.2], with an initial value of 0.1; and the mycelial weight w... i Initialize w using a uniform distribution i ~∪(0.8, 1.2)
[0061] The implementation method of the dynamic attenuation mechanism described in step 2.7.2 includes:
[0062] Initialize the branch weights E = [e1, e2, e3], where e1 = 1.0, e2 = 0.8, and e3 = 0.6.
[0063] A decay operation is performed every 10 training iterations:
[0064] E new =E·λ
[0065] Where λ∈[0.95,0.99] is the decay rate, and the decay operation is activated only during the training phase.
[0066] The processing method of the fork optimization module in step 2.8 includes:
[0067] The input feature map is bisected along the height dimension:
[0068] x0, x1 = split(x, dim = 2)
[0069] For each sub-feature map, bisect it along the width dimension:
[0070] x 00 x 01=split(x0, dim=3)
[0071] x 10 x 11 =split(x1, dim=3)
[0072] Four-branch parallel processing:
[0073] y i =F i (x ij )·w i i = 0, 1, 2, 3
[0074] Where F i w is the attention processing function. i Learnable branch weights
[0075] Branch weight w i Decrease every 5 training iterations:
[0076] w new =w i ·β
[0077] Where β∈[0.85,0.95] is the attenuation coefficient.
[0078] Recombination output formula:
[0079] x out =concat(y0,y1,y2,y3)+x
[0080] The initialization method for the bifurcation weight is as follows:
[0081] Initial value setting: w i = [1.0, 0.9, 0.8, 0.7], with the attenuation coefficient β fixed at 0.9.
[0082] Step 2.9 The decoder uses a progressive upsampling structure for feature fusion:
[0083]
[0084] Where D is the decoding convolutional layer. For channel splicing operation
[0085] Step 3 includes the following steps:
[0086] Precision, Accuracy, BalancedAccuracy, Recal1, and F1-score are used as evaluation metrics to assess the training and testing results. The function expressions for each evaluation metric are as follows:
[0087]
[0088] In this context, TP, TN, FP, and FN represent the true positive class, true negative class, false positive class, and false negative class, respectively. Precision measures the proportion of samples that the model predicts as positive when they are actually positive. Accuracy measures the proportion of samples correctly predicted by the model out of the total sample. Recall measures the proportion of samples correctly identified by the model out of all samples that are actually positive. F1-score is the harmonic mean of precision and recall, used to balance these two metrics, and is particularly suitable for class imbalance problems.
[0089] Step 4 includes the following operations:
[0090] After the model training is completed, the best model from the training is used to validate on a medical image validation set to detect the segmentation effect in medical images.
[0091] Compared with existing technologies, the beneficial effects of the technical solution of this invention are:
[0092] 1. A dynamic multi-attention fusion mechanism based on fungal growth optimization. Technical implementation: A differentiable fungal growth weight allocator is designed to parametrically model the nutrient allocation process of the mycelial network. Specifically, this includes: defining learnable nutrient consumption rate and basal growth rate to simulate the growth characteristics of mycelia in eutrophic regions; calculating the local variance of the feature map as an information density index to dynamically generate fusion weights for channel, spatial, and cross-batch attention; and using Softmax normalized weights to achieve adaptive fusion of multi-attention features. This enables the model to autonomously focus on high semantic regions in medical images, overcoming the dependence of traditional attention mechanisms on fixed pattern features and enhancing the boundary sensitivity to complex lesions.
[0093] 2. The hyphal bifurcation-inspired local path optimization module simulates the topological bifurcation behavior of hyphal networks. A four-way block parallel processing mechanism is designed to divide the input feature map into four blocks along the spatial dimension, which are processed by independent FGAttention modules. Dynamic decaying branch weights are introduced to simulate the natural elimination of sub-branches during hyphal aging. A residual recombination strategy is used to stitch the processed sub-blocks together and add them to the original features to retain the underlying information. This forces the model to focus on small lesions and improves the robustness of the model to geometric transformations such as image rotation and scaling through local feature decoupling, effectively solving the problem of large intra-class differences in medical images.
[0094] 3. A cross-attention mechanism simulates hyphal interconnection, driving global context modeling to construct a multi-head self-attention module that associates across samples. This module reshapes the feature map into a sequence ([B, H*W, C]) while preserving the spatial topology. Cross-case attention associations are established in the batch dimension (H*W) to uncover common pathological patterns in the population data. The original dimensions are restored through feature reconstruction, enhancing the population consistency of expression. This overcomes the limitations of single-sample reasoning, leveraging cross-case knowledge transfer to improve the identification of rare lesions (such as atypical pneumonia and rare tumors). Simultaneously, population statistical features suppress imaging interference such as ultrasound speckle noise and CT metal artifacts, enhancing the model's stability in real-world clinical scenarios. Attached Figure Description
[0095] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention and do not constitute a limitation thereof.
[0096] Figure 1 This is a diagram of the overall system architecture of the present invention.
[0097] Figure 2 The image shows the fungal optimized attention module FGA diagram of this invention.
[0098] Figure 3 This is a schematic diagram of the fungal growth weight allocation optimizer of the present invention.
[0099] Figure 4 This is a schematic diagram of the cross-channel attention mechanism of the present invention.
[0100] Figure 5 This is a schematic diagram of the cross-attention mechanism of the present invention.
[0101] Figure 6 This is a schematic diagram of the multi-head attention mechanism of the present invention. Detailed Implementation
[0102] 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 embodiments. Of course, the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0103] Example 1
[0104] First, the medical image dataset is preprocessed and augmented, and then divided into training, validation, and test sets in an 8:1:1 ratio. Next, a self-attention mechanism network based on a fungal growth optimization algorithm is constructed. By replacing the LPA attention mechanism in the traditional Transformer with the fungal optimization algorithm, an encoder-decoder architecture is built to enhance feature saliency and boundary clarity. Subsequently, the preprocessed data is input into the network for iterative training until the model converges. Finally, the optimal model trained is used to perform medical image segmentation tasks, outputting high-precision lesion region detection results.
[0105] The specific implementation steps of the above method are as follows:
[0106] Step 1: Preprocess the input image dataset, perform data augmentation, and divide the dataset into training, test, and validation sets in an 8:1:1 ratio;
[0107] Step 2: Construct a feedforward neural network based on a self-attention mechanism using a fungal growth optimization algorithm. The encoder-decoder network based on the fungal growth optimization algorithm and Transformer uses the fungal growth optimization algorithm to replace the LPA attention machine in Transformer, further enhancing the accuracy of the network and solving the problems of insignificant features and blurred boundaries caused by imaging devices.
[0108] Step 3: Input the preprocessed image dataset into a feedforward neural network based on a self-attention mechanism using a fungal growth optimization algorithm for training to obtain the optimal model;
[0109] Step 4: After training is complete, input the image dataset into the obtained optimal model to detect the segmentation results of the medical image dataset;
[0110] The specific process in step 1 is as follows:
[0111] Step 1.1: Divide the medical image dataset into a training set and a validation set in a ratio of 8:1:1.
[0112] Step 1.2: Load the images and masks from the training and test sets of the medical image dataset using cv2, and resize the images and masks to 256×256.
[0113] Step 1.3: The mask was grayscaled before being converted to a PIL image, and then the pixel values were normalized to [0,1] by dividing by 255. The grayscale and normalization formulas are as follows:
[0114]
[0115] Where R, G, and B are the values of the red, green, and blue channels of the image, respectively, and Out is the image after grayscale conversion and normalization.
[0116] Step 1.4: Convert the image from BGR format to RGB format.
[0117] Step 1.5: Perform data augmentation and preprocessing on the training set data by performing random scaling, random horizontal flipping, random vertical flipping, random cropping, and labeling. This data augmentation process, by introducing diversity and uncertainty, not only improves the robustness and generalization ability of the model but also increases attention to the details of the target, making the model more adaptable to slight changes in data distribution. Mean = (0.402, 0.402, 0.402), Std = (0.298, 0.298, 0.298), and the standardization formula is as follows:
[0118]
[0119] Where Input is the input image, Mean is the mean, Std is the standard deviation, and Normalized is the image after standardization.
[0120] Step 2 is specifically as follows:
[0121] Step 2.1: Due to the advantages of Transformer in capturing long-range dependencies, we replace the traditional convolutional operation with a Transformer encoder block. To construct a multi-scale feature encoding network, we choose either SwingTransformer or PVT_v2 as the backbone network, configuring the output channels as follows: Swing_L version [192, 384, 768, 1536], Swing_B version [128, 256, 512, 1024], and PVT_v2_b2 version [64, 128, 320, 512]. When loading pre-trained weights, parameter filtering is performed, retaining only the parameters of convolutional and normalized layers that match the current network structure.
[0122] Step 2.2: Perform dynamic multi-channel feature fusion, construct a feature pyramid structure, and establish feature interaction through upsampling operations, as follows.
[0123] F′4=Conv 3×3 (F4)
[0124] F′3=Upsample(F′4)⊙Conv 3×3 (F3)
[0125] F′2=Upsample(F′3)⊙Conv 3×3 (F2)
[0126] F′1=Upsample(F′2)⊙Conv 3×3 (F1)
[0127] After fusion, the feature map set {F′1, F′2, F′3, F′4} is obtained.
[0128] Step 2.3: Block-based reconstructed local path attention, first dividing the input feature map into blocks according to space, and then... The region is divided into 2×2 sub-regions along both its height and width, and then independent attention is calculated. For each sub-region, a self-attention mechanism based on the fungal growth optimization algorithm, FGAttention, is applied.
[0129] F′ ij =FGAttention(F ij )
[0130] The processed sub-regions are then stitched together to form a complete feature map.
[0131]
[0132] Step 2.4: Implementation of the channel attention mechanism (FGAttention submodule) to simulate longitudinal hyphal growth.
[0133] α c =σ(W2·δ(W1·Avg(F)))
[0134] in Let δ be the MLP weight matrix, δ be the ReLU activation function, and σ be the Sigmoid activation function.
[0135] Step 2.5: Implementation of spatial attention mechanism (FGAttention submodule) to simulate the lateral expansion of hyphae.
[0136] α s =σ(Conv 3×3 (F))
[0137] Where MaxPool is max pooling, AvgPool is average pooling, and Conv... 3×3 For convolution operations
[0138] Step 2.6: The implementation method of the cross-attention module is as follows: simulating mycelial network interconnection.
[0139] Input feature map dimensionality transformation:
[0140] x permuted =permute(x, [0, 2, 3, 1])
[0141] x seq=reshape(x) permuted [B, H·W, C])
[0142] Multi-head attention calculation:
[0143] attn out =MHA(x seq x seq x seq )
[0144] Restoring spatial dimensions:
[0145] x out =permute(attn) out [0, 2, 1])
[0146] x out =reshape(x) out [B, C, H, W])
[0147] Step 2.7: The implementation of its fungal growth optimization algorithm includes:
[0148] Step 2.7.1 Calculate the characteristic variance for each attention branch as an indicator of nutrient concentration:
[0149] richness=var(fm,dim=(1,2,3))
[0150] Where fm is the input feature map
[0151] Formula for calculating weight increment:
[0152] Δ=γ·richness·w i
[0153] Where γ is the learnable base growth rate, w i The mycelial weight of the current branch
[0154] Weight update formula:
[0155] w new =w i ·η+Δ
[0156] Where η is the learnable nutrient consumption rate.
[0157] The parameter constraints of the hyphal network weight allocator include:
[0158] The nutrient consumption rate η ranges from [0.9, 1.0], with an initial value of 0.95; the basal growth rate γ ranges from [0.05, 0.2], with an initial value of 0.1; and the mycelial weight w... i Initialize w using a uniform distribution i~∪(0.8, 1.2)
[0159] The implementation method of the dynamic attenuation mechanism described in step 2.7.2 includes:
[0160] Initialize the branch weights E = [e1, e2, e3], where e1 = 1.0, e2 = 0.8, and e3 = 0.6.
[0161] A decay operation is performed every 10 training iterations:
[0162] E new =E·λ
[0163] Where λ∈[0.95,0.99] is the decay rate, and the decay operation is activated only during the training phase.
[0164] The processing method of the fork optimization module in step 2.8 includes:
[0165] The input feature map is bisected along the height dimension:
[0166] x0, x1 = split(x, dim = 2)
[0167] For each sub-feature map, bisect it along the width dimension:
[0168] x 00 x 01 =split(x0, dim=3)
[0169] x 10 x 11 =split(x1, dim=3)
[0170] Four-branch parallel processing:
[0171] y i =F i (x ij )·w i i = 0, 1, 2, 3
[0172] Where F i w is the attention processing function. i Learnable branch weights
[0173] Branch weight w i Decrease every 5 training iterations:
[0174] w new =w i ·β
[0175] Where β∈[0.85,0.95] is the attenuation coefficient.
[0176] Recombination output formula:
[0177] x out =concat(y0,y1,y2,y3)+x
[0178] The initialization method for the bifurcation weight is as follows:
[0179] Initial value setting: w i = [1.0, 0.9, 0.8, 0.7], with the attenuation coefficient β fixed at 0.9.
[0180] Step 2.9 The decoder uses a progressive upsampling structure for feature fusion:
[0181]
[0182] Where D is the decoding convolutional layer. For channel splicing operation
[0183] Step 3 includes the following steps:
[0184] Precision, Accuracy, Balanced Accuracy, Recall, and F1-score are used as evaluation metrics to assess the training and testing results. The function expressions for each evaluation metric are as follows:
[0185]
[0186] In this context, TP, TN, FP, and FN represent the true positive class, true negative class, false positive class, and false negative class, respectively. Precision measures the proportion of samples that the model predicts as positive when they are actually positive. Accuracy measures the proportion of samples correctly predicted by the model out of the total sample. Recall measures the proportion of samples correctly identified by the model out of all samples that are actually positive. F1-score is the harmonic mean of precision and recall, used to balance these two metrics, and is particularly suitable for class imbalance problems.
[0187] The results of comparing this embodiment with current mainstream medical image segmentation models on the CVC-300 dataset are shown in Table 1.
[0188] Table 1. Performance comparison of segmentation models on the CVC-300 dataset.
[0189] Segmentation Model Precision Accuracy Recall VGG16 77.78 75.00 70.00 ResNet-50 82.35 79.45 76.92 ResNet-101 85.25 83.20 83.33 ViT 88.00 85.50 86.27 Method of this embodiment 92.31 90.80 91.67
[0190] Table 1 compares the performance of different segmentation models on the CVC-300 dataset, with evaluation metrics including Precision, Accuracy, and Recall. The results show that the method in this embodiment achieves the best performance across all three metrics: Precision (92.31%), Accuracy (90.80%), and Recall (91.67%), demonstrating its superior segmentation performance compared to other comparative models.
[0191] Specifically, VGG16's precision, accuracy, and recall are 77.78%, 75.00%, and 70.00%, respectively, which are relatively low. ResNet-50 shows improvement over VGG16, with precision and recall reaching 82.35% and 76.92%, respectively. ResNet-101 further improves performance, achieving accuracy and recall of 85.25% and 83.33%, respectively. ViT, by introducing the Transformer architecture, performs even better across all metrics, with accuracy of 88.00% and recall...
[0192] In summary, the method presented in this embodiment achieves significant performance improvements in dermatology image segmentation tasks through effective improvement strategies, particularly in Precision and Recall metrics, demonstrating stronger target recognition capabilities and segmentation stability. This proves the effectiveness of this method when processing the CVC-300 dataset.
[0193] Example 2
[0194] This embodiment further validates the effectiveness of the proposed method in skin disease image segmentation by comparing it with the VGG16 and ViT models. The experiment used the CVC-ClinicDB dataset, and the evaluation metrics included Precision, Recall, F1-score (harmonic mean of precision and recall), and Accuracy.
[0195] Table 2 Performance comparison of different segmentation models on the CVC-ClinicDB dataset
[0196] Segmentation Model Precision Recall F1 score Accuracy VGG16 76.92 72.73 74.77 78.51 ViT 86.67 83.33 84.97 87.20 Method of this embodiment 93.02 91.67 92.34 94.12
[0197] In comparison with VGG16 and ViT, the method of this embodiment shows significant advantages:
[0198] Table 2 compares the performance of different segmentation models on the CVC-ClinicDB dataset, with evaluation metrics including Precision, Recall, F1-score, and Accuracy. The results show that the invented method achieved the best performance across all four metrics: Precision (93.02%), Recall (91.67%), F1-score (92.34%), and Accuracy (94.12%), further validating its other segmentation performance metrics.
[0199] Specifically, VGG16's Precision, Recall, F1-score, and Accuracy were 76.92%, 72.73%, 74.77%, and 78.51%, respectively, showing relatively weak overall performance. ViT, by introducing a Transformer structure, significantly outperformed traditional CNN models in various metrics, achieving Precision, Recall, F1-score, and Accuracy of 86.67%, 83.33%, 84.97%, and 87.20%, respectively.
[0200] In summary, the method presented in this embodiment balances the VGG16 and ViT models across all evaluation metrics, with significant improvements in Recall and F1-score, demonstrating higher target detection rate and balanced classification performance. This further validates its strong performance in skin disease image segmentation tasks.
[0201] Example 3
[0202] This embodiment further compares the method of this embodiment with other popular segmentation network models, such as...
[0203] ResNet-101 and ViT were used to verify the superiority of the method in this embodiment for the task of segmenting images of skin diseases.
[0204] Table 3 Performance comparison of different segmentation models on the Kvasir dataset (Example 3)
[0205] Segmentation Model Precision Recall F1 score Accuracy ResNet-101 83.21 85.47 84.32 86.74 ViT 86.55 88.13 87.32 89.02 Method of this embodiment 89.67 91.24 90.44 92.16
[0206] In comparison with VGG16 and ViT, the method of this embodiment shows significant advantages:
[0207] Table 3 compares the performance of different segmentation models on the Kvasir dataset, with evaluation metrics including Precision, Recall, F1-score, and Accuracy. The results show that the invented method achieved the best performance across all four metrics: Precision (89.67%), Recall (91.24%), F1-score (90.44%), and Accuracy (92.16%), further validating its other segmentation performance metrics.
[0208] Specifically, ResNet-101's Precision, Recall, F1-score, and Accuracy were 83.21%, 85.47%, 84.32%, and 86.74%, respectively, showing relatively weak overall performance. ViT, by introducing a Transformer structure, significantly outperformed traditional CNN models in various metrics, achieving Precision, Recall, F1-score, and Accuracy of 86.55%, 91.24%, 90.44%, and 92.16%, respectively.
[0209] In summary, the method in this embodiment balances the ResNet-101 and ViT models across all evaluation metrics, with significant improvements in precision and accuracy, demonstrating higher target detection rate and balanced classification performance, further validating its strength in skin disease image segmentation tasks.
[0210] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A medical image depth segmentation method based on an attention mechanism and Transformer using a fungal growth optimization algorithm, characterized in that, Includes the following steps: S1: Preprocess the input image dataset, perform data augmentation, and divide the dataset into training set, test set, and validation set in an 8:1:1 ratio; S2: Construct a feedforward neural network based on a self-attention mechanism of a fungal growth optimization algorithm. The encoder-decoder network based on the fungal growth optimization algorithm and Transfomer uses an attention mechanism based on the fungal growth optimization algorithm to replace the self-attention mechanism in Transfomer. S3: Input the preprocessed image dataset into a feedforward neural network based on the self-attention mechanism of the fungal growth optimization algorithm for training to obtain the optimal model; S4: After training, input the image dataset into the obtained optimal model to detect the segmentation results of the medical image dataset.
2. The medical image depth segmentation method based on the attention mechanism of the fungal growth optimization algorithm and Transformer according to claim 1, characterized in that, Step S1 includes the following steps: S11: Preprocess the input image dataset, perform data augmentation, and divide the dataset into training set, test set, and validation set in an 8:1:1 ratio; S12: Construct a feedforward neural network based on a self-attention mechanism using a fungal growth optimization algorithm. The encoder-decoder network based on the fungal growth optimization algorithm and Transfomer uses the fungal growth optimization algorithm to replace the LPA attention mechanism in Transfomer. S13: Input the preprocessed image dataset into a feedforward neural network based on a self-attention mechanism of fungal growth optimization algorithm for training to obtain the optimal model; S14: After training, input the image dataset into the obtained optimal model to detect the segmentation results of the medical image dataset.
3. The medical image depth segmentation method based on the attention mechanism of the fungal growth optimization algorithm and Transformer as described in claim 1, characterized in that, Step S11 includes the following steps: Step 1.1: Divide the medical image dataset into a training set and a validation set in an 8:1:1 ratio; Step 1.2: Load the images and masks from the training and test sets of the medical image dataset using cv2, and resize the images and masks to 256×256; Step 1.3: The mask was grayscaled before being converted to a PIL image, and then the pixel values were normalized to [0,1] by dividing by 255. The grayscale and normalization formulas are as follows: Where R, G, and B are the values of the red, green, and blue channels of the image, respectively, and Out is the image after grayscale conversion and normalization; Step 1.4: Convert the image from BGR format to RGB format; Step 1.5: Perform random scaling, random horizontal flipping, random vertical flipping, random cropping, and labeling operations on the training set data to perform data augmentation and preprocessing; Mean = (0.402, 0.402, 0.402), Std = (0.298, 0.298, 0.298), and the standardization formula is as follows: Where Input is the input image, Mean is the mean, Std is the standard deviation, and Normalized is the image after standardization.
4. The medical image depth segmentation method based on the attention mechanism of the fungal growth optimization algorithm and Transformer as described in claim 1, characterized in that, Step S2 includes the following steps: Step 2.1: Construct a multi-scale feature encoding network. Select Swing Transformer or PVT_v2 as the backbone network, and configure the output channels as follows: Swing_L version output channels [192,384,768,1536], Swing_B version output channels [128,256,512,1024], PVT_v2_b2 version output channels [64,128,320,512]. When loading pre-trained weights, perform parameter filtering and only retain the parameters of convolutional layers and normalized layers that match the current network structure. Step 2.2: Perform dynamic multi-channel feature fusion, construct a feature pyramid structure, and establish feature interaction through upsampling operations, as follows. F4 ′ =Conv 3×3 (F4) F3 ′ =Upsample(F4 ′ )⊙Conv 3×3 (F3) F2 ′ Upsample(F3) ′ )⊙Conv 3×3 (F2) F1 ′ Upsample(F2) ′ )⊙Conv 3×3 (F1) After fusion, the feature map group {F1} is obtained. ′ F2 ′ F3 ′ F4 ′ }; Step 2.3: Block-based reconstructed local path attention, first dividing the input feature map into blocks according to space, and then... The region is divided into 2×2 sub-regions along both the height and width, and then independent attention is calculated. For each sub-region, the self-attention mechanism FGAttention based on the fungal growth optimization algorithm is applied. F′ ij =FGAttention(F ij ) The processed sub-regions are then stitched together to form a complete feature map. Step 2.4: Implementation of the channel attention mechanism to simulate longitudinal hyphal growth a c =σ(W2·δ(W1·Avg(F))) in Let be the MLP weight matrix, δ be the ReLU activation function, and σ be the Sigmoid activation function; Step 2.5: Implementation of spatial attention mechanism to simulate lateral hyphal expansion; a s =σ(Conv 3×3 (F)) Where MaxPool is max pooling, AvgPool is average pooling, and Conv... 3×3 This is a convolution operation; Step 2.6: The implementation method of the cross-attention module is as follows: simulating the dimensionality transformation of the input feature map of the mycelial network interconnection: x permuted =permute(x,[0,2,3,1]) x seq =reshape(x permuted ,[B,H·W,C]) Multi-head attention calculation: attn out =MHA(x seq ,x seq ,x seq ) Restoring spatial dimensions: x out =exchanges(attn out ,[0,2,1]) x out =reshape(x out ,[B,C,H,W]) The processing method of the fork optimization module in step 2.7 includes: The input feature map is bisected along the height dimension: x0,x1 = split(x,dim=2) For each sub-feature map, bisect it along the width dimension: x 00 ,x 01 =split(x0,dim=3) x 10 ,x 11 =split(x1,dim=3) Four-branch parallel processing: y i =F i (x ij )·w i ,i=0,1,2,3 Where F i For the attention processing function, w i Learnable branch weights Branch weight w i Decrease every 5 training iterations: In new =in i ·β Where β∈[0.85,0.95] is the attenuation coefficient. Recombination output formula: x out =concat(y0,y1,y2,y3)+x The initialization method for the bifurcation weight is as follows: Initial value setting: w i = [1.0, 0.9, 0.8, 0.7], with the attenuation coefficient β fixed at 0.9; Step 2.8 The decoder uses a progressive upsampling structure for feature fusion: Where D is the decoding convolutional layer. This is for channel splicing operations.
5. The medical image depth segmentation method based on the attention mechanism of the fungal growth optimization algorithm and Transformer according to claim 1, characterized in that, In step 2.7, the fungal growth optimization algorithm implementation includes the following steps: Step 2.7.1 Calculate the characteristic variance for each attention branch as an indicator of nutrient concentration: richness=var(fm,dim=(1,2,3)) Where fm is the input feature map Formula for calculating weight increment: Δ=γ·richness·w i Where γ is the learnable base growth rate, w i The mycelial weight of the current branch Weight update formula: w new =w i ·h+D Where η is the learnable nutrient consumption rate; The parameter constraints of the hyphal network weight allocator include: The nutrient consumption rate η ranges from [0.9, 1.0], with an initial value of 0.95; the basal growth rate γ ranges from [0.05, 0.2], with an initial value of 0.1; and the mycelial weight w... i Initialize w using a uniform distribution i ~∪(0.8,1.2) The implementation method of the dynamic attenuation mechanism described in step 2.7.2 includes: Initialize the branch weights E = [e1, e2, e3], where e1 = 1.0, e2 = 0.8, and e3 = 0.
6. A decay operation is performed every 10 training iterations: AND new =E·λ Where λ∈[0.95,0.99] is the decay rate, and the decay operation is activated only during the training phase.
6. The medical image depth segmentation method based on the attention mechanism of the fungal growth optimization algorithm and Transformer according to claim 1, characterized in that, Step S14 includes the following steps: Precision, Accuracy, Balanced Accuracy, Recall, and F1-score are used as evaluation metrics to assess the training and testing results. The function expressions for each evaluation metric are as follows: In this context, TP, TN, FP, and FN represent the true positive class, true negative class, false positive class, and false negative class, respectively. Precision measures the proportion of samples that the model predicts as positive when they are actually positive. Accuracy measures the proportion of samples that the model correctly predicts out of the total sample. Recall measures the proportion of samples that the model correctly identifies out of all samples that are actually positive. F1-score is the harmonic mean of precision and recall, used to strike a balance between these two metrics.
7. The medical image depth segmentation method based on the attention mechanism of the fungal growth optimization algorithm and Transformer according to claim 1, characterized in that, Step S4 includes the following operations: After the model training is completed, the best model from the training is used to perform validation on a medical image validation set to detect the segmentation effect in the medical images.