## 2 Method
### Modelling
#### 2.2.1 Bitmap Vectorization  
The transformation from a binary image to a vector image can be achieved using the following method. Figure 6 illustrates four steps, including connected-component labeling, the boundary extraction technique, boundary refinement, and geometry scaling.  
In the connected-component labeling implementation, a digital image's microstructure is stored as discrete pixels and grouped by a procedure. A binary image of n \(\times\) m pixels is represented by \(f(i,j)\) in the Cartesian coordinate system [37]:  
\[f(i,j)=\begin{bmatrix}f(1,1)&f(1,2)&\cdots&f(1,m)\\ f(2,1)&f(2,2)&\cdots&f(2,m)\\ \vdots&\vdots&&\vdots\\ f(n,1)&f(n,2)&\cdots&f(n,m)\end{bmatrix},\ i=1,2,\ldots,n,\quad j=1,2,\ldots,m \tag{10}\]  
Figure 5: The process of multi-scale feature fusion.  
To obtain the microstructure's geometry, such as pores or gravel, each pixel's group is determined. A fast two-pass method algorithm segments the geometry into regions. A zero matrix of size f, a label variable l, and a label set variable li are initialized. The neighborhood \(\Omega\) is shown in Figure 7, and a 4-neighbor domain is utilized. The first pass labels each pixel and its domain. A loop constructs domains with the same label.  
To implement the boundary extraction technique, we utilized a method proposed for extracting the microstructure boundary from CT or NMR images [38]. The method labels the connected pixels using a region-growing algorithm, then divides each pixel into four edges, storing them in a list. Subsequently, the algorithm removes edges that appear twice in the list and connects the remaining edges to form a closed curve.  
After determining the edges of the microstructure, in the boundary refinement step, microstructure edges are connected into a closed polyline using the Douglas-Peucker smooth algorithm (see Figure 8a). This polyline is jagged and has too many points, which are undesirable for numerical modeling. To smooth and reduce the number of points, we employed a boundary refinement algorithm described in Algorithm 1[39]. This algorithm divides the vertices into two sections using the longest line (see Figure 8b). Subsequently, it calculates the line equation and the maximum distance from a vertex to the line as follows:  
\[d=\left|\frac{Ax_{0}+By_{0}+C}{\sqrt{A^{2}+B^{2}}}\right| \tag{11}\]  
Figure 6: Flow chart depicting the steps of bitmap vectorization.  
Figure 7: Local neighborhood \(\Omega\): (**a**) 4-neighbor domain, (**b**) 8-neighbor domain [36].  
where \(Ax+By+C=0\) is the line equation and (\(x_{0}\), \(y_{0}\)) is the vertex coordinates. It repeats this for each section until the maximum distance is below a threshold (see Figure 8c). Finally, it obtains the refined boundary by connecting the edges (see Figure 8d).  
Figure 8: Illustration of geometry boundary refinement algorithm: (**a**) initial boundary polyline, (**b**) first polyline segment, (**c**) second polyline segment, (**d**) final boundary polyline [36].  
The microstructure geometry in digital images is measured in pixels rather than physical distance (mm or \(\upmu\)m). We employed a geometry scaling procedure to convert the geometry to the real size. Typically, the digital image has a proportional scale indicating the resolution. The real distance of a pixel can be estimated based on this information.