Improved genetic algorithm for multi-threshold optimization in digital pathology image segmentation

This section explores the effectiveness of the improved genetic algorithm for multi-threshold optimization in pathological image segmentation. It provides an overview of the data augmentation, model training, evaluation metrics, and a detailed analysis of algorithm performance, including comparison with traditional methods and statistical validation.Data augmentation and model training Data augmentationTo enhance the model’s adaptability to new data, we used extensive data augmentation techniques via the ImageDataGenerator class, including:

(1)

Random rotation Rotating images within a random range to simulate different viewpoints and improve generalization.

(2)

Horizontal flipping Flipping images along the vertical axis to increase diversity without changing content.

(3)

Scale scaling Changing image sizes to simulate different resolutions, enhancing generalization.

These techniques enriched the training data, helping the model learn robust feature representations.Model trainingWe adopted a transfer learning strategy, initializing our model with pretrained weights. Key steps included:

(1)

Weight initialization Using pretrained model weights to initialize the new model.

(2)

Freezing layers Freezing the initial layers and fine-tuning the top layers.

(3)

Training Using the gradient descent algorithm and the .fit_generator() method for training, which includes online data augmentation.

This strategy accelerates convergence and enhances the model’s recognition and generalization capabilities. Model evaluationWe used several metrics to evaluate the model’s performance:(1) Sensitivity Measures the ability to identify positive cases.$$\:Sensitivity=\frac{TP}{TP+FN}$$
(14)
(2) Specificity Measures the ability to identify negative cases.$$\:Specificity=\frac{TN}{TN+FP}$$
(15)
(3) Accuracy Overall classification accuracy.$$\:Accuracy=\frac{TP+TN}{TP+TN+FP+FN}$$
(16)
(4) Intersection over Union (IOU) Evaluates segmentation accuracy.$$\:IOU=\frac{TP}{TP+FP+FN}$$
(17)
(5) Dice coefficient Another segmentation performance metric.$$\:Dice\:Coefficient=\frac{2\times\:TP}{2\times\:TP+FP+FN}$$
(18)
The Dice coefficient is another metric for assessing segmentation performance, similar to IOU but giving higher weight to the intersection.By quantitatively calculating these metrics, we can obtain scores that reflect the model’s performance in different aspects. The calculation of performance metrics is shown in Table 1.Table 1 Performance metrics summary.These metrics indicate the model performs well across all datasets, with high sensitivity and specificity, and good IOU and Dice coefficients, important for segmentation tasks.We also performed qualitative analysis by visualizing prediction results to identify potential misclassifications and assess sensitivity to different sample types. The visualization results are shown in Fig. 1.Fig. 1Comparison of model performance on different datasets.Through comprehensive quantitative and qualitative evaluations, we obtained valuable insights for model improvement, confirming its strong performance and generalization capabilities.Threshold selection results of the improved genetic algorithmIn multi-threshold optimization algorithms, the selection of thresholds directly impacts the outcome of image segmentation. This section details the comparison of segmentation effects under different thresholds for the improved genetic algorithm presented in this paper and the original genetic algorithm.Comparison of Segmentation effects under different thresholdsQuantitative analysisTo evaluate the segmentation effects of the improved genetic algorithm compared to the original genetic algorithm, we used metrics such as precision, recall, and F1 score. Table 2 presents these metrics for various thresholds (0.01 to 0.10).Table 2 Comparison of Segmentation effects under different thresholds between the Improved Genetic Algorithm and the original genetic algorithm.These results validate the effectiveness of the improvements made to the genetic algorithm, demonstrating that the modified approach is superior in image segmentation tasks when compared to the original algorithm.Statistical testsTo determine the significance of performance differences, we used the t-test and Wilcoxon rank-sum test. t-test is a parametric test comparing the means of two samples. Wilcoxon rank-sum test (Mann-Whitney U test) is a nonparametric test comparing the medians of two samples.The statistical tests confirm that the performance difference is significant, with a p-value of 0.00195, indicating that the improved genetic algorithm performs significantly better than the original. Figure 2 presents a visual comparison of the performance of Improved GA (the improved genetic algorithm) and Original GA (the original genetic algorithm).Fig. 2Performance comparison between the improved GA and the original GA.In Fig. 2, the visualization depicts the precision distribution of both methods across various threshold values. By conducting statistical tests, we can ascertain that the performance disparity between the different threshold selection methodologies is statistically significant. The computed p-value is 0.00195, which is substantially lower than the conventional significance level of 0.05. This low p-value suggests that the observed performance difference is highly unlikely to have occurred by chance alone, indicating a significant difference in performance between the two methods. Therefore, the statistical test results affirm that the performance difference is highly significant, underscoring the exceptionally good performance of the improved method.Performance comparison with other threshold selection methodsWe compared the improved genetic algorithm with other methods: Histogram Thresholding, SVM, and PSO. The comparison metrics include segmentation quality, computation time, memory consumption, robustness, and flexibility. The comparison of the above evaluation indicators is shown in Table 3.Table 3 Performance comparison of different threshold selection algorithms.The improved genetic algorithm demonstrates superior segmentation quality and robustness, although it requires more computation time and memory. Its balance between accuracy and efficiency makes it suitable for complex image segmentation tasks.In conclusion, the Improved GA’s performance in image segmentation, as showcased through the comparison with other threshold selection methods, demonstrates its practical efficacy and competitive advantages for use in real-world image processing tasks.Additionally, we have also created box plots and bar graphs to further demonstrate the outstanding advantages of the improved GA algorithm presented in this paper. The box plot is shown in Fig. 3, and the bar chart is shown in Fig. 4.Fig. 3Box plots comparing computation time and segmentation quality.Fig. 4Bar graphs displaying average computation time and segmentation quality.By examining both Figs. 3 and 4, it becomes clear that the Improved GA has a comprehensive advantage. While it may not have the shortest computation time, its exceptional performance in segmentation quality makes it suitable for complex image segmentation tasks and applications that require high precision. In medical imaging, where complex images often require high-precision segmentation, the Improved GA demonstrates a significant advantage over the other three typical algorithms (Table 4).Table 4 Performance comparison between SAM and the improved genetic algorithm.Comparison with segment anything model (SAM)To further validate the effectiveness of the improved genetic algorithm in pathology image segmentation, we introduced the Segment Anything Model (SAM) as a comparison model. SAM, a general-purpose segmentation model based on large-scale pre-training, was tested on the same dataset as the genetic algorithm, with key metrics such as segmentation quality, computation time, and memory consumption compared.The experimental results indicate that while SAM performs well, particularly in flexible applications, it lags behind the improved genetic algorithm in segmentation quality, especially when dealing with complex pathology images. SAM’s longer computation time and higher memory consumption also highlight the advantages of the improved genetic algorithm in scenarios where high precision and resource efficiency are critical. Additionally, SAM’s generalization ability may be somewhat limited in specific applications, whereas the improved genetic algorithm is better suited to the demands of specialized tasks.Comparison with other improved GAs and Heuristic algorithmsTo thoroughly evaluate the performance of our improved GA, we compared it against several other improved versions of GAs, including Adaptive Genetic Algorithms (AGA), Hybrid Genetic Algorithms (HGA), and Multi-Objective Genetic Algorithms (MOGA). Additionally, we compared it with other popular heuristic algorithms such as Ant Colony Optimization (ACO), Differential Evolution (DE), and Simulated Annealing (SA). Table 5 presents the performance metrics for these algorithms, including segmentation quality (measured by accuracy and F1 score), computation time, and memory consumption.Table 5 Performance comparison of different genetic algorithms and heuristic algorithms.As shown in Table 5, the Improved GA outperforms other algorithms in terms of segmentation quality and computational efficiency. While Adaptive GA and Hybrid GA offer competitive accuracy and F1 scores, our improved GA demonstrates faster computation times and lower memory consumption. The performance of other heuristic algorithms like ACO, DE, and SA also underscores the strengths of our approach, particularly in achieving high precision in complex segmentation tasks.The inclusion of comparisons with other improved versions of Genetic Algorithms (GAs) and heuristic algorithms highlights the distinct advantages of our proposed approach. While algorithms like Adaptive GA, Hybrid GA, and Multi-Objective GA show promising results, particularly in specific applications, our improved GA offers a better balance between segmentation quality and computational efficiency, which is critical in pathology image analysis.The comparison with other heuristic algorithms, such as Ant Colony Optimization (ACO), Differential Evolution (DE), and Simulated Annealing (SA), further reinforces the effectiveness of our method. Despite the robustness of these algorithms in general optimization tasks, they fall short in the specific demands of multi-threshold optimization in digital pathology, where precision and computational efficiency are paramount.Performance analysis of the algorithmPerformance analysis is crucial to evaluate the improved genetic algorithm in multi-threshold optimization tasks. The analysis focuses on convergence speed, global optimality, and stability.Performance changes and convergence speedTo assess the algorithm’s performance and convergence, we record the optimal fitness value in each generation. Improvement in fitness value over iterations indicates the algorithm’s progression towards the optimal solution. A stable increase or plateau in the fitness value shows effective convergence, while significant fluctuations suggest potential issues like premature convergence or local optima traps.The convergence speed, reflected by the number of iterations needed to reach a predetermined performance standard, is crucial for practical applications. Fast convergence is highly desirable. By plotting the relationship between performance and iterations, we visualize the convergence speed of the algorithm. The performance changes and convergence speed during iteration are shown in Fig. 5.Fig. 5Performance changes and convergence speed during iteration.Fig. 6Comparison of final performance across.Different runsIn Fig. 5, the solid line represents the optimal fitness value per generation, and the dashed line shows the global optimal performance metric. The improved genetic algorithm shows a steady upward trend in performance, indicating good convergence speed without getting trapped in local optima.Global optimalityTo verify the algorithm’s ability to find the global optimal solution, we run the algorithm multiple times and compare the optimal solutions. Consistent or similar solutions across different runs suggest global optimality, indicating the algorithm is not trapped in local optima. The global optimality after multiple runs is depicted in Fig. 6.Figure 6 shows consistently high final performance metrics across all runs, approaching a certain optimal value with minimal differences. This indicates the algorithm’s capability to find high-quality solutions under various initial conditions, demonstrating robustness and stability.StabilityStability is assessed by analyzing the algorithm’s performance under different initialization conditions and random seeds. A stable algorithm shows similar performance across different runs, with minimal variation indicating good stability. Significant performance fluctuations suggest sensitivity to initialization or randomness. The experimental results for the stability of the algorithm in this paper are presented in Fig. 7.Fig. 7Comparison of performance fluctuations with different initializations and random seeds.Figure 7 demonstrates similar convergence trends and small fluctuations in performance curves across different initialization conditions, showing the algorithm’s consistent performance. The final performance metrics are close to the global optimal value, confirming the algorithm’s stability and reliability in practical applications.Time complexity analysisTo comprehensively understand the performance of the Improved Genetic Algorithm (Improved GA), a detailed analysis of its time complexity has been conducted. Time complexity is a critical metric for evaluating how the execution time of an algorithm scales with the size of the input. In the context of genetic algorithms, the primary time-consuming operations are selection, crossover, mutation, and fitness evaluation.

