## 2 Reconstruction of Polycrystalline Model
### NURBS Characterization of Grains  
To improve the rough appearance of grain boundaries in the polycrystal image and create a suitable input file for the PolyCISAMR mesh generation algorithm, NURBS functions are used to describe the geometry of each grain. A NURBS curve \(\mathbf{C}(u)\) is a rational generalization of B-splines \(M_{i}^{p}(u)\) which are functions of a parametric coordinate \(u\). A knot vector \(\mathbf{U}=u_{1},u_{2},u_{3},\dots,u_{n+p+1}\) represents the parametric coordinates of the initial and end points of a NURBS patch in a \(C^{0}\)-continuous NURBS curve. In this knot vector, \(n\) and \(p\) refer to the number of control points and the order of B-splines, respectively. A NURBS curve can be written as [36]  
\[\mathbf{C}(u)=\sum_{i=1}^{n}\frac{\mathbf{x}_{i}w_{i}M_{i}^{p}(u)}{\sum_{j=1} ^{n}w_{j}M_{j}^{p}(u)}, \tag{1}\]  
Figure 4: Identifying a small skewed grain and the modified image after its removal. Figure 3: Skeleton image of the pixelated polycrystalline microstructure shown in Figure 1.  
where \(\mathbf{x}_{i}\) is a set of control points (described in the Cartesian coordinate system) and \(w_{i}\) are weights of each control point. To evaluate the NURBS characterization of each grain, we must first identify its sharp corners. A _junction detection algorithm_[37] is implemented that receives the skeleton image \(I_{\text{skel}}\) of the polycrystal (cf. Figure 3) as the input and detects the sharp corners, as shown in Figure 5. These sharp corners are in fact intersection points of two or more grain boundaries in a given 2D image slice. The junction detection process begins by applying a 2D convolution operation [38] on the binary skeleton image \(I_{\text{skel}}\) (cf. Figure 5a) using a \(3\times 3\) box blur kernel of all ones [39]. The resulting image \(I_{\text{blur}}\), which is depicted in Figure 5b, has pixel values equal to the sum of pixel values in the Moore neighborhood of each pixel of \(I_{\text{skel}}\)[40]. A pixel-wise dot-product is then taken between \(I_{\text{skel}}\) and \(I_{\text{blur}}\), which generates an image with possible pixel values of \(\{0,3,4,5,6,7,8,9\}\) depending on the number of grain boundaries that intersect at a given pixel, as shown in Figure 5c. Here, a value of 0 denotes the interior of a grain, 3 represents pixels on the grain boundaries, and any value greater than 3 corresponds to pixels near the grain vertices (sharp corners). Next, pixel values greater than 3 are filtered out from \(I_{\text{blur}}\) to obtain multiple junctions containing sharp corners. These junctions can either have a pixel value greater than 3 (junction B in Figure 5c) or multiple pixels that meet this threshold (junction A). A sharp corner in the latter scenario is identified by calculating the mean of all pixel locations and then selecting the closest pixel to this mean value (Figure 5d). Next, vertices that are too close to domain boundaries or extremely close to each other are detected; these are respectively snapped to the boundary or collapsed to their midpoint (see Figure 6). While identifying such vertices based on their distance to other sharp corners is straightforward, there are cases where multiple sharp corners can be in close proximity, as shown in Figure 7. Such scenarios require a special approach to ensure that small grains are preserved in the final polycrystal model after merging the sharp corners. Note that after generating the skeleton image of the initial polycrystal we no longer have access to individual grains at this stage of processing, as only grain boundary information is available and it is unfeasible to identify small grains that must be preserved. Therefore, as depicted in Figure 7, for each sharp corner we first determine the number of neighboring sharp corners \(N_{\text{s}}\) within a distance \(l_{\text{gs}}\) given by  
\[l_{\text{gs}}=\frac{l+w}{2N}, \tag{2}\]  
where \(l\) and \(w\) are the length and width of the 2D polycrystal image and \(N\) is the total number of grains.