## 3 Results
### Feature Extraction from Chemically Etched Metallographic Specimens
#### 3.3.2 Carbide Detection and Segmentation  
Then, to avoid potential issues in the final castings, it is time to focus on carbide detection and its measurement. As explained in Section 1, carbides are hard, brittle compounds typically formed by carbon combining with metals during solidification. Their uncontrolled presence can severely compromise the mechanical properties and machinability of the final component. Thus, it is very important to detect and locate carbides, as well as to measure their presence, specifically, the relative percentage of carbides in relation to the full image size. Due to the computational complexity of the image analysis process for carbide extraction, we aimed to avoid unnecessary calculations by using the classification model previously explained in Section 2.1 and evaluated in Section 3.1. Notwithstanding, if the possibility of carbide apparition is feasible, the detection and segmentation models are launched. In this way, the current section also presents the outcomes of training the YOLOv11 model for carbide detection on the evaluated dataset. The dataset, with the augmentation process defined in Section 2.3 was used. Figure 15 provides an example of how those images were employed during the training and testing phase of the algorithm. To measure the performance of the trained model and its ability to accurately detect and classify the objects, both performance metrics and training losses were analyzed. The evaluation includes an analysis of training and validation behaviors across key indicators such as precision, recall, and mean average precision (mAP) at different intersection over union (IoU) thresholds. Additionally, the classification, localization, and distribution focal losses were reviewed to gauge learning stability and model generalization on unseen data (see all data plotted in Figure 16). Figure 15: Detection of carbides in metallographic images. Examples of how the model used the images during the training and testing phases. Specifically, the model achieved a precision of 0.453, which indicates a moderate performance with a reduced number of false positives. However, the recall was relatively low at 0.384, meaning the model is still missing a significant number of true objects in the images. The mAP at IoU 0.5 ([EMAIL_ADDRESS]) reached 0.372 (close to acceptable values), although it clearly indicates room for improvement. On the other hand, the mAP across IoU thresholds from 0.5 to 0.95 ([EMAIL_ADDRESS]:0.95) was only 0.142, suggesting that the model struggles with precise localization and consistent bounding box quality. The low recall, below 0.4, further emphasizes the presence of undetected objects. Figure 17 illustrates example results from carbide detection, where it is evident that several carbides remain undetected. After the detection process, and with the aim of refining the carbide detection results, we applied SAM to the bounding boxes initially extracted by our YOLOv11 detector. As  
Figure 16: Training metrics of YOLO11 visualized across epochs, including bounding box loss (box_loss), classification loss (cls_loss), and distribution focal loss (dfl_loss) for object detection optimization. The graphs also depict precision, recall, mean average precision at IoU = 0.5 (mAP50), and mAP50-95 (average over IoU thresholds 0.5-0.95). Figure 17: Processed metallography showing the bounding boxes in carbide detection when the learned model is applied. It can be seen that some carbides are not detected, as reflected in the key measurement indicators extracted during the experiment. we described previously, while YOLO provides approximate object localization through rectangular regions, SAM enables high-precision pixel-level segmentation. Therefore, the accuracy of the segmentation process is not solely dependent on the quality of the mask extracted by SAM, but rather on the recall or precision of the bounding boxes.