(1)

Selection Operation: The “Monarch Strategy” selection mechanism has a time complexity of O(N), where N is the size of the population.

(2)

Crossover Operation: The optimized crossover operation also exhibits a time complexity of O(N), as it involves processing each individual in the population.

(3)

Mutation Operation: The mutation operation also has a time complexity of O(N).

(4)

Fitness Evaluation: Fitness evaluation is the most time-intensive part of the algorithm, with its complexity depending on the complexity of the image segmentation task and the implementation of the fitness function. The complexity of fitness evaluation is denoted as F(N), where N represents the number of pixels or features in the image.

Considering these factors, the overall time complexity of the Improved GA can be expressed as O (G * N * F(N)), where G is the number of generations, N is the population size, and F(N) is the complexity of the fitness evaluation function.To visually represent the time complexity, an experimental analysis was conducted, and a 3D plot was generated to illustrate the time complexity under various combinations of population size and number of generations. Each point in the plot corresponds to a specific combination of population size and generation, with the color intensity reflecting the magnitude of the time complexity. Text labels were added to provide direct numerical values for each point. The 3D plot of the Time Complexity Analysis of the Improved Genetic Algorithm is shown in Fig. 8.Fig. 8The 3D plot of the time complexity analysis of the improved genetic algorithm.The experimental results indicate that the time complexity increases with both the population size and the number of generations. This is intuitive, as each individual in the population requires processing through selection, crossover, mutation, and fitness evaluation, and these operations are directly proportional to the population size and the number of generations.In practical scenarios, the choice of population size and number of generations involves a trade-off between computational efficiency and solution quality. For applications where high-quality solutions are paramount, the Improved GA’s superior performance justifies its higher computational demands. The time complexity analysis provides a profound understanding of the Improved GA’s performance, aiding in informed decision-making when designing and applying genetic algorithms in practice.Ablation experimentIn order to further evaluate the algorithm in this article, ablation studies were conducted, and the ablation experiments in this article aim to analyze and evaluate the influence of different components in the algorithm.The primary experiment compared the full algorithm with three variants: one without a selection strategy, one without a crossover operation, and one without a mutation operation. These variants were created by removing specific operations from the complete algorithm to explore their impact on performance.After conducting the ablation experiment, performance data of each variant were obtained, and the results of the ablation experiment were presented in a table (as shown in Table 6) and a graph (as shown in Fig. 9) to visually compare the performance differences of different variants.Table 6 Comparison of ablation experiment performance.Fig. 9Performance comparison of algorithm variants.Fig. 10Total running time vs. number of generations.The results clearly show that the selection strategy significantly impacts the algorithm’s performance. Removing the selection strategy led to notable declines in accuracy, recall, and F1 Score, highlighting its critical role in maintaining algorithmic efficiency and effectiveness. Additionally, the removal of crossover and mutation operations also impacted performance, albeit to a lesser extent. The slight decrease in performance following the removal of the crossover operation suggests its role in introducing new solutions into the algorithm, aiding in exploration and diversity. The relatively minor impact of removing the mutation operation implies that while it helps explore new solutions, its core contribution is not as significant as the selection strategy and crossover operation in the current parameter setting and problem definition.Through ablation experiment, the study not only validates the effectiveness of the algorithm but also provides deep insights into how each component collaborates, offering valuable perspectives for further research and development.Running time analysisIn the evaluation of the genetic algorithm presented, a critical aspect was the assessment of its computational efficiency, focusing on the relationship between the number of generations and the total running time required for execution. This analysis is pivotal for understanding the scalability of the algorithm and for practical implementations where computational resources may be limited.The running times were measured using a standard system, conducted on a computing environment with a CPU of Intel Core i7-8700 K and a GPU of NVIDIA GeForce RTX 2080Ti.The genetic algorithm was configured with a population size of 100 individuals, with the complexity of the fitness function moderated to reflect typical use cases in computational biology and optimization problems. The running time over a range of generations from 1 to 100 was examined to provide a comprehensive view of the algorithm’s performance under different load conditions. The time taken for each generation, which included the evaluation of the fitness function for each individual in the population, was measured. The average time per generation was consistently around 10 s. This duration remained consistent across all tests, indicating stable computational demands per generation, irrespective of the sequence in the overall run.The total running time exhibited a linear relationship with the number of generations, as illustrated in the Fig. 10. For a single generation, the algorithm required 10 s, scaling up to 1000 s for 100 generations. This linearity is an expected outcome given that each generation involves a fixed amount of computation — specifically, the evaluation of the fitness function for each individual.The linear increase in running time with the number of generations confirms the algorithm’s predictable behavior under varying operational scales. This predictability is advantageous for users needing to estimate the time requirements for larger problems or longer runs. However, it also highlights the importance of optimizing the efficiency of the fitness function evaluation and possibly reducing the population size or the number of generations for very large-scale problems to manage the computational cost effectively. The conducted running time analysis underscores the genetic algorithm’s consistency and scalability.Convergence process analysisThe convergence process of the genetic algorithm under study is crucial for understanding its effectiveness in solving optimization problems and reaching satisfactory solutions within reasonable time frames. The genetic algorithm was tested on a series of benchmark optimization problems commonly used in the field. The focus was on both the rate of convergence and the quality of the solutions obtained. Parameters were adjusted to evaluate their impact on the convergence process.Convergence was assessed by monitoring the fitness scores of the population over successive generations. The primary metric for convergence was the change in average fitness of the population, alongside the best fitness score observed. The experiments were repeated multiple times to ensure statistical significance of the results.(1) Rate of Convergence: The algorithm demonstrated a rapid improvement in fitness scores within the initial generations, followed by a gradual approach towards a plateau. This suggests that the majority of significant improvements were made early in the process, with subsequent generations refining the solutions. Rate of Convergence of the Genetic Algorithm as shown in Fig. 11.Fig. 11Rate of convergence of the genetic algorithm.Fig. 12Impact of mutation rates on convergence.(2) Impact of Parameters: Variations in mutation rates significantly influenced the convergence rate. Higher mutation rates generally led to faster convergence but at the risk of instability in the solution quality. Conversely, lower mutation rates stabilized the convergence process but required more generations to reach optimal fitness levels. Impact of Mutation Rates on Convergence of the Genetic Algorithm as shown in Fig. 12.The convergence analysis shows that the genetic algorithm’s efficiency can be improved by tailoring its operations and selection methods. Convergence is closely tied to the right parameter settings, which vary by problem. Understanding this process helps predict the needed generations for a good solution and adjust parameters for better performance. This analysis underscores the importance of convergence in genetic algorithms and paves the way for future improvements.Samples of data set images and segmentation resultsTo provide a clear visualization of the dataset and the effectiveness of the segmentation results, we have included representative samples of the images used in our experiments and the corresponding segmentation outcomes produced by the improved genetic algorithm. Figure 13 shows examples of original pathology images from the dataset. These images represent various original pathology images from the breast cancer dataset, illustrating various tissue structures and.staining patterns.Fig. 13Representative samples of original pathology images from the dataset.Fig. 14Segmentation results using the improved genetic algorithm.Figure 14 presents the segmentation results corresponding to the images in Fig. 13. The images display the results of applying the improved genetic algorithm, with different tissue regions accurately segmented and color-coded to distinguish between epithelial, stromal, and background areas.

Hot Topics

Related Articles