## 2 Materials and Methods
### Dataset  
To obtain segments from steel images, unsupervised segmentation algorithms were considered. As a decision criterion, we wanted to use fast algorithms, preferably with \(O(N)\) computational complexity and with control over the number of clusters, without the need to perform complex image preprocessing steps prior to segmentation. Therefore, a Simple Iterative Linear Clustering (SLIC) was chosen, which adapts a k-means clustering approach to efficiently generate superpixels [21]. Its implementation from the sklearn library was  
Figure 1: Sample section with spots where images were taken.  
employed. For each image, a distinct target number of segments was established (100, 400, and 600), and for each combination, the algorithm yielded a unique number of clusters.  
Subsequently, a mask was generated for each segment. These masks were then combined with the original image through a process of arithmetic and operation, resulting in an intermediate image. The intermediate image was then cropped to remove any extraneous portions of the mask. The segments were stored individually and saved for each combination of original file and preset number of segments. We have noticed that higher compactness values led to more regular shapes of segments, but their boundaries were not matching with grains. Thus, compactness = 0.1 was used in this experiment.  
In the second phase, manual labeling was performed on the previously prepared dataset to mark segments (See Figure 2) that contain small amounts of bainite, significant amounts of bainite, and no bainite. Segments that were difficult to classify were also marked and excluded from the dataset. Furthermore, classes of segments were binarized to predict presence or lack of bainite rather than its quantity. This allowed us to create a mapping between the segment image and its corresponding class. This approach was adopted to validate the correctness of the hypothesis. It draws from previous experiments where alternative methods, such as using the U-Net algorithm combined with Local Binary Patterns (LBPs), yielded inaccurate results. The decision to shift to this approach is based on observed limitations in earlier plans of experiments, emphasizing the need for a more robust and reliable solution to confirm selected features.  
Data preparation has been designed with the use of the medallion approach (it is a design of preparing data from the data engineering domain; see Figure 3), which allowed us to create a clean structure of the whole experiment.  
The medallion model has been implemented with the use of 2 layers:  
* The bronze layer;
* The silver layer.  
The bronze layer is designed to store raw data described by metadata; in metadata, there is information about sources including date of update, etc. The silver layer is a place where the labeled data are stored for a given experiment. Every single experiment has its own preprocessing pipeline. So, the features are stored in separated places, but if some other experiments still need them, it is easy to find them. In Table 1 is the final number of prepared classes.  
Figure 2: Example of segments extracted from the image using superpixel segmentation. (**a**) Bainite segment. (**b**) Non-bainite segment. Original proportions were preserved.