## 2 Materials and Methods
### Methods
In the case of large super pixels, spatial distances dominate over color proximity, resulting in spatial proximity being prioritized over color. This leads to the formation of compact super pixels that may not align well with image boundaries. To merge the two distances into a unified metric, it becomes necessary to normalize both color proximity (N\({}_{\text{C}}\)) and spatial proximity (N\({}_{\text{s}}\)) by their respective maximum distances within a cluster. Consequently, the distance D' is computed as follows:  
\[d_{c}=\sqrt{\left(l_{j}-l_{i}\right)^{2}+\left(a_{j}-a_{i}\right)^{2}+\left(b_{ j}-b_{i}\right)^{2}} \tag{2}\]  
\[d_{s}=\sqrt{\left(x_{j}-x_{i}\right)^{2}+\left(y_{j}-y_{i}\right)^{2}} \tag{3}\]\[D^{\prime}=\sqrt{{(\frac{{{d_{c}}}}{{{N_{c}}}})}^{2}+{(\frac{{{d_{s}}}}{{{N_{s}}}})} ^{2}} \tag{4}\]  
In (4), the maximum expected spatial distance (N\({}_{\rm S}\)) within a given cluster can be set as equal to the sampling interval S. However, determining the maximum color distance is more challenging. It can be scaled by a constant M to mitigate the variability in the maximum color distance. In practical terms, the distance D is computed as follows:  
Figure 3:0  
The SLIC super pixel method, employed subsequent to Mask2 Former, facilitates the preservation of details during the segmentation process, resulting in the clearer determination of object boundaries. This algorithm enhances the delineation of segment boundaries in the image, laying a robust foundation for subsequent processing stages. In the second stage, an analysis is conducted on the obtained segments. During this analysis, the proportions of pixels belonging to each class within every segment are computed. If the proportion of pixels belonging to a particular class within a segment exceeds a threshold value, such as 65%, that region is entirely assigned to that class. This approach enhances the accuracy of class predictions in segmentation outcomes, while simultaneously providing more a precise delineation of object boundaries. Finally, among the morphological operations, the 'opening' method is utilized to refine the segmentation map. The 'opening' process initially eliminates small and insignificant objects or noise through erosion, followed by dilation to re-expand these areas, thereby preserving the main structure of the objects. This approach aids in eliminating minor errors and unwanted objects during segmentation while enhancing the precision and accuracy of object boundary definition. Moreover, 'opening' enhances the overall quality of segmentation results, particularly by enhancing the differentiation of objects with fine details or those in close proximity. This technique facilitates the removal of small and inconsequential elements from the segmentation map while maintaining the integrity of larger objects. The proposed two-step algorithm, combined with this morphological operation, presents an effective approach to addressing challenges in semantic segmentation tasks and achieving more precise outcomes. To implement the proposed two-step algorithm, we utilized OpenCV for performing morphological operations and the scikit-learn implementation of the SLIC algorithm for super pixel generation. The SLIC algorithm was configured with a relatively high number of clusters to ensure finer granularity in capturing detailed object boundaries. Unlike square or uniform grid-based segmentation, the SLIC approach adapts to the color and texture variations in the image, producing super pixels that closely follow the natural boundaries of the objects. This configuration was particularly beneficial for segmenting complex regions with intricate details, as it allowed the super pixels to conform to subtle changes in color and texture, resulting in an improved delineation of object boundaries. The kernel size for the morphological opening and closing operators is set to (5,5), while the SLIC algorithm is configured with a compactness parameter of 5 and the number of clusters set to 600.