## 2 Materials and Methods
### Automated Feature Inference and Extraction from Non-Etched Metallographic Microstructures
#### 2.2.3 Extraction of Various Measurements  
The third stage of nodule-related work focuses on quantifying the five key morphological descriptors. These descriptors are (i) circularity, (ii) roundness, (iii) AR, (iv) Feret's diameter, and (v) modularity. In this research work, we carried out the measurement extraction through two complementary strategies; firstly, applying classic CV methods, and, secondly, learning ML-based models. On the one hand, when CV methods are employed, each image is converted to grayscale, binarized by thresholding, and then analyzed with contour detection. Contours that touch the image border or the pixel-to-length reference rectangle are discarded. In the same way, although it can be configured, regions smaller than 25 \(\upmu\)m\({}^{2}\) are also discarded. The main reason is that their size is not significant for the study. On the other hand, using ML methods, every nodule mask is cropped and passes through a three-stage DL pipeline--two sequential VGG16 networks followed by a final custom-trained network. All the aforementioned models are tuned and optimized for our specific objective, thanks to the dataset previously explained. More precisely, after finding the contours, a small image file is extracted for each contour. The specific image contains the rectangle that encloses the calculated contour. Then, the resulting image is processed in the ML pipeline for its classification. The pipeline was created to improve the classification accuracy between types III, V, and VI. The first model checks whether the extracted contour is type III or type V. If it is identified as type V, the second model is launched to verify whether it is type V or type VI. If the result indicates type VI, the third model is executed to determine whether it is type III or type VI. This last model is just to ensure the final classification, trying to avoid image misclassifications that escape the first detection. After segmentation, it is necessary to extract features from each nodule. Hence, the contour measurements are evaluated by a rule-based model that assigns the final graphite morphology class in accordance with ISO 945-4 descriptors [7; 60]. There are custom models developed for specific companies, each with its own parameterization based on ISO standards, that is, roundness (ISO and Company 2), circularity (Company 1 and Azterlan), and AR (Azterlan). Due to confidentiality, company names cannot be disclosed. They are  
Figure 5: Classification of graphite in the iron cast according to UNE EN ISO 945-2 [59]. Types of graphite morphologies: lamellar (**I**), “crab-shaped” graphite (**II**), vermicular (**III**), irregular spheroidal (**IV**), slightly irregular spheroidal (**V**), and spheroidal (**VI**). referred to as Company 1 and Company 2. We based our approach on the Azterlan method due to its greater completeness and specificity. The following parameters are computed during the metallographic analysis of nodular cast iron:  
Circularity is calculated as follows:  
\[\text{Circularity}=\frac{4\pi\cdot\text{Area}}{\text{Perimeter}^{2}} \tag{1}\]  
where a value of 1.0 indicates a perfect circle. Between 0.6 and 1.0, nodules are considered spheroidal. In other cases, when the circularity value approaches 0.0, it reflects an increasingly elongated or irregular shape. Note that circularity values may not be reliable for very small particles, where measurement noise or resolution limitations can significantly affect the accuracy [6]. Aspect ratio:  
\[\text{Aspect Ratio}=\frac{\text{Major Axis}}{\text{Minor Axis}} \tag{2}\]  
The AR is defined as the ratio of the major axis to the minor axis of the ellipse fitted to the particle. If the fit ellipse is selected, both the major and minor axes of the fitted ellipse will be displayed. A higher AR indicates a more elongated shape, while a value close to 1.0 suggests a shape closer to a circle [6].