## 2 Reconstruction of Polycrystalline Model
### NURBS Characterization of Grains
If \(N_{\text{s}}>3\), it implies that this sharp corner belongs to a small grain relative to the average size of grains in the polycrystalline microstructure and should not be relocated/merged. Figure 5: Junction detection algorithm used for grain vertices/sharp corners: (**a**) original binary skeleton image \(I_{\text{skel}}\); (**b**) updated image after convolving with box blur kernel \(I_{\text{blur}}\); (**c**) updated image after taking a pixel-wise dot-product between \(I_{\text{skel}}\) and \(I_{\text{blur}}\); (**d**) detected sharp corners. To obtain the NURBS characterization of grain boundaries, we first implement the Shi-Tomasi corner detection algorithm [41] to identify a set of corner points that represent grain boundaries. Note that the detection of _corner points_ here refers to points that result from the jagged representation of the grain boundaries (cf. Figure 7), and should not be confused with the sharp corners detected via the junction detection algorithm discussed previously. To avoid any ambiguity, we refer to such corner points (detected on a jagged boundary) as _feature points_ in the remainder of this section. The Shi-Tomasi corner detection algorithm [41] starts by identifying small image windows/patches that have large variations in intensity (large gradients). The algorithm computes the change in intensity \(E(u,v)\) of each image patch \(I(x,y)\) when moved slightly in the \(x\) and \(y\) directions by \(u\) and \(v\), respectively, i.e.,  
\[E(u,v)=\sum_{x,y}[I(x+u,y+v)-I(x,y)]^{2}w(x,y), \tag{3}\]  
where \(w(x,y)\) is a weighting function. In the simplest case, \(w(x,y)=1\); however, it could be a Gaussian-like function instead to emphasize the central area of the image patch. Applying the Taylor series expansion to (3) yields  
\[E(u,v)\approx[u,v]\mathbf{M} \begin{bmatrix}u\\ v\end{bmatrix} , \tag{4}\]  
where \(\mathbf{M}\) is a symmetric \(2\times 2\) matrix of the system provided by  
\[\mathbf{M}=\sum_{x,y}w(x,y) \begin{bmatrix}I_{x}&I_{x}I_{y}\\ I_{x}I_{y}&I_{y}I_{y}\end{bmatrix} . \tag{5}\]  
Figure 6: Merging sharp corners that are very close to one another. Figure 7: Search algorithm aimed at locating \(>3\) sharp corners in close proximity to preserve small grains from collapsing. In Equation (5), \(I_{x}\) and \(I_{y}\) represent the image gradients in the \(x\) and \(y\) directions, respectively. A feature point on the jagged boundary is identified by a large variation of \(E(u,v)\) in all directions of \([u,v]\). Because the eigenvalues of \(M\) represent the variance in the corresponding principal directions, this matrix should have two large eigenvalues, \(\lambda_{1}\) and \(\lambda_{2}\), at a feature point. However, because the minimum of these two eigenvalues represents the smallest amount of variance in the image patch, it is less affected by noise and is a more reliable criterion for feature point detection [41]. Therefore, a scoring function \(R\) is defined as \(R=\min(\lambda_{1},\lambda_{2})\). If this scoring function is greater than a threshold \(\lambda_{\text{th}}\), it is determined that the image window contains a feature point. Note that this threshold \(\lambda_{\text{th}}\) is chosen as a fraction of the best score \(R_{\text{max}}\) from a given image, i.e., \(\lambda_{\text{th}}=qR_{\text{max}}\), where we have chosen \(q=0.01\). After identifying the feature points along grain boundaries (smaller green points in Figure 8), a subset of these points is selected as the NURBS control points, which is shown as larger blue points in Figure 8. Note that using all feature points as control points leads to spurious oscillations in the resulting NURBS representation of grain boundaries. To select appropriate control points, we loop over the global set of feature points, then for each point being visited we find the neighboring points within the distance \(l_{gs}\), as defined in (2). All identified points are then removed, and only the original point being visited is maintained as a control point.