# Advanced Medical Image Segmentation Enhancement:
## 4 Results and Discussion
### Segmentation Performance
#### 4.2.1 Analysis of Best-Cost Values  
The best-cost values, as depicted in Figure 8, offer valuable insights into the optimization process of the particle swarm optimization (PSO) algorithm applied to medical image segmentation. We consider two distinct datasets, lung CT scan and chest X-ray, each with and without preprocessing using histogram equalization (HE). This analysis aims to understand how different combinations of the PSO algorithm and preprocessing methods influence segmentation convergence behavior and efficiency.  
The process initializes a population of particles with random positions and velocities and evaluates their objective function. It updates personal and global best positions based on the cost (Equations (2) and (3)). In the main PSO loop, particle velocities and positions are iteratively updated within imposed limits. The algorithm tracks the best solution and associated information, and incorporates a damping factor for the inertia weight. The process continues for several iterations and stores the final solution and relevant details. The result indicates the indices corresponding to the best solution.  
Figure 8: Comparison of best-cost values of the PSO segmentation approach for lung CT scan and chest X-ray images with and without histogram equalization (HE) preprocessing.  
1. Chest X-ray Segmentation Without HE, the best-cost values exhibit fluctuations within a relatively narrow range. This indicates that the PSO algorithm converges effectively to a stable solution. The consistency of best-cost values can be attributed to the nature of chest X-ray images, which already possess a certain level of contrast and a grayscale distribution suitable for segmentation. When HE is applied, the best-cost values slightly increase. This is likely due to HE redistribution of pixel intensities and emphasizing the overall contrast, which can create additional complexity in the segmentation process. However, despite the slight increase, the best-cost values remain relatively stable.
2. Lung CT Scan Segmentation In the case of lung CT scan images, the best-cost values demonstrate more significant variations. Without HE, the algorithm exhibits periodic dips and peaks. The complexity in these images, characterized by intricate anatomical structures like lung parenchyma, blood vessels, and airways, contributes to the periodic fluctuations. These variations might indicate the algorithm's challenges in settling on a precise segmentation solution. With HE preprocessing, the best-cost values exhibit a notable reduction in fluctuations. The redistribution of pixel intensities through HE improves the overall contrast, resulting in a smoother convergence pattern. It is important to note that in this context, a lower best-cost value reflects a more accurate segmentation. The comparison between chest X-ray and lung CT scan datasets highlights the significance of dataset characteristics in influencing the convergence behavior of the PSO algorithm. Moreover, the impact of HE on the optimization process is more pronounced in lung CT scan images, which emphasizes the need for preprocessing methods tailored to the dataset's characteristics.