## 2 Materials and Methods
### Automated Feature Inference and Extraction from Non-Etched Metallographic Microstructures
#### 2.2.4 Quality Classification  
The quality of metallography based on nodule types and their distribution in the area is essential, especially in cast iron analysis. It focuses on [54]:  
* Nodule shape: Spheroidal (ideal for ductile iron) vs. irregular or vermicular (undesirable). * Nodule size: Uniform size indicates consistent processing, while varied sizes may indicate cooling inconsistencies. The size distribution impacts mechanical properties like tensile strength, elongation, and fatigue resistance. * Nodule count (modularity): A high number of uniformly distributed nodules improves mechanical properties. * Distribution: Evenly distributed nodules prevent stress concentrations and improve the strength of the material. * Nodule integrity: Absence of defects like cracks or porosity within nodules. Metallography from a high-quality metal reveals well-formed, uniformly sized, and evenly distributed nodules, indicating good metallurgical control. As briefly cited before, if modularity is below a certain margin, 90% (this threshold value has been established by metallographic chemistry experts at Azterlan), the quality of the metallography is poor. Nevertheless, it is also needed to perform this calculation in an objective way. In our work, we propose to make this classification based on the distribution of the nodule sizes. In fact, the calculation is developed using the calculated nodule size distribution and its categorization into specific size ranges. These ranges, created under a division on the possible values of Feret's diameter and measures in um, are as follows:  
\[5\leq x<10,\quad 10\leq x<15,\quad 15\leq x<20,\quad 20\leq x<25,\] \[25\leq x<30,\quad 30\leq x<35,\quad 35\leq x<40,\quad 40\leq x<45,\] \[45\leq x<50,\quad 50\leq x<55,\quad 55\leq x<60,\quad x\geq 60\]  
In our research, different methods have been employed. The first one is based on a curve slope function computation, and the other uses ANN to make the final classification. In Azterlan, metallurgical experts assess quality by analyzing the curve generated by the nodule size distribution in the specified ranges. The ideal curve exhibits the following characteristics:  
* High values on the left side: From 1 to 2, this indicates a large number of small nodules, reflecting good nodulization and consistent cooling: \[f(x)\quad\text{is large as}\quad x\to 0^{+}\] (6)
* Steep downward slope: From 3 to 4, a rapid decrease in frequency as the size of the nodule increases, showing that the larger nodules are minimized. \[\frac{df}{dx}<0\quad\text{and}\quad\left|\frac{df}{dx}\right|\text{ is large for intermediate sizes}\] (7)
* Linear and stable towards the end: From 5 to the end, the curve flattens, indicating that very large nodules are rare or absent. \[\lim_{x\to x_{\text{max}}}\frac{df}{dx}\to 0\quad\Rightarrow\quad f(x) \approx\text{small constant}\] (8)  
For example, and taking into account the curve shown in Figure 6, its shape suggests a well-controlled metallurgical process, where most of the nodules are small and welldistributed, minimizing structural weaknesses and improving the mechanical properties of the material. However, if the histogram is totally directed to the higher ranges, the quality of the metal is going to be classified as the worst one. The calculation was performed programmatically by analyzing the distribution and the slope of the curve between three intervals. An acceptance variation percentage (15%) is applied to each interval. The slope of each section is then analyzed to indicate the quality level, with steeper or flatter trends corresponding to different classifications. The other solution involves using a multilayer perceptron (MLP) model. This model was trained on a dataset of 1072 records. In our case, each record contains the number of nodules per range based on their Feret diameter. It is a range divided into 12 parts, and the category (\"very good\", \"good\", \"bad\", \"regular\", and \"very bad\") indicates the quality according to that distribution.