Multi-threshold image segmentation method based on quisqualis strategy improved genetic algorithm
By introducing a genetic algorithm with improved monarch strategy in image segmentation technology, the problem of insufficient segmentation accuracy and stability in the existing technology is solved, efficient and accurate segmentation in complex pathological images is achieved, and the reliability and calculation of diagnosis are improved. efficiency.
Patent Information
- Application Number
- CN202411373764.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-01-14
AI Technical Summary
The existing image segmentation technology has problems with insufficient segmentation accuracy and stability when processing complex pathological images, especially in multi-threshold selection and global optimal solution acquisition, making it difficult to achieve accurate identification and segmentation in complex environments.
Genetic algorithms based on monarch strategy improvement are introduced, and population diversity and convergence speed are improved by optimizing the fitness evaluation mechanism and cross operators, and an adaptive parameter adjustment mechanism is adopted to ensure that the algorithm quickly converges to the global optimal solution in multi-threshold problems.
It significantly improves the accuracy and stability of image segmentation, enhances the adaptability and flexibility of the algorithm, shortens the calculation time, realizes more efficient digital pathological image segmentation, and improves the reliability of diagnosis.
Smart Images

Figure CN119313696A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of medical image processing, and in particular relates to a multi-threshold image segmentation method based on a monarch strategy improved genetic algorithm. Background Art
[0002] In modern digital pathology, image segmentation is a key step in analyzing tissue samples, which directly affects subsequent diagnosis and treatment decisions. Traditional image segmentation methods, including thresholding, edge-based segmentation, and region growing methods, are effective to a certain extent, but they often face challenges when processing complex pathological images, especially when the boundaries between cells and tissues are blurred, noise interference, and deformation occur.
[0003] In recent years, image segmentation technology based on machine learning and deep learning has received widespread attention. Among them, algorithms such as support vector machine (SVM) and particle swarm optimization (PSO) are widely used in the segmentation of digital pathology images. However, these methods have limitations in multi-threshold selection and obtaining the global optimal solution.
[0004] In addition, existing genetic algorithms (GAs) have also shown good performance in image segmentation tasks, but traditional genetic algorithms often have shortcomings in convergence speed and stability. For example, traditional GAs may have insufficient diversity in the offspring population due to the limitations of the fitness evaluation mechanism, which in turn affects the accuracy and reliability of the segmentation results.
[0005] Although traditional thresholding methods, SVM and PSO have achieved certain results in some applications, they have several significant disadvantages when processing complex pathological images. First, traditional thresholding methods usually rely on global or local information and are easily affected by noise and illumination changes, resulting in inaccurate segmentation results, especially when the boundaries between cells and tissues are blurred.
[0006] Secondly, although machine learning-based algorithms, such as SVM, can effectively process certain features, their fitness evaluation mechanism often limits the global search capability of the algorithm in the multi-threshold selection problem, which will cause the model to stagnate at the local optimal solution and miss a better segmentation solution.
[0007] In addition, the shortcomings of traditional genetic algorithms in terms of convergence speed and stability are mainly due to their reliance on population diversity. Insufficient fitness evaluation may lead to the loss of high-quality solutions, which in turn affects the final segmentation effect. These problems make it difficult for existing technologies to achieve ideal segmentation accuracy and reliability when processing complex pathological images. Summary of the invention
[0008] The present invention aims to solve the deficiencies of existing image segmentation technology in digital pathology image processing, especially the challenges in multi-threshold selection and segmentation accuracy. Specific goals include:
[0009] 1. Improve segmentation accuracy: By improving the genetic algorithm, it can accurately identify and segment different tissue types in complex pathological images, thereby improving the reliability of diagnosis.
[0010] 2. Accelerate convergence speed: Optimize the fitness evaluation mechanism to ensure that the algorithm can quickly converge to the global optimal solution when dealing with multi-threshold problems and avoid the trap of local optimal solutions.
[0011] 3. Enhanced stability: Introducing the “monarch strategy” selection mechanism to improve population diversity, ensure the stability and consistency of the algorithm over multiple runs, and reduce the volatility of segmentation results.
[0012] 4. Adapt to complex environments: Improve adaptability in actual pathological image analysis by designing algorithms that can handle various lighting and noise conditions.
[0013] By solving the above technical problems, the present invention provides a multi-threshold image segmentation method based on the monarch strategy to improve the genetic algorithm, aiming to provide a more efficient, accurate and reliable solution for digital pathology image segmentation and promote research and application progress in the field of pathology.
[0014] The monarch strategy improved genetic algorithm proposed in this invention, namely the improved genetic algorithm, effectively overcomes the above shortcomings by introducing the "monarch strategy" selection mechanism and optimized crossover operator, thereby improving the accuracy and stability of image segmentation. This innovation not only solves the limitations of traditional methods, but also provides a more reliable tool for image analysis in digital pathology.
[0015] A multi-threshold image segmentation method based on a monarch strategy improved genetic algorithm comprises the following steps:
[0016] The improved genetic algorithm of the present invention is mainly used for pathological image segmentation, especially when processing complex tumor tissue slice images. It optimizes the multi-threshold selection and can achieve accurate segmentation between different gray levels, especially suitable for images with multiple tissue types or complex structures. The genetic algorithm can effectively identify complex boundaries and overlapping structures, and improve recognition accuracy by automatically adjusting segmentation parameters. These characteristics make the present invention show a wide range of application prospects in the field of medical image analysis.
[0017] Step 1: Initialize the population:
[0018] A certain number of individuals are randomly generated, each of which represents a set of thresholds. The initial threshold is set by a random generation method, and multiple candidate thresholds are randomly selected from the defined threshold range (0-255) for image segmentation. The thresholds specifically included in the set of thresholds are determined according to the pathological image to be segmented. Thresholds play a key role in image segmentation because they determine how pixels in the image are assigned to different categories or regions. By setting multiple thresholds, the grayscale value of the pixel can be compared with the threshold to determine whether the pixel belongs to the foreground (region of interest) or the background. In complex images, multiple thresholds may be required to effectively segment different regions. The purpose is to find the best threshold combination to improve the effect of image segmentation.
[0019] Step 2: Initial fitness evaluation:
[0020] For each individual, according to the characteristics of the pathological image, an indicator is selected to evaluate the performance of each individual to obtain the corresponding fitness value to measure its effectiveness in image segmentation. The fitness value reflects the effect of the individual in image segmentation.
[0021] Step 3: Monarch strategy selection:
[0022] The "monarch strategy" is used to select the best individual in the evaluation as the "monarch", and perform crossover and mutation operations with other individuals to generate new population individuals.
[0023] Step 4: Fitness re-evaluation:
[0024] Fitness re-evaluation is to evaluate the effectiveness of the newly generated individuals in the population after the crossover and mutation operations. First, according to the selected evaluation indicators, for each new individual's threshold combination, these thresholds are applied to perform image segmentation, generate segmentation results, and compare them with the true labels to calculate the corresponding fitness values. Then, the calculated fitness values are updated to the individual information to ensure that the fitness of the new population accurately reflects its segmentation effect. Through this series of steps, fitness re-evaluation ensures that the evolution of the population is based on the latest individual performance and continuously optimizes the image segmentation effect.
[0025] Step 5: Iterative Evolution:
[0026] Repeat steps 3 to 4 for iteration, and use an adaptive parameter adjustment mechanism to dynamically adjust the number of iterations and parameters of the genetic algorithm according to the real-time feedback of the segmentation results to ensure efficient convergence and stable segmentation performance.
[0027] Step 6: Output:
[0028] After the termination condition is triggered, the individual with the highest fitness is selected as the final multi-threshold solution, and the solution is output as the threshold for image segmentation. This optimal solution will be used in the actual image segmentation task to complete the accurate segmentation of the target area.
[0029] The threshold is applied to segment the input pathological image to obtain the segmented result. The segmentation result is quantitatively and qualitatively analyzed to verify the effectiveness and superiority of the method.
[0030] In the multi-threshold image segmentation task, the algorithm can efficiently and stably find the optimal threshold combination to achieve accurate image segmentation.
[0031] Furthermore, the specific operations of step 3 are as follows:
[0032] (1) Selection of the monarch: In each round of iteration, the individual with the highest fitness is selected as the "monarch" based on the fitness evaluation results. The "monarch" not only represents the optimal solution for the current population, but also plays a guiding role.
[0033] (2) Monarch retention mechanism: When updating the population, ensure that the "monarch" individuals are retained to prevent the loss of excellent genes. By retaining the "monarch", the stability of the population can be maintained and a strong benchmark can be provided for subsequent evolution.
[0034] (3) Guided evolution: In the process of crossover and mutation, the information of the "monarch" is used to influence other individuals. The threshold parameter of the "monarch" is used as a reference point for crossover to encourage other individuals to move closer to a better solution, thereby improving the global search capability. Using a single-point crossover operation, the genes of the selected individuals are crossovered to generate new individuals, so that the threshold of the new individuals after crossover is still within the effective range.
[0035] (4) Promoting diversity: While guiding, set appropriate random mutations to prevent the population from falling into a local optimum. In this way, the diversity of the population is maintained and the exploration of more solution spaces is encouraged. The random mutation is achieved by slightly adjusting the threshold or randomly replacing some thresholds to enhance population diversity and prevent premature maturity.
[0036] Through the above steps, the monarch strategy not only improves the fitness of the population, but also effectively enhances the global search capability, thereby improving the effect of multi-threshold image segmentation.
[0037] Furthermore, in step 5, the following two termination conditions are set, and the iteration stops when one of them is met:
[0038] Maximum number of iterations: The algorithm stops after reaching the preset maximum number of iterations to avoid infinite loops. The maximum number of iterations here is set based on experience and is initially set based on parameters such as population size, number of individuals, crossover rate, and mutation rate.
[0039] Fitness convergence: In each round of iteration, monitor the changes in the fitness value of the population. If the fitness value of the population does not increase significantly in consecutive generations of iterations, it is judged to be close to convergence, indicating that the population has found the optimal solution and the iteration is stopped. At this time, the number of subsequent iterations is dynamically reduced. When the fitness value is found to have significantly improved, the number of iterations is appropriately increased to give the algorithm more opportunities to explore new solutions. The dynamic adjustment of the number of iterations is achieved by setting the fitness increment threshold.
[0040] Furthermore, in order to dynamically adjust the number of iterations of the genetic algorithm and significantly improve the fitness, the following describes the relevant settings:
[0041] (1) Definition of fitness increment;
[0042] In each iteration, the average fitness value of the current population is calculated and compared with the fitness value of the previous iteration. The fitness increment can be expressed as:
[0043] ΔF t =F t -F t-1
[0044] Where: ΔF t is the fitness increment of the tth iteration, F t is the average fitness value of the population in the tth iteration, F t-1 It is the average fitness value of the population in the t-1th round of iteration.
[0045] (2) Judgment of significant improvement;
[0046] Set a fitness increment threshold ∈ to judge the significant improvement or convergence of fitness. t When the threshold is exceeded, it is considered that the fitness has been significantly improved and the number of iterations needs to be increased; when the fitness increment ΔF t When it is less than this threshold, the fitness change is considered insignificant, indicating that the algorithm is close to convergence. Among them, ∈ is a small positive value, which is adjusted by experimental experience or problem complexity.
[0047] (3) Dynamically adjust the number of iterations
[0048] According to the fitness increment, the number of iterations of the genetic algorithm is dynamically adjusted. When the fitness is significantly improved, the number of iterations is increased; when the fitness change is not significant, the number of iterations is reduced. The formula for dynamically adjusting the number of iterations is:
[0049] Increase the number of iterations (when it improves significantly): T new =T current +γ·ΔF t
[0050] Reduce the number of iterations (when convergence): T new =T current -β
[0051] Midterm: T new is the adjusted maximum number of iterations, T current is the current number of iterations, γ is an incremental adjustment factor used to increase the number of iterations when the fitness is significantly improved. β is a fixed reduction factor used to reduce the number of iterations when the fitness change is not significant. Set γ=2 and β=3 as the initial values, which is a balance between exploration and computational efficiency.
[0052] Through the above iterative process, the genetic algorithm based on the monarch strategy can continuously optimize the individuals in the population, making them gradually approach the global optimal solution.
[0053] In one embodiment, F1-score, precision and recall are selected as evaluation indicators.
[0054] In summary, the "monarch strategy" selection mechanism plays a vital role in the genetic algorithm of the present invention. It not only maintains the diversity of the population and optimizes the global search capability, but also ensures that the global optimal solution is found more efficiently in complex multi-threshold selection problems through the fitness priority strategy. This innovative mechanism significantly improves the effect of digital pathology image segmentation, making the present invention have important application value and prospects in the field of image processing.
[0055] The technical solution of the present invention is based on the evolutionary principle of genetic algorithms. By simulating the gene crossover and mutation process in natural selection and genetics, it ensures that the solution space can be effectively explored and converged to the optimal solution in the multi-threshold selection problem. The use of biological principles ensures the efficiency and accuracy of the algorithm in solving complex image segmentation tasks.
[0056] Through the above technical measures, the present invention effectively solves the problem of insufficient accuracy and stability in digital pathology image processing in the prior art and provides a new solution.
[0057] The beneficial effects of the present invention are as follows:
[0058] Compared with the prior art, the technical solution of the present invention has the following advantages and positive effects:
[0059] (1) Improve segmentation accuracy:
[0060] By introducing an improved genetic algorithm, especially the "monarch strategy" selection mechanism, the accuracy and stability of segmentation are significantly improved. Experimental data show that the segmentation accuracy of the present invention is improved by more than 10% on average, which is specifically reflected in the improvement of the F1 score.
[0061] (2) Enhance adaptability:
[0062] The optimized crossover and mutation operations enable the algorithm to perform better in complex and changeable pathological image environments, effectively adapt to the characteristics of different images, and reduce errors caused by differences in image quality.
[0063] (3) Shorten calculation time:
[0064] The adaptive parameter adjustment mechanism enables the algorithm to automatically optimize during operation, improves the convergence speed, and thus effectively shortens the calculation time, reducing the running time by about 20% compared to traditional methods.
[0065] (4) Functional scalability:
[0066] The present invention is not only applicable to pathological image segmentation, but can also be extended to other fields, such as medical image analysis and computer vision, and has broad application potential.
[0067] Compared with the background technology, the present invention realizes the following differences in function:
[0068] Comprehensive index evaluation: Background technology often relies on a single index for evaluation, while the present invention adopts a comprehensive evaluation of multiple indicators to more comprehensively reflect the segmentation effect.
[0069] Dynamic optimization capability: The background technology lacks a dynamic adjustment mechanism during the evolution process, while the present invention realizes dynamic optimization of parameters through an adaptive mechanism, thereby improving the flexibility and effect of the algorithm.
[0070] In general, the technical solution of the present invention effectively overcomes the shortcomings of the prior art and provides a more accurate and efficient digital pathology image segmentation solution. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] Figure 1 It is a flowchart of a multi-threshold image segmentation method based on the monarch strategy to improve the genetic algorithm according to an embodiment of the present invention;
[0072] Figure 2 Box plots of computation time and segmentation quality of different threshold selection algorithms;
[0073] Figure 3 Bar graphs of computation time and segmentation quality for different threshold selection algorithms;
[0074] Figure 4 Performance changes and convergence speed during iterations;
[0075] Figure 5 Final performance comparison of different runtimes;
[0076] Figure 6 Compare the performance fluctuations for different initializations and random seeds. DETAILED DESCRIPTION
[0077] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0078] Example
[0079] A multi-threshold image segmentation method based on a monarch strategy improved genetic algorithm comprises the following steps:
[0080] Step 1: Data enhancement;
[0081] In the data enhancement phase, we adopted a series of strategies to improve the model's adaptability to unknown data. Using the ImageDataGenerator class, we implemented a wide range of data enhancement techniques on the existing breast cancer pathology raw image dataset. This includes operations such as random rotation, horizontal flipping, and scale scaling. In the process of data enhancement, the specific description of these operations is as follows:
[0082] (1) Random rotation: Increase the diversity of training samples by rotating images within a randomly selected range. This operation can simulate different perspectives and camera angles in the real world, thereby improving the model’s generalization ability when processing new data.
[0083] Suppose the original image is I and the rotation angle is θ, then the rotated image I rot It can be expressed as: rot =R(I,θ), where R represents the rotation operation. The R function rotates the original image I clockwise by an angle θ. This transformation keeps the center point of the image unchanged and only changes the direction of the image pixels. Random rotation operations can be automatically applied during training to enhance the robustness of the model.
[0084] (2) Horizontal flip: Flip the image along the vertical center line. Let I represent the original image, I flip represents the flipped image, then the horizontal flip operation can be simply expressed as: flip (x,y)=I(Wx,y), where W is the width of the image, and x and y are the horizontal and vertical coordinates of the image, respectively. This formula means that for each point (x,y) in the original image I, the value of the point (x,y) in the flipped image I is flip In (x, y), the horizontal coordinate x of the point is replaced by (Wx), while the vertical coordinate y remains unchanged. This flip operation is symmetrical, meaning that the left half of the image is mapped to the right half, and the right half is mapped to the left half. This transformation is often used for data enhancement in image processing to increase the generalization ability of the model. It does not change the content of the image, but only changes the direction of the image.
[0085] (3) Scaling: By changing the size of the image to increase the diversity of training samples. This operation can simulate images with different resolutions, thereby improving the generalization ability of the model when dealing with new data. Let I represent the original image, X represent the scaling operation, and s represent the scaling factor. The scaling operation can be expressed as: I scale = S(I, s), in this formula, I scale represents the scaled image. The S function scales the original image I with the scaling factor s. If s > 1, the image is enlarged; if 0 < s < 1, the image is shrunk. The scaling in the present invention uses the bicubic interpolation method.
[0086] These data augmentation means effectively enrich the diversity of training samples, help the model learn more robust feature representations, and thus improve the generalization ability of the model.
[0087] Step 2: Model training;
[0088] Use the EfficientNet-B0 deep learning model to extract high-level features from breast cancer pathology images. In terms of model training, we adopt a transfer learning strategy and initialize the model using pre-trained weights. In the transfer learning strategy, a pre-trained model is used, and its weights are used as the initialization weights of the new model. This pre-trained model is trained on a large dataset and has learned rich feature representations. Use these feature representations to initialize the EfficientNet-B0 deep learning model to obtain better performance on new tasks.
[0089] The weights of the pre-trained model are W pre . The EfficientNet-B0 deep learning model has L layers, and each layer has its corresponding weights W l , where l = 1, 2,..., L.
[0090] In transfer learning, a part of the layers of the pre-trained model is frozen, and only the top layer or several layers are fine-tuned. Let k be the number of frozen layers, then the first k layer weights in W pre will be directly used for the new model, and the weights of the subsequent (L - k) layers will be randomly initialized.
[0091] Let W init be the initialization weights of the new model, then we can use the following calculation formula to describe the transfer learning strategy:
[0092]
[0093] where, represents the first k layers of the pre-trained weights.
[0094] During model training, the gradient descent algorithm is used to update the model weights. Let α be the learning rate, is the gradient of the loss function J(W) with respect to the weight W, then the update of the weight W can be expressed as:
[0095]
[0096] In transfer learning, we only update W init The weights of the last (Lk) layers in , while the weights of the first k layers remain unchanged. Through this transfer learning strategy, good performance can be quickly obtained on new tasks while saving a lot of computing resources and time. In addition, since the pre-trained model has learned rich feature representations, these feature representations can be used to improve the generalization ability of the new model.
[0097] In model training, we adopt the strategy of transfer learning and use pre-trained weights to initialize the model, which greatly accelerates the convergence of the model, and then trains it through the .fit_generator() method. This method allows us to continue to use ImageDataGenerator for online data enhancement, which means that the model can receive differently transformed image samples at each iteration, further enhancing its recognition and generalization capabilities.
[0098] Through data enhancement processing and model training strategies, our model has strong learning ability and prediction accuracy while maintaining efficient computing.
[0099] Step 3: Initialize the population:
[0100] In the present invention, breast cancer pathology images have complex boundaries and diverse tissue features, so a large enough population is required to cover various possible threshold combinations. In the present invention, the population size is set to 50 individuals, the crossover rate is set to 0.6, and the mutation rate is set to 0.01. This setting balances the computational complexity and the search ability of the algorithm, can effectively cover the threshold space, and ensures a faster convergence speed. Each individual represents a set of threshold combinations. According to the breast cancer pathology image to be segmented, the individual set of thresholds specifically includes 3 thresholds. The first threshold is used to distinguish between background and foreground, set between grayscale values 30 and 100, the second threshold is used to further subdivide the foreground and tumor area, set between 100 and 170, and the third threshold is used to distinguish between tumor and interstitial area, set between 170 and 220. The initial randomly generated 3 threshold sizes are 40, 120, and 180 respectively. Thresholds play a key role in image segmentation because they determine how pixels in an image are assigned to different categories or regions. By setting multiple thresholds, the grayscale value of a pixel can be compared with the threshold to determine whether the pixel belongs to the foreground (region of interest) or the background. In complex images, multiple thresholds are required to effectively segment different regions. The goal is to find the best threshold combination to improve the image segmentation effect.
[0101] Step 4: Initial fitness evaluation:
[0102] For each individual, according to the characteristics of breast cancer pathology images, we selected indicators such as F1-score, precision, and recall to evaluate the performance of each individual and obtain the corresponding fitness value to measure the effectiveness of the threshold in image segmentation. The fitness value reflects the effect of the individual in image segmentation.
[0103] Step 5: Monarch strategy selection:
[0104] (1) Selection of the monarch: In each round of iteration, the individual with the highest fitness is selected as the "monarch" based on the fitness evaluation results. The "monarch" not only represents the optimal solution for the current population, but also plays a guiding role.
[0105] (2) Monarch retention mechanism: When updating the population, ensure that the "monarch" individuals are retained to prevent the loss of excellent genes. By retaining the "monarch", the stability of the population can be maintained and a strong benchmark can be provided for subsequent evolution.
[0106] (3) Guided evolution: In the process of crossover and mutation, the information of the "monarch" is used to influence other individuals. The threshold parameter of the "monarch" is used as a reference point for crossover to encourage other individuals to move closer to a better solution, thereby improving the global search capability. Using a single-point crossover operation, the genes of the selected individuals are crossovered to generate new individuals, so that the threshold of the new individuals after crossover is still within the effective range.
[0107] (4) Promoting diversity: While guiding, set appropriate random mutations to prevent the population from falling into a local optimum. In this way, the diversity of the population is maintained and the exploration of more solution spaces is encouraged. The random mutation is achieved by slightly adjusting the threshold or randomly replacing some thresholds to enhance population diversity and prevent premature maturity.
[0108] Through the above steps, the monarch strategy not only improves the fitness of the population, but also effectively enhances the global search capability, thereby improving the effect of multi-threshold image segmentation.
[0109] Step 6: Fitness re-evaluation:
[0110] Fitness re-evaluation is to evaluate the effectiveness of the newly generated population individuals after crossover and mutation operations. First, select evaluation indicators suitable for pathological images, such as F1-score, accuracy and recall, to fully reflect the segmentation effect. Then, for each new individual's threshold combination, apply these thresholds for image segmentation, generate segmentation results, and compare them with the true labels to calculate the corresponding fitness values. Next, update the calculated fitness values to the individual information to ensure that the fitness of the new population accurately reflects its segmentation effect. Through this series of steps, fitness re-evaluation ensures that the evolution of the population is based on the latest individual performance and continuously optimizes the image segmentation effect.
[0111] Step 7: Iterative Evolution:
[0112] Repeat steps 5 to 6. As the number of iterations increases, the overall fitness of the population will gradually improve, and the quality of the solution will continue to optimize. Set the following two termination conditions, and the algorithm stops when one of them is met:
[0113] Maximum number of iterations: The algorithm stops after reaching the preset maximum number of iterations to avoid infinite loops. The maximum number of iterations here is set based on experience, mainly based on population size, number of individuals, crossover rate, mutation rate and other parameters. For the complex image segmentation problem in this invention, the initial number of iterations is set to 70 times.
[0114] Fitness convergence: In each round of iteration, monitor the changes in the fitness value of the population. If the fitness value of the population does not increase significantly in consecutive generations of iterations, it is judged to be close to convergence, indicating that the population has found the optimal solution and the iteration is stopped. At this time, the number of subsequent iterations can be dynamically reduced. When it is found that the fitness value has increased significantly, the number of iterations is appropriately increased to give the algorithm more opportunities to explore new solutions. The dynamic adjustment here is achieved by setting the fitness increment threshold.
[0115] In order to dynamically adjust the number of iterations of the genetic algorithm and significantly improve the fitness judgment, the following describes the relevant settings:
[0116] (1) Definition of fitness increment
[0117] In each iteration, the average fitness value of the current population is calculated and compared with the fitness value of the previous iteration. The fitness increment can be expressed as:
[0118] ΔF t =F t -F t-1
[0119] Where: ΔF t is the fitness increment of the tth iteration, F t is the average fitness value of the population in the tth iteration, F t-1 It is the average fitness value of the population in the t-1th round of iteration.
[0120] (2) Judgment of significant improvement
[0121] Set a fitness increment threshold ∈ to judge the significant improvement or convergence of fitness. t When the threshold is exceeded, it is considered that the fitness has been significantly improved and the number of iterations needs to be increased; when ΔF t When it is less than this threshold, the fitness change is considered insignificant, indicating that the algorithm is close to convergence. Among them, ∈ is a small positive value, which is adjusted by experimental experience or problem complexity.
[0122] (3) Dynamically adjust the number of iterations
[0123] According to the fitness increment, the number of iterations of the genetic algorithm can be adjusted dynamically. When the fitness is significantly improved, the number of iterations can be increased; when the fitness change is not significant, the number of iterations can be reduced. The formula for dynamically adjusting the number of iterations is:
[0124] Increase the number of iterations (when it improves significantly): T new =T current +γ·ΔF t
[0125] Reduce the number of iterations (when convergence): T new =T current -β
[0126] Midterm: T new is the adjusted maximum number of iterations, T currentis the current number of iterations, γ is an incremental adjustment factor used to increase the number of iterations when the fitness is significantly improved. β is a fixed reduction factor used to reduce the number of iterations when the fitness change is not significant. Set γ=2 and β=3 as the initial values, which is a balance between exploration and computational efficiency.
[0127] Through the above iterative process, the genetic algorithm based on the monarch strategy can continuously optimize the individuals in the population, making them gradually approach the global optimal solution.
[0128] Step 8: Output:
[0129] After the termination condition is triggered, the individual with the highest fitness is selected as the final multi-threshold solution, and the solution is output as the threshold for image segmentation. The trained EfficientNet-B0 deep learning model is used to extract high-level features from breast cancer pathology images, and the threshold obtained by the improved genetic algorithm is combined to perform multi-threshold optimization segmentation.
[0130] After obtaining the segmentation results, we conduct quantitative and qualitative analysis on the segmentation results to verify the effectiveness and superiority of the method. In the model evaluation stage, we adopt a series of quantitative and qualitative methods to comprehensively analyze the performance of the model. In order to quantify the performance of the model, the following evaluation indicators are calculated:
[0131] (1) Sensitivity, which is calculated as follows:
[0132]
[0133] Among them, TP (True Positive) represents the number of samples correctly predicted as positive examples, and FN (False Negative) represents the number of samples that are actually positive examples but are incorrectly predicted as negative examples. Sensitivity measures the model's ability to identify positive examples.
[0134] (2) Specificity, which is calculated as follows:
[0135]
[0136] Among them, TN (True Negative) represents the number of samples correctly predicted as negative examples, and FP (False Positive) represents the number of samples that are actually negative examples but are incorrectly predicted as positive examples. Specificity measures the model's ability to identify negative examples.
[0137] (3) Accuracy, which is calculated as follows:
[0138]
[0139] Accuracy measures how accurately the model classifies the entire dataset.
[0140] (3) Intersection over Union (IOU), which is calculated as:
[0141]
[0142] IOU is an important indicator for evaluating image segmentation tasks, which calculates the ratio of the intersection and union of the predicted area and the true area.
[0143] (4) Dice Coefficient, which is calculated as follows:
[0144]
[0145] The Dice coefficient is another metric used to evaluate segmentation performance, which is similar to IOU but gives more weight to the intersection.
[0146] By quantitatively calculating these indicators, we can get the performance scores of the model in different aspects. The specific calculation performance indicators are shown in Table 1.
[0147] Table 1 Performance of the model in the present invention
[0148]
[0149] This table lists the performance indicators of the model on the training set, validation set, and test set. These indicators include sensitivity, specificity, accuracy, intersection-over-union ratio, and Dice coefficient. Through this table, you can intuitively see the performance of the model on different data sets and the model's ability to generalize to new data.
[0150] In addition to quantitative analysis, we also visualized the model’s predictions. This qualitative analysis allows us to intuitively see where the model performs well and where it falls short. Visualization not only helps us discover possible misclassifications of the model, but also reveals the model’s sensitivity to different types of samples.
[0151] In summary, by combining quantitative and qualitative evaluation methods, we can comprehensively evaluate the performance of the model and provide valuable insights for model improvement.
[0152] Improved genetic algorithm threshold selection results:
[0153] In the multi-threshold optimization algorithm, the selection of the threshold directly affects the effect of image segmentation. The following will describe in detail the comparison of the segmentation effect of the improved genetic algorithm of the present invention and the existing genetic algorithm under different thresholds.
[0154] Comparison of segmentation effects under different thresholds obtained by the improved genetic algorithm and the existing genetic algorithm:
[0155] (1) Quantitative analysis;
[0156] In order to evaluate and compare the segmentation effects under different thresholds, the segmentation results of the improved genetic algorithm of the present invention and the existing genetic algorithm are quantitatively analyzed and compared.
[0157] In order to quantify the segmentation quality, a series of evaluation indicators were selected, including precision, recall and F1 score. These indicators can fully reflect the performance of the model, especially in the case of unbalanced samples.
[0158] 1) Precision: Precision refers to the proportion of samples predicted to be positive that are actually positive. The formula is:
[0159]
[0160] 2) Recall: Recall, also known as sensitivity, refers to the proportion of samples that are correctly predicted to be positive among samples that are actually positive.
[0161] 3) F1 Score: The F1 score is the harmonic mean of precision and recall, and the formula is:
[0162]
[0163] By calculating these indicators, the segmentation effects under different thresholds can be quantitatively compared. Table 2 shows the segmentation effects of the two methods under different thresholds, including precision, recall and F1 score.
[0164] Table 2 Comparison of segmentation effects between the improved genetic algorithm and the existing genetic algorithm at different thresholds
[0165]
[0166] In Table 2, we can see that as the threshold increases, the precision of both methods increases, while the recall decreases. This is because at higher thresholds, the model tends to predict only the positive class it is very confident of, thereby reducing false positives, but may also miss true positives. The F1 score reaches the highest between thresholds of 0.02 and 0.05, indicating that precision and recall have reached a good balance within this range.
[0167] Through these experimental data, further statistical analysis can be performed to calculate the average precision, recall and F1 score of the two methods at each threshold, and perform t-test or Wilcoxon test to compare their significant differences. These analysis results can help us determine which threshold selection method performs best in a given image segmentation task.
[0168] (2) Statistical tests;
[0169] In order to further compare the performance differences of different threshold selection methods, we performed statistical tests. The statistical test methods of the present invention include t-test and Wilcoxon test. These tests can help us determine the significance of the performance differences between different methods.
[0170] 1) t-test: t-test is a parametric test used to compare whether the means of two independent samples are significantly different. In the comparison of threshold selection methods, the means of performance indicators (such as precision, recall, F1 score) at each threshold are first calculated. Then the difference between these means is calculated and divided by the standard error (SE) to obtain the t value.
[0171] When the variances of the two samples are equal, we use the equal variance t-test, and the formula is as follows:
[0172]
[0173] in, and are the means of the two samples, and is the variance of the two samples, n1 and n2 are the sizes of the two samples.
[0174] When the variances of the two samples are not equal, we use the heteroskedastic t-test, and the formula is as follows:
[0175]
[0176] same, and are the means of the two samples, and is the variance of the two samples, n1 and n2 are the sizes of the two samples.
[0177] After calculating the t value, compare it to the critical value of the t distribution. If the t value is greater than the critical value, reject the null hypothesis and consider that there is a significant difference in the means of the two samples. Use the p value to determine statistical significance. If the p value is less than the significance level (0.05), it is considered that there is a significant difference in the means of the two samples.
[0178] 2) Wilcoxon test (Mann-Whitney U test): The Wilcoxon test is a non-parametric test used to compare whether the medians of two independent samples are significantly different. The test does not rely on the distribution assumptions of the data. In the comparison of threshold selection methods, the rank of the performance index under each threshold is first calculated. Then the sum of these ranks is calculated to obtain the U value. The calculation formula of the U value is as follows:
[0179]
[0180] Among them, R i is the sum of the ranks of the observations in the second sample in the first sample, and n is the size of the first sample.
[0181] After calculating the U value, compare it with the critical value. If the U value is less than the critical value, reject the null hypothesis and consider that there is a significant difference between the medians of the two samples. Similarly, use the p value to determine statistical significance. If the p value is less than the significance level (0.05), it is considered that there is a significant difference between the medians of the two samples.
[0182] Performance comparison with other threshold selection methods
[0183] In order to compare the performance of the improved genetic algorithm (hereinafter referred to as "improved GA") proposed in this invention with other threshold selection methods, we conducted a series of experiments and evaluations. The following is a comparison between the improved GA and several other threshold selection methods:
[0184] (1) Improved Genetic Algorithm (Improved GA): Improved GA is based on the traditional genetic algorithm and improves the accuracy and efficiency of image segmentation by introducing new selection and crossover strategies. The present invention uses the "monarch strategy" to select the best individual as the "monarch" and perform crossover operations with other individuals. Its advantage is that it can handle complex optimization problems and has strong global search capabilities.
[0185] (2) Histogram threshold: Based on the grayscale histogram of the image, the threshold is selected by analyzing the peaks and valleys. Its advantages are simplicity and speed, and it is suitable for images with obvious bimodal histograms. However, its disadvantage is that it is not suitable for images with complex or unclear histograms.
[0186] (3) Support Vector Machine (SVM): Use SVM classifier to determine the optimal threshold and can handle nonlinear problems. Its advantage is strong generalization ability and applicability to various types of images. Its disadvantage is that it takes a long time to train and has limited processing capabilities for large-scale data sets.
[0187] (4) Particle Swarm Optimization (PSO): This method simulates the social behavior of bird flocks or fish schools to find the optimal threshold. The advantages of this method are strong global search capabilities and easy implementation. Its disadvantages are that it requires adjusting multiple parameters and is prone to falling into local optimality.
[0188] The performance of the above four algorithms is compared using the following evaluation indicators:
[0189] (1) Segmentation quality: evaluated by quantitative indicator accuracy.
[0190] (2) Computational efficiency: Compare the time and resource consumption required by different methods to process the same data set.
[0191] (3) Robustness: Evaluate the performance stability of different methods under different datasets and noise levels.
[0192] (4) Flexibility: The applicability of the evaluation method in processing data of different types and sizes.
[0193] The comparison of the above evaluation indicators is shown in Table 3.
[0194] Table 3 Performance comparison of different threshold selection algorithms
[0195]
[0196] It can be seen from Table 3 that the improved GA algorithm of the present invention has excellent performance in the image segmentation task, and its effectiveness and advantages in practical applications can be seen after comparison with other threshold selection methods.
[0197] In addition, we also draw box plots and bar graphs to further demonstrate the outstanding advantages of the improved GA algorithm of the present invention.
[0198] Figure 2 The box plots in Figure 4 compare computation time and segmentation quality. The box plots provide the distribution of computation time and segmentation quality for four threshold selection methods (modified genetic algorithm, histogram threshold, support vector machine, and particle swarm optimization).
[0199] (1) Figure 2 Left figure in: Computation time comparison;
[0200] It can be seen from the figure that the calculation time of the improved GA algorithm of the present invention is not the shortest among the four methods, but is close to the histogram method and the particle swarm algorithm. This is mainly because the improved genetic algorithm has a higher computational complexity because it needs to iteratively evaluate and select individuals, which may lead to a longer calculation time. Although the histogram method takes the shortest time, its segmentation quality is the worst.
[0201] (2) Figure 2 Right chart in: Segmentation quality comparison;
[0202] It can be seen from the figure that the improved GA algorithm of the present invention provides the highest segmentation quality, especially when processing complex images. This is mainly because the improved genetic algorithm can provide higher segmentation quality because it can search for a better solution. SVM can also provide higher segmentation quality, but it takes too long compared to the method of the present invention.
[0203] Figure 3 Another way of explanation in the present invention is to show the average calculation time and segmentation quality in the form of a bar graph. The bar graph provides the average calculation time and segmentation quality index of each threshold selection method. Figure 2 Compare the performance of different methods in a more intuitive way.
[0204] (1) Figure 3 Left panel in: Average computation time of each method;
[0205] This bar chart shows the average computation time for each method, which helps to quickly identify which methods are more computationally efficient. Also, because the method of the present invention requires iterative evaluation and selection of individuals, it is more sensitive to parameter settings. Therefore, it has a higher computational complexity, which may lead to longer computation times.
[0206] (2) Figure 3 Right panel in: Average segmentation quality of each method;
[0207] This bar chart shows the average segmentation quality index of each method, which helps to quickly identify which methods perform better in terms of segmentation accuracy. This figure shows that the method of the present invention has a strong global search capability because it searches for the optimal solution in the solution space through crossover and mutation operations, and has strong adaptability and can adapt to different optimization problems by adjusting the selection, crossover and mutation strategies. Therefore, the method of the present invention can search for a better solution and provide higher segmentation quality.
[0208] Joint Observation Figure 2 and Figure 3 It can be seen that the GA algorithm of the present invention has comprehensive advantages. Therefore, although the GA algorithm of the present invention is not the shortest in terms of calculation time, it performs well in segmentation quality, is suitable for segmenting complex images, and is very suitable for applications with high segmentation accuracy requirements. In medical images, complex images are usually required to be segmented with high accuracy, so the improved GA algorithm of the present invention has outstanding advantages over the other three typical algorithms.
[0209] Algorithm performance analysis
[0210] Algorithm performance analysis is a key step in evaluating the performance of improved genetic algorithms in multi-threshold optimization tasks. Algorithm convergence analysis aims to verify whether the algorithm can achieve the predetermined performance standard within a limited time. For multi-threshold optimization based on improved genetic algorithms, convergence analysis mainly includes the following aspects:
[0211] (1) Performance changes and convergence speed during the iteration process;
[0212] By recording the best fitness value in each generation of the population, we can observe how the performance of the algorithm changes as the iterations proceed. The fitness value increases with the number of iterations, indicating that the algorithm is gradually approaching the optimal solution. The fitness value shows a steady upward or stable trend during the iteration process, which indicates that the algorithm is converging. On the contrary, if the fitness value fluctuates greatly or does not improve significantly, it indicates that there is a problem with the algorithm, it converges too early or falls into a local optimum.
[0213] The number of iterations required to evaluate the algorithm to reach a predetermined performance standard can reflect the convergence speed. Fast-converging algorithms can achieve good performance in fewer iterations, which is very important for practical applications.
[0214] By plotting the relationship between performance and number of iterations, we can intuitively observe the convergence speed of the algorithm. Figure 4 As shown in the figure, the solid line represents the optimal fitness value of each generation of the population, and the dotted line represents the global optimal performance index. By comparing these two lines, we can simultaneously understand the performance improvement of the improved GA algorithm of the present invention in each generation and whether it is approaching the global optimal solution.
[0215] At the same time, from Figure 4 It can be seen that the improved GA algorithm of the present invention has a better convergence speed and better performance change. With the increase of the number of iterations, the performance index is constantly improving, the performance-iteration curve shows a stable upward trend, and the performance index gradually tends to be flat, indicating that the improved GA algorithm of the present invention will not fall into the local optimum and is steadily converging to a better solution.
[0216] (2) Global optimality;
[0217] By running the algorithm multiple times and comparing the optimal solutions from different runs, you can verify whether the algorithm has the ability to find the global optimal solution. If the optimal solutions from different runs are similar or the same, this may indicate that the algorithm has global optimality. Often the algorithm is able to find the same or very similar optimal solutions in multiple runs, which indicates that the algorithm is not stuck in a local optimum. Global optimality after multiple runs is shown in Figure 1. Figure 5 shown.
[0218] from Figure 5It can be seen that in all runs, the final performance index is very high, close to or reaching a certain optimal value, and the final performance difference between different runs is small, which shows that the algorithm can find high-quality solutions under different initializations. Furthermore, the final performance of all runs is close to the same performance index of 0.58, which shows that the improved GA algorithm of the present invention is consistent and can stably find solutions close to the global optimal solution. The good performance of this figure shows that the improved GA algorithm of the present invention has strong robustness and stability, and can perform well under different starting conditions. This is a very important feature for practical applications.
[0219] (3) Stability;
[0220] The stability of an algorithm can be evaluated by analyzing the performance changes of the algorithm under different initialization conditions and random seeds. A stable algorithm will show similar performance in different runs. If the performance fluctuations of the algorithm in different runs are small, this indicates that the algorithm has good stability. On the contrary, if the performance fluctuations are large, it may indicate that the algorithm is sensitive to initialization or randomness and has poor stability. The stability experimental results of the algorithm in the present invention are shown in Figure 2. Figure 6 shown.
[0221] from Figure 6 It can be seen that the performance curves of the algorithms in the present invention all show similar convergence trends, which means that the algorithms can stably converge to similar performance levels under different initialization conditions, and the performance curves fluctuate slightly, which indicates that the algorithms perform consistently in different runs. In addition, the final performance indicators are similar, and the final performance of all runs is close to the global optimal value, which further shows that the improved GA algorithm of the present invention can stably achieve similar performance levels and effectively find the global optimal solution without being affected by the initialization conditions.
[0222] Figure 6 This shows that the improved GA algorithm of the present invention has stable performance under different initialization conditions, which also shows the reliability of the improved GA algorithm of the present invention in practical applications. In multiple runs, similar performance levels are stably achieved, and we are more confident in applying it to practical problems.
[0223] The above-described embodiments are only descriptions of preferred implementations of the present invention, and are not intended to limit the concept and scope of the present invention. Without departing from the design concept of the present invention, various modifications and improvements made by ordinary persons in the art to the technical solution of the present invention should fall within the protection scope of the present invention, and the technical contents for which protection is sought in the present invention have been fully recorded in the claims.
Claims
1. A multi-threshold image segmentation method based on the monarch strategy improved genetic algorithm, characterized in that: The steps include: Step 1: Initialize the population: A certain number of individuals are randomly generated, each of which represents a set of thresholds. The initial threshold is set by a random generation method, and a plurality of candidate thresholds are randomly selected from a defined threshold range for image segmentation; the thresholds specifically included in the set of thresholds are determined according to the pathological image to be segmented; Step 2: Initial fitness evaluation: For each individual, according to the characteristics of the pathological image, an indicator is selected to evaluate the performance of each individual to obtain the corresponding fitness value, so as to measure the effectiveness of the threshold in image segmentation; the fitness value reflects the effect of the individual in image segmentation; Step 3: Monarch strategy selection: Use the "monarch strategy" to select the best individual in the evaluation as the "monarch", and perform crossover and mutation operations with other individuals to generate new population individuals; Step 4: Fitness re-evaluation: Fitness re-evaluation is to evaluate the effectiveness of the newly generated population individuals after the crossover and mutation operations. First, according to the selected evaluation indicators, for each new individual's threshold combination, these thresholds are applied to perform image segmentation, generate segmentation results, and compare them with the true labels to calculate the corresponding fitness values. Then, the calculated fitness values are updated to the individual information to ensure that the fitness of the new population accurately reflects its segmentation effect. Step 5: Iterative Evolution: Repeat steps 3 to 4 for iteration, and use an adaptive parameter adjustment mechanism to dynamically adjust the number of iterations and parameters of the genetic algorithm according to the real-time feedback of the segmentation results to ensure efficient convergence and stable segmentation performance; Step 6: Output: After the termination condition is triggered, the individual with the highest fitness is selected as the final multi-threshold solution, and the solution is output as the threshold for image segmentation; the obtained threshold is applied to segment the input pathological image to obtain the segmented result; the segmentation results are quantitatively and qualitatively analyzed to verify the effectiveness and superiority of the method.
2. According to claim 1, a multi-threshold image segmentation method based on the monarch strategy improved genetic algorithm is characterized in that: Step 3: (1) Selection of the monarch: In each round of iteration, the individual with the highest fitness is selected as the "monarch" based on the fitness evaluation results; (2) Monarch retention mechanism: when renewing the population, ensure that "monarch" individuals are retained to prevent the loss of excellent genes; (3) Guided evolution: In the process of crossover and mutation, the information of the "monarch" is used to influence other individuals; the threshold parameter of the "monarch" is used as a reference point for crossover to encourage other individuals to move closer to a better solution, thereby improving the global search capability; a single-point crossover operation is used to cross the genes of the selected individuals to generate new individuals; (4) Promoting diversity: While guiding, setting appropriate random variation to prevent the population from falling into local optimality; the random variation is achieved by adjusting the threshold slightly or randomly replacing part of the threshold to enhance population diversity and prevent premature maturity.
3. The multi-threshold image segmentation method based on the monarch strategy improved genetic algorithm according to claim 1 is characterized in that: In step 5, the following two termination conditions are set, and the iteration stops when one of them is met: Maximum number of iterations: The algorithm stops after reaching the preset maximum number of iterations to avoid infinite loops; the maximum number of iterations here is set based on experience and is initially set based on parameters such as population size, number of individuals, crossover rate, and mutation rate; Fitness convergence: In each round of iteration, monitor the changes in the fitness value of the population; if the fitness value of the population does not increase significantly in consecutive generations of iterations, it is judged to be close to convergence, indicating that the population has found the optimal solution and the iteration is stopped; at this time, dynamically reduce the number of subsequent iterations; when it is found that the fitness value has increased significantly, increase the number of iterations appropriately; dynamic adjustment of the number of iterations is achieved by setting the fitness increment threshold.
4. The multi-threshold image segmentation method based on the monarch strategy improved genetic algorithm according to claim 3 is characterized in that: In order to dynamically adjust the number of iterations of the genetic algorithm and significantly improve the fitness, the following describes the relevant settings: (1) Definition of fitness increment; In each iteration, the average fitness value of the current population is calculated and compared with the fitness value of the previous iteration; the fitness increment can be expressed as: ΔF t =F t -F t-1 Where: ΔF t is the fitness increment of the tth iteration, F t is the average fitness value of the population in the tth iteration, F t-1 is the average fitness value of the population in the t-1th round of iteration; (2) Judgment of significant improvement; Set a fitness increment threshold ∈ to judge the significant improvement or convergence of fitness; when the fitness increment ΔF t When the threshold is exceeded, it is considered that the fitness has been significantly improved and the number of iterations needs to be increased; when the fitness increment ΔF t When it is less than this threshold, it is considered that the fitness change is not significant, indicating that the algorithm is close to convergence; where ∈ is a small positive value, which is adjusted by experimental experience or problem complexity; (3) Dynamically adjust the number of iterations According to the judgment of fitness increment, the number of iterations of the genetic algorithm is dynamically adjusted; when the fitness is significantly improved, the number of iterations is increased; when the fitness change is not significant, the number of iterations is reduced; the formula for dynamically adjusting the number of iterations is: Increase the number of iterations: T new =T current +γ·ΔF t ; Reduce the number of iterations: T new =T current -β; Midterm: T new is the adjusted maximum number of iterations, T current is the current number of iterations, γ is an incremental adjustment factor used to increase the number of iterations when the fitness is significantly improved; β is a fixed reduction factor used to reduce the number of iterations when the fitness change is not significant.
5. The multi-threshold image segmentation method based on the monarch strategy improved genetic algorithm according to claim 4 is characterized in that: Set γ=2 and β=3 as initial values.
6. The multi-threshold image segmentation method based on the monarch strategy improved genetic algorithm according to claim 1 is characterized in that: F1-score, precision and recall are selected as evaluation indicators.