## 2 Materials and Methods
### Image Segmentation by Using a Level Set Method  
The accuracy of data-driven stochastic model for spatial uncertainties depends on the experimental characterization data. Although profilometry is a fast and simple method to measure the spatial profiles, the usage of profilometry is strictly limited by its dimensional accessibility [17]. Therefore, we employ an image-based technique to extract the spatial variation of AM products. The method involves collecting sidewall profile data of additively manufactured struts from multiple sample images and extracting the data set that can be used to quantify the spatial variations by using image segmentation. The image-based technique can be applied to any spatially varying field obtained from any imaging technique. Image segmentation is a partitioning process that groups clusters of pixels of a digital image based on parameters including their colors, intensities, and textures to extract useful information from the image [18]. Various techniques are proposed for segmenting images [18; 19; 20]. Among these, thresholding is one of the simplest and most widely used techniques for image segmentation. Thresholding separates pixels in which the grayscale level exceeds a critical value from the background, and the critical value is defined by the image gray-level histogram. However, a few disadvantages of thresholding are also reported, including susceptibility to pixel noise and the possibility that the extract profile is potentially not a closed contour due to lack of consideration of spatial characteristics [21]. In this study, we use the level set method to extract the profiles of objects in the image [22]. In the level set method, a higher dimensional function termed as level set function (\(\phi\)) is defined to describe the contour. The contour evolves toward the object's boundaries in the image based on the predefined constraints such as difference or gradient of pixel intensities. With respect to the evolving level set function, the contours are given by the zero-level set, \(C=\{(x,y)|\phi(x,y)=0\}\), which evolves toward the object's boundaries. We assume that \(\Omega\subset R^{2}\) is the domain inside an image, and \(I(x,y)\) denotes the intensity of pixel at the pixel's location \((x,\,y)\). The general energy function \(E\) in the level set method is shown as follows [23]:  
\[ \begin{array}{c}E=\lambda_{o}\int_{\Omega}|I(x,y)-u_{o}|^{2}H(\phi(x,y))dxdy \\ +\lambda_{b}\int_{\Omega}|I(x,y)-u_{b}|^{2}(1-H(\phi(x,y)))dxdy+\gamma\int_{ \Omega}g(\phi(x,y))|\
abla\phi(x,y)|dxdy,\end{array}  \tag{1}\]  
where \(u_{o}\) and \(u_{b}\) denote the pixel intensity averages inside the contour and in the background region, respectively, and \(\lambda_{o}\), \(\lambda_{b}\), and \(\gamma\) are non-negative weighting factors. A smoothing function \(g(x)=(1+\exp{((x-\xi)/L)})^{-1}\) is selected for the robustness of the algorithm. \(L\) defines the smoothing length, and \(\xi\), locates the center of the smoothing function. The Heaviside function (\(H\)) is used to differentiate the object \(\Omega_{o}\) and the background \(\Omega_{b}\). The physical meaning of each term in Equation (1) is as follows: The first term matches the average pixel intensity inside the contour with the pixel intensity of objects by minimizing its mean-squared error. Similarly, the second term matches the pixel intensity of background in the image. The third term regulates the smoothness of the contour, and thus a higher weight of the term implies the smoothing of the contour. The initial condition of the level set function is given by the threshold pixel intensities. With the fixed level set function, \(u_{o}\) and \(u_{b}\) are obtained as follows:  
\[u_{o}=\frac{\int  
Given \(u_{o}\) and \(u_{b}\), the energy function \(E\) is minimized by a standard gradient descent algorithm [23]. This two-step energy minimization is repeated until the converged level set function is obtained. As a result, the zero level set of the converged level set function is matched with the object's boundaries in the image.