## 4 Results
### Anomaly Detection  
To evaluate the performance of the anomaly detector, for each test sample, three metrics were computed: the image distance of the generated image to the original image, the anomaly score, and the z-distance, which are defined in Section 3.4.3. In Table 3, it is possible to find the average values of such metrics for each class of test set 1, while in Figure 6a, the discrete distributions of the obtained anomaly scores are presented. As it is possible to infer from these results, the normal class, which corresponds to the images without any defect, achieved the lowest values in terms of the three computed metrics for almost all classes, with the exception of class 13 concerning the anomaly score metric. It is important to mention that, for these experiments with the anomaly detector engine, class Defect-13 was only present in two patches. Moreover, although these \begin{table}
\begin{tabular}{c c c} \hline \hline
**Class** & **IOU (\%)** & **Accuracy (\%)** \\ \hline Background & 99.20 & 99.62 \\ Center top zone & 97.24 & 98.57 \\ Lateral top zone & 91.06 & 95.16 \\ Border & 82.36 & 90.60 \\ Lateral bottom zone & 92.58 & 95.99 \\ Middle bottom zone & 87.51 & 93.27 \\ Foot-ring & 87.03 & 92.85 \\ Central bottom zone & 95.42 & 97.89 \\ \hline Mean & 91.55 & 95.49 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Test set metrics obtained for the piece zone segmentation task. Figure 6: Results for the anomaly detection engine with test set 1. (**a**) Discrete distributions of anomaly scores; (**b**) ROC-AUC curve in terms of anomaly scores. metrics are very close between some defective classes, which prevents their separability, the results suggest that this approach is able to distinguish between samples with and without (normal samples) defects. This statement may also be verified in Figure 6a, where the green (normal) samples are essentially settled in the leftmost area of the plot, which corresponds to the lowest anomaly scores, whereas for other defective classes, it is difficult to find the corresponding boundaries, due to the verified overlap. Bearing this in mind, a threshold was defined in order to distinguish between normal and defective samples. To establish this value, the ROC-AUC curve (Figure 6b) concerning the anomaly scores of test set 1 was plotted and the cut-off point, i.e., the closest point of the curve to the top left corner of the plot, was set as the threshold value, corresponding to an anomaly score of 0.0128. This was made using only test set 1, as it is composed of defective and normal patches that belong to the same set of images used to train the models but that have not been seen during the training process. Also, we decided to go with the anomaly scores to make this experiment as this metric was proposed in the original paper of f-AnoGAN [14] and gives information regarding the degree of anomaly. Therefore, a sample whose anomaly score is higher than this value is defined as a defective sample. The resulting accuracy, macro-average, and weighted-average metrics were then calculated for both test set 1 and test set 2, and the corresponding confusion matrices were computed, giving rise to the results shown in Table 4 and Figure 7, respectively. These results show that the introduction of patches belonging to a dataset acquired in a different time window (test set 2) slightly penalized the macro-average metrics, which treat the two classes equally while improving the weighted-average metrics, which take into consideration the number of samples belonging to each class. It is worth noting that this new set of images that is present in test set 2 is essentially composed of patches without defects. By scrutinizing these outcomes in terms of classes, we verified that, overall, the ability of the framework to differentiate defective patches decreased, while its ability to detect normal patches improved. This may also result from the different acquisition conditions of these new samples, which may have influenced the defects' appearance, even if minimally.