Three-Dimensional Imaging of Metallic Grain by Stacking the Microscopic Images

: Three-dimensional observation of metal grains (MG) has a wide potential application serving the interdisciplinary community. It can be used for industrial applications and basic research to overcome the limitations of non-destructive testing methods, such as ultrasonic testing, magnetic particle testing, and eddy current testing. This study proposes a method and its implementation algorithm to observe (MG) metal grains in three dimensions in a general laboratory environment equipped with a polishing machine and a metal microscope. An image was taken by a metal microscope while polishing the mounted object to be measured. Then, the metal grains (MGs) were reconstructed into three dimensions through local positioning, binarization, boundary extraction, (MG) selection, and stacking. The goal is to reconstruct the 3D MG in a virtual form that reﬂects the real shape of the MG. The usefulness of the proposed method was veriﬁed using the carbon steel (SA106) specimen.


Introduction
Predicting, comprehending, and monitoring the microstructure and mechanical properties, such as heterogeneous microstructure, ductility decreases, the concentration of residual stress, brittleness, and deterioration of toughness, of critical structures, such as heat exchangers, power plants, the oil and gas industry, chemical engineering, and especially nuclear power plants, is important to ensure safety and avoid failures that can lead to environmental disasters, causalities, and financial losses. To prevent and avert such risks, and to ensure the continued safety and integrity of these structures, periodic inspections are required [1][2][3][4].
Numerous non-destructive methods can be used for microstructure characterization. In most cases, non-destructive testing cannot directly determine material characteristics, which are established by destructive testing. To quantify material properties non-destructively, non-destructive methods must be correlated with destructively measured standard data. The limitation and disadvantage of destructive methods are that they do not allow the characterization of the evolution of material properties of the same specimen when successively damaged [3], and they are not easily applicable to characterize the mechanical behavior of materials, if possible, with restricted, difficult and expensive access, even using a numerical simulation, such as the finite element method.
The finite element method is used to analyze the relationship between the load, stressstrain, and resistance to failure of a structure [5][6][7][8]. Meanwhile, according to conventional studies, the size and shape of the microstructure affect the strength, toughness, and creep 2 of 16 resistance of the structure [9][10][11]. However, it is not easy to reflect and demonstrate this with the finite element method [12][13][14][15]. This is because the factor used in the finite element method is the shape of the structure and does not include the microstructure of the structure itself. Therefore, we have not yet seen an example in which the size of the microstructure is inserted as an analysis condition in the finite element method (or two-dimensional analysis). Therefore, in order to analyze the shape and size of the microstructure, it is necessary to express the shape of the grain in three dimensions. On the other hand, the size and shape of the grains affect the analysis results of non-destructive tests [16][17][18][19], such as ultrasonic testing, magnetic particle testing, and eddy current testing. For instance, in the case of ultrasonic examination, research results have been reported that the size and shape of the microstructure influence the scattering of the sound [20]. However, analysis or qualitative matters considering only the average size of the microstructure are reported in [21], and it is difficult to find previous studies on ultrasound wave scattering targeting the size and shape of the actual microstructure. In the magnetic particle inspection method, the sample is magnetized, and the adsorption of magnetic particles by the magnetic flux leakage generated around the defect is observed. At this point, if a strong external magnetic field is applied and then removed, residual magnetization occurs. A similar fault signal is generated, in which magnetic particles are adsorbed even in non-defective areas due to residual magnetization [22][23][24]. Even though the deformation caused by an external force causes the magnetic moment inside the magnetic domain to be anisotropic in a specific direction and, therefore, residual magnetization occurs even if an external magnetic field is not applied [25][26][27]. In addition, residual magnetization is frequently generated in welds where heat and residual stress are generated by an external force. In the eddy current method of inspection, an induced current is applied to an object to be measured, and the distortion of the induced current occurring around a fault, that is, a change in impedance and a different phase due to eddy currents is measured [28,29]. However, it is difficult to determine the presence or size of a defect due to the edge effect that occurs at the end of the object to be measured [30]. This means that even when the grain is needle-shaped or the shape changes rapidly, the eddy current signal can be affected. It is important to provide a means of quantitatively measuring and expressing the three-dimensional shape of a grain in order to grasp the effects of such effects, i.e., the formation of magnetic domains, residual magnetization, and the effects of edge according to the shape and size of the grain. According to nano-radiography and tomography, the metal grain can be imaged in three dimensions [31,32]. Nevertheless, this requires very high accuracy and expensive equipment, including X-ray shielding. Furthermore, it is difficult to measure the distribution of magnetic domains within the grain in three dimensions. In addition, under the heat treatment influence, the application of external field and mechanical stress can rearrange the martensite variant and can change the magnetic domains. It is important to understand their effect not only at the macroscopic level but also at the microscopic level [33][34][35][36]. In this context, the use of an alternative method to overcome the limitations of non-destructive testing (NDT) techniques can make a valuable contribution to the characterization of materials and the evaluation of microstructure performance through rapid and efficient experiments and simulations. In this paper, we present a method to reproduce the real shape and size of the grains of the tested sample SA106 by pilling up two-dimensional images obtained by a metal microscope. To achieve this target, we introduce fixtures, procedures, and software algorithms based on mathematical formulas.
Several studies have previously developed 2D and 3D techniques to construct a way to study microstructure using different experimental and simulation techniques. The results of these studies lead to a good outcome that provides access to crucial structural information of the investigated materials, which facilitates and enhances the understanding of physical and chemical concepts at the microscopic level [37][38][39][40][41][42][43].
However, we have not seen any work similar to our work, which allows the reconstruction, extraction, and selection of one or more grains with the exact shape and size of the inspected material, without using extensive software and hardware, but just simple equipment and some algorithms. It should be emphasized that the method presented here permits: (1) 3D grain shape obtaining; (2) using conventional research laboratory environment; (3) easy preparing specimens; (4) multi-parallel data acquisition; (5) easy 3D image processing. This is particularly important for the industry and research laboratories.
The finding is encouraging for the near future application of the method for the analysis of 3D stress, strain deformation at grain level, and the analytical study of nondestructive evaluations using electromagnetic and ultrasound testing.

Specimen and Layer Capture
In this study, carbon steel SA106 was targeted. The sample was cut and cropped to a small volume of 25 × 9 × 25 mm (width × length × height), respectively, and mounted on a cylindrical resin with a diameter of 35 mm and a height of 27 mm. Then, the observation side and the backside of the mounted specimen were polished to be exposed outside the resin. This allows the "polished" height to be measured more accurately when viewed under a microscope. In other words, when measuring the height of the sample with a micrometer after polishing, errors likely to be caused by compression of the resin can be avoided when the resin is used as a measurement reference and not the surface of the sample. As shown in Figure 1a, the side surface was polished to deflect by 1.84 mm. This deflected side surface (hereafter "key-hole") was used as a reference surface for microscopic observation. Figure 1b is a jig for uniform grinding of the key-hole, and Figure 1c is a template (state) in which the key-hole is polished in the sample mounted in the jig. Figure 1d illustrates these mounted samples; they are inserted into the X-Y stage holder under the microscope and are fixed by a key (expressed in black in the figure). Due to this structure, the area observed by the microscope can fix the measurement surface with a repeatability of the order of 10 to 20 µm.   The observation surface was polished using SiC polishing pads FEPA P200, P400, P800, P1200, and P2000. The last stage, P2000, has a grid size of 10.3 µm. Finally, fine polishing was carried out for 20 s using polishing cloths and polycrystalline diamond paste having a grid size of 1 µm. Once the micro-polishing was completed, an etchant solution obtained by diluting with nitric acid 3 g in 65 g ethanol was exposed onto the observation surface for 5 s, followed by ultrasonic cleaning with distilled water for 15 s and then cleaning with ethanol for 10 s. This chemical etching was performed a total of three times. The height of the four sides of the test sample was measured with a micrometer having an accuracy of ±0.01 µm, visualized through the microscope (500×), and recorded on the laptop. The observation by the microscope was repeated while repeating fine polishing, chemical etching, as well as the height measurement and can be directly linked to the 3D image processing. A total of 60 fine polishes were performed; Table 1 shows the heights measured in each layer.

Local Positioning
As mentioned above, the main goal of this study is to image MG in 3D. To reach our purpose, micrographs are taken while repeatedly polishing. At this time, the height information measured by the micrometer is taken as the z-axis. Then the location of the boundary of a specific MG selected in the photo is stored as the x-y coordinates. Therefore, it is possible to obtain three-dimensional coordinates for the node representing the boundary of the MG.
However, as the experimental methodology seems very simple, a challenge associated with this technique is a positional error within ±7 µm that occurred when the specimen was polished, and the same area was observed, even though we used very accurate equipment to avoid this (backlash play), because of the high special-resolution used (2 µm). As an example, Figure 2 is a photograph (hereinafter, nth layer photo) taken after polishing an area of 130 × 98 µm three times, four times, and fifth times, respectively, using a microscope at a magnification of 500. For mutual comparison, a white line with a + mark is indicated in the center. Based on the 3rd layer, the position of the 4th layer is shifted to the upper left. Further, based on the 4th layer, the 5th layer has moved to the right. Meaning the photos of each layer are not in the same position.
Appl. Sci. 2021, 11, x FOR PEER REVIEW 6 of 17 possible to obtain three-dimensional coordinates for the node representing the boundary of the MG. However, as the experimental methodology seems very simple, a challenge associated with this technique is a positional error within ±7 μm that occurred when the specimen was polished, and the same area was observed, even though we used very accurate equipment to avoid this (backlash play), because of the high special-resolution used (2 μm). As an example, Figure 2 is a photograph (hereinafter, nth layer photo) taken after polishing an area of 130 × 98 μm three times, four times, and fifth times, respectively, using a microscope at a magnification of 500. For mutual comparison, a white line with a + mark is indicated in the center. Based on the 3rd layer, the position of the 4th layer is shifted to the upper left. Further, based on the 4th layer, the 5th layer has moved to the right. Meaning the photos of each layer are not in the same position. To correctly stake the images, improve the accuracy, and achieve high precision of the final desired result, we have developed and used a set of algorithms that automatically corrects these positional errors. Figure 3a is an nth layer and is used as a reference. Figure  3b is a target as the (n + 1)th layer. Each microscope image is composed of 1536 and 2048 pixels in the row and column directions, respectively. The horizontal column is the x-direction, and the vertical row is the y-direction. The origin of the coordinates is (1,1), which is left-top based on the pixel, and the last coordinate is (2048,1536), which is the right- To correctly stake the images, improve the accuracy, and achieve high precision of the final desired result, we have developed and used a set of algorithms that automatically corrects these positional errors. Figure 3a is an nth layer and is used as a reference. Figure 3b is a target as the (n + 1)th layer. Each microscope image is composed of 1536 and 2048 pixels in the row and column directions, respectively. The horizontal column is the x-direction, and the vertical row is the y-direction. The origin of the coordinates is (1,1), which is left-top based on the pixel, and the last coordinate is (2048,1536), which is the right-bottom. To correctly stake the images, improve the accuracy, and achieve high precision of the final desired result, we have developed and used a set of algorithms that automatically corrects these positional errors. Figure 3a is an nth layer and is used as a reference. Figure  3b is a target as the (n + 1)th layer. Each microscope image is composed of 1536 and 2048 pixels in the row and column directions, respectively. The horizontal column is the x-direction, and the vertical row is the y-direction. The origin of the coordinates is (1,1), which is left-top based on the pixel, and the last coordinate is (2048,1536), which is the rightbottom.
(a) (b)  The (x 1 , y 1 ) and (x 2 , y 2 ) shown in Equation (1) In Equation (2), the region of Figure 3a was selected from the first layer photo, which means that it was used as a reference photo. In other words, when stacking the photos, they should be positioned with the first one defined as the reference. In addition, Equations (3) and (4) involve selecting a region to be analyzed with respect to the reference photo in the second layer photo, which is a target for local positioning. Select a total of cases from the domain of (x 1 − h, y 1 − h) and (x 2 − h, y 2 − h) to the domain of (x 1 + h, y 1 + h) and (x 2 + h, y 2 + h). Where h represents the maximum position error of each layer. Figure 3b is the case of h = 100, which is a schematic diagram of the selection of a total of 40.000 cases from the domains of (151,101) and (1800,1200) to the domains of (351,301) and (2000,1400).
Equation (5) denotes S 1 (i,j), the sum of the absolute values of the differences between each element of the matrix of the selected region in the reference photo and the target photo, respectively. Equation (6) denotes the row ∆X 2 and column ∆Y 2 having the minimum value in S 1 (i,j). In this instance, (∆X 1 , ∆Y 1 ) = (0, 0). Furthermore, the minimum value of S 1 (i,j) is generated at the position where the reference photo and the target photo almost coincide.
Thereafter, as shown in Equations (7)- (9), the reflecting region in the nth layer photo becomes the reference, and the local positioning is repeated by comparing it with the target (n + 1)th layer photo. Using this process along with ∆X n and ∆Y n for each layer obtained using Equation (10), the region of interest of the first layer photo, to be the same region as the other target photos, each local positioning of the region having X 1 , Y 1 and X 2 , Y 2 as the diagonal vertices layer, can be observed, as shown in Equation (11). P n ∆x∆y = P n target (x 1 + ∆X n : x 2 + ∆X n , y 1 + ∆Y n : y 2 + ∆Y n ) P n+1 P n align = P n target (X 1 + ∆X n : On the other hand, X 1 , X 2 , Y 1 , Y 2 of Equation (11) to be selected for observing the change of a specific cross section of the MG are independent of x 1 , x 2 , y 1 , y 2 of Equations (1), (2), (7) and (8) , an area of 1700 × 1200 pixels in Figure 4a,b, and also 420 × 420 pixels in Figure 4c,d were selected, respectively. (1), (2), (7) and (8)

Selection and Binarization
In order to select a specific MG and image it in 3D, it is necessary to select the boundary surface of the corresponding MG. First, a point inside a specific MGF is read, it is called point-1, and the brightness of the corresponding coordinate is read. Next, a point is read in the boundary area, it is called point-2, and the brightness of the corresponding coordinate is read. Half of the difference between the two coordinates is used as the (1), (2), (7) and (8) , , , , an area of 1700 × 1200 pixels in Figure 4a,b, and also 420 × 420 pixels in Figure 4c,d were selected, respectively.

Selection and Binarization
In order to select a specific MG and image it in 3D, it is necessary to select the boundary surface of the corresponding MG. First, a point inside a specific MGF is read, it is called point-1, and the brightness of the corresponding coordinate is read. Next, a point is , , an area of 1700 × 1200 pixels in Figure 4a,b, and also 420 × 420 pixels in Figure 4c,d selected, respectively.

Selection and Binarization
In order to select a specific MG and image it in 3D, it is necessary to select the b ary surface of the corresponding MG. First, a point inside a specific MGF is read called point-1, and the brightness of the corresponding coordinate is read. Next, a p

Selection and Binarization
In order to select a specific MG and image i ary surface of the corresponding MG. First, a called point-1, and the brightness of the corresp

Selection and Binarization
In order to select a specific MG and image it in 3D, it is necessary to select the boundary surface of the corresponding MG. First, a point inside a specific MGF is read, it is (1100,583).

Selection and Binarization
In order to select a specific MG and image it in 3D, it is necessary to select the boundary surface of the corresponding MG. First, a point inside a specific MGF is read, it is called point-1, and the brightness of the corresponding coordinate is read. Next, a point is read in the boundary area, it is called point-2, and the brightness of the corresponding coordinate is read. Half of the difference between the two coordinates is used as the threshold, and the resulting ones are separated into a double collection of pixels (two levels of color), namely bright and dark. If it is bright, it is replaced by "1", and if it is dark, it is replaced by "0".
After fixing the column at point-1, the row with the first 0 is read while shrinking the row. In Figure 5a, the horizontal direction is the column, and the vertical direction is the row. The column number increases as the column moves to the right. On the other hand, the row number increases as the row goes down. Hence, the upward arrow in Figure 5b means that the row becomes smaller. Therefore, the starting point of the boundary can be found by adding 1 to the row where the first 0 occurs. Furthermore, according to the micrograph, voids may occur in the layer or be expressed as black dots (points) due to decidualization. The presence of these dots may confuse the position of the first zero in the row. As a matter of fact, in this study, as can be seen in Figure 5c, all the small "0" surrounded by the wide distribution of "1" were changed to "1". By these measures, the black dots inside each layer in Figure 5b become collectively "1", as depicted in Figure 5c, such that the position of the boundary can be clearly found.
Appl. Sci. 2021, 11, x FOR PEER REVIEW 9 of 17 row. As a matter of fact, in this study, as can be seen in Figure 5c, all the small "0" surrounded by the wide distribution of "1" were changed to "1". By these measures, the black dots inside each layer in Figure 5b become collectively "1", as depicted in Figure 5c, such that the position of the boundary can be clearly found. Figure 5d is a diagram explaining the algorithm for finding the coordinates of the boundary after finding the starting point of the boundary by the algorithm of Figure 5c. We know the positions of the 'first 0′ and 'last 1′. The presence or absence of "1" and "0" is checked in four adjacent pixels. There are four cases. Point-1 moves to the upper side and stops at the boundary of "1" and "0", so it is the fixed condition. We can assume four cases, including this fixed condition, right upper, and right side will be 1-1, 0-1, 0-0, 1-0. In the case of 0-1, the boundary is to the right, as shown in the following case of the breakpoint in Figure 5d. In the case of 1-1, the boundary will be right-side up, as shown in the following case of 0-1 in Figure 5d. In the case of 0-0, as shown in Figure 5d, the peak at the following arrows. The MATLAB command boundary is used.

Nodes and Stacking
When the metallographic microscope used in this paper is set to 500× magnification, the resolution per pixel is approximately 0.063 μm; the micrometer accuracy for measuring the height is 0.01 μm. Consequently, the boundary expressed by the (x,y) coordinates obtained from the MG picture is drawn with a relatively large number of nodes compared to the height z, and higher spatial resolution than necessary. This reduces the computational speed during three-dimensional imaging, as well as forming needle-like surfaces up and down. To overcome this problem, if the number of nodes forming the boundary  stops at the boundary of "1" and "0", so it is the fixed condition. We can assume four cases, including this fixed condition, right upper, and right side will be 1-1, 0-1, 0-0, 1-0. In the case of 0-1, the boundary is to the right, as shown in the following case of the breakpoint in Figure 5d. In the case of 1-1, the boundary will be right-side up, as shown in the following case of 0-1 in Figure 5d. In the case of 0-0, as shown in Figure 5d, the peak at the following arrows. The MATLAB command boundary is used.

Nodes and Stacking
When the metallographic microscope used in this paper is set to 500× magnification, the resolution per pixel is approximately 0.063 µm; the micrometer accuracy for measuring the height is 0.01 µm. Consequently, the boundary expressed by the (x,y) coordinates obtained from the MG picture is drawn with a relatively large number of nodes compared to the height z, and higher spatial resolution than necessary. This reduces the computational speed during three-dimensional imaging, as well as forming needle-like surfaces up and down. To overcome this problem, if the number of nodes forming the boundary is reduced, the shape of the layer may be distorted. Accordingly, in this section, we examined how effective it is to reduce the number of nodes forming the boundary of the organization.
Let the pixels of the camera (microscope) be as defined by Equation (12). Generally the ratio of vertical and horizontal pixels is such that m/n = 4/3. The spatial resolution of the image, which can be obtained using the microscope, depends on the optical lens system and can be expressed by Equation (13).
where w and h are the width and height of each image. The quantitative distance between each pixel can be derived from Equation (14) P = w/n (µm/pixels) Here we were using m = 2048 and obtaining w = 130 (µm). Therefore, P would be 130/2048 (µm/pixels), corresponding to 0.063 (µm/pixels). However, as indicated in Table 1, the height of each layer after polishing was 1-2 µm. If we use P = 0.063 (µm/pixels), the lateral surface of the crystal will be expressed as shallow needle-like squares, and the surface lacks uniformity, due to the small value of P. In order to reproduce the result well, we defined P as expressed in Equation (15), with P = P × r and r = 30 ∼ 60. P = w /n (µm/pixels) Figure 6a is a polygonal figure drawn by the boundary coordinates obtained by the above-mentioned algorithm using the picture shown in Figure 4c. There are 3084 polygonal vertices, represented by solid blue lines. Then, the polygons expressed by 1028 vertices skipping three each were expressed by green dot-lines, and the polygons expressed by skipping nine by 343 dots were expressed by circular lines marked in red. A black dot-line is a polygon expressed by 114 dots that are skipped by 27. In the case of a bay with a complex shape located above the structure, it cannot be expressed by the number of vertices being skipped by 27, but the shape of the bay can be expressed by the marked red circular solid line that is expressed by skipping every nine. This means that detailed regions of the structure can be expressed with a spatial resolution of about 0.57 µm. Meanwhile, Figure 6b shows the area of the polygon as a function of the number of vertices of the polygon. The area of the polygon drawn with 114 vertices by skipping 27 is reduced by about 50%; however, when less than 13 are skipped, the area ratio hardly changes. Therefore, in this study, a boundary with a spatial resolution of 0.57 µm was applied by skipping nine each. Figure 7a-d shows the boundary with a spatial resolution of 0.57 μm of the microscope's xy section image for the shape of three layers (#1, #2, #3) along the z-axis height, respectively, which is the result of extraction. In the case of #1 and #2, we see an example of a layer that gradually narrows in width as it is polished. If the layer of #1 in Figure 7d becomes smaller, this means that it can be eventually be divided into several layers as in #2. Figure 8a-c is the results of stacking by extracting the coordinates of the layer's boundaries #1, #3, #5, and #6 by height. #1 indicates a shape in which the cross-sectional area increases gradually and then decreases again. #3 decreases gradually, and at the same time, #5 increases gradually, and #6 appears. Figure 8d is a top view, and #2 and #3 partially overlap to show that a part of the organization has been merged. On the plus side, the upper part of #1 represents a phenomenon in which the layer is separate as the polishing proceeds into a state in which the upper left layer is integrated. Figure 7a-d shows the boundary with a spatial resolution of 0.57 µm of the microscope's xy section image for the shape of three layers (#1, #2, #3) along the z-axis height, respectively, which is the result of extraction. In the case of #1 and #2, we see an example of a layer that gradually narrows in width as it is polished. If the layer of #1 in Figure 7d becomes smaller, this means that it can be eventually be divided into several layers as in #2. Figure 8a-c is the results of stacking by extracting the coordinates of the layer's boundaries #1, #3, #5, and #6 by height. #1 indicates a shape in which the cross-sectional area increases gradually and then decreases again. #3 decreases gradually, and at the same time, #5 increases gradually, and #6 appears. Figure 8d is a top view, and #2 and #3 partially overlap to show that a part of the organization has been merged. On the plus side, the upper part of #1 represents a phenomenon in which the layer is separate as the polishing proceeds into a state in which the upper left layer is integrated. Figure 7a-d shows the boundary with a spatial resolution of 0.57 μm of the microscope's xy section image for the shape of three layers (#1, #2, #3) along the z-axis height, respectively, which is the result of extraction. In the case of #1 and #2, we see an example of a layer that gradually narrows in width as it is polished. If the layer of #1 in Figure 7d becomes smaller, this means that it can be eventually be divided into several layers as in #2. Figure 8a-c is the results of stacking by extracting the coordinates of the layer's boundaries #1, #3, #5, and #6 by height. #1 indicates a shape in which the cross-sectional area increases gradually and then decreases again. #3 decreases gradually, and at the same time, #5 increases gradually, and #6 appears. Figure 8d is a top view, and #2 and #3 partially overlap to show that a part of the organization has been merged. On the plus side, the upper part of #1 represents a phenomenon in which the layer is separate as the polishing proceeds into a state in which the upper left layer is integrated.

Post-Processing
The above result is the stacking of the boundary in each layer, and to understand it as a volume, it is necessary to form a surface connecting the coordinate point of the boundary and the position of the adjacent height. In this study, the results shown in Figures 9 and 10 was obtained using "alpha Shape", a function that creates a boundary area or volume surrounding a set 2D or 3D point in MATLAB. This 3D graphical function may help to understand the layer or MG by imaging the shape of the layer in 3D.
Due to the large grain selected in layer 8, as shown in Figure 9, it is difficult to understand the original shape of the 3D image. Furthermore, we do not know which data is correct in layer 8, that is to say, whether it is connected to the neighboring grain or not. Therefore, we have to compare four figures, namely the original microscopic image, the extracted boundary image, and two types of stacked volumetric images. The reconstructed 3D grains volume is illustrated in Figure 10.

Post-Processing
The above result is the stacking of the boundary in each layer, and to understand it as a volume, it is necessary to form a surface connecting the coordinate point of the boundary and the position of the adjacent height. In this study, the results shown in Figures 9 and 10 was obtained using "alpha Shape", a function that creates a boundary area or volume surrounding a set 2D or 3D point in MATLAB. This 3D graphical function may help to understand the layer or MG by imaging the shape of the layer in 3D.

Post-Processing
The above result is the stacking of the boundary in each layer, and to understand it as a volume, it is necessary to form a surface connecting the coordinate point of the boundary and the position of the adjacent height. In this study, the results shown in Figures 9 and 10 was obtained using "alpha Shape", a function that creates a boundary area or volume surrounding a set 2D or 3D point in MATLAB. This 3D graphical function may help to understand the layer or MG by imaging the shape of the layer in 3D.
Due to the large grain selected in layer 8, as shown in Figure 9, it is difficult to understand the original shape of the 3D image. Furthermore, we do not know which data is correct in layer 8, that is to say, whether it is connected to the neighboring grain or not. Therefore, we have to compare four figures, namely the original microscopic image, the extracted boundary image, and two types of stacked volumetric images. The reconstructed 3D grains volume is illustrated in Figure 10.  Due to the large grain selected in layer 8, as shown in Figure 9, it is difficult to understand the original shape of the 3D image. Furthermore, we do not know which data is correct in layer 8, that is to say, whether it is connected to the neighboring grain or not. Therefore, we have to compare four figures, namely the original microscopic image, the extracted boundary image, and two types of stacked volumetric images. The reconstructed 3D grains volume is illustrated in Figure 10.

Discussion
In this study, a method and its implementation algorithm for the three-dimensional observation of the microstructure of carbon steel (AS106) was proposed while explaining and illustrating its principle.
The visualization of the shape of the 3D grains with simple equipment, namely a polishing machine, a metallurgical microscope, and some algorithms, is a great advantage. Moreover, it is inexpensive and easy to implement due to its simple technique and does not involve extensive hardware and software.
While the mounted object was being polished, a photograph of the layer was taken using a metallurgical microscope. Subsequently, the metallic MG was reconstructed in three dimensions by assembling and processing the collected 2D images through local positioning, MG selection, binarization, resizing, stacking (superimposing), and surfacing, which provides very accurate data. The assembly and processing techniques are based on mathematical formulae as described above; the program derived from these formulae is straightforward. It is easily accessible and provides a quick result, making it a simple resource to operate and can be implemented in general-purpose software, e.g., MATLAB, C, C++, Python.

Discussion
In this study, a method and its implementation algorithm for the three-dimensional observation of the microstructure of carbon steel (SA106) was proposed while explaining and illustrating its principle.
The visualization of the shape of the 3D grains with simple equipment, namely a polishing machine, a metallurgical microscope, and some algorithms, is a great advantage. Moreover, it is inexpensive and easy to implement due to its simple technique and does not involve extensive hardware and software.
While the mounted object was being polished, a photograph of the layer was taken using a metallurgical microscope. Subsequently, the metallic MG was reconstructed in three dimensions by assembling and processing the collected 2D images through local positioning, MG selection, binarization, resizing, stacking (superimposing), and surfacing, which provides very accurate data. The assembly and processing techniques are based on mathematical formulae as described above; the program derived from these formulae is straightforward. It is easily accessible and provides a quick result, making it a simple resource to operate and can be implemented in general-purpose software, e.g., MATLAB, C, C++, Python. As shown in the example in Figure 6, the MG image is designed by a large number of nodes and will require a lot of computational power. To overcome this, skipping is necessary. However, there is a limit, which should not be exceeded, to not compromise the accuracy of the final results. Skipping by nine, in this case, leads to both minimal resources simulation time and accurately obtained results. Organizational photos may contain personal opinions. In other words, the shredded pieces may, in fact, be the tip of a large layer. If this personal subjectivity is expressed in three dimensions, a somewhat objective judgment is possible.
Notwithstanding non-destructive testing techniques, three-dimensional imaging grains will be one of the most widely used techniques in the near future. Firstly, for its numerous advantages listed in the introduction. Another interest is to be able to reconstruct the shape of the microstructure, which may allow the evaluation and prediction of the material's behavior under stress, damage, heat treatment effects, etc., and a variety of research has been carried out in this area [19,44,45].
The reconstructed 3D grains volume, as illustrated in Figure 10, from the processed 2D images is of significant interest and may be useful for our future research in the field of non-destructive evaluation using mainly electromagnetic and ultrasonic testing to better understand structural properties at the microstructural level. In addition, the generation of a three-dimensional grains structure may also broaden the scope of applications, especially in the field of materials science, designing structural materials, and investigation of engineering materials.
In the last few years, thanks to numerical models and the increase in computing and processing capacity, it has become possible to obtain precise models and simulations of complex material properties, especially microstructures, using advanced software and modeling techniques [46][47][48]. The software algorithms developed under MATLAB employed are complementary to the experimental work, and the combination of the two leads to more accurate and realistic grain representations with a very acceptable simulation time. In addition, the method allows the creation of microstructures with the exact shape and size of the grains and offers the possibility of selecting one or more grains, as illustrated in Figures 7, 8 and 10.

Conclusions
Three-dimensional imaging of metallic grain by stacking the microscopic images was successfully applied to obtain 3D grain volume from processed 2D images. This method can be applied as a useful tool for the characterization of metal grains. It is ready to be used in industrial steel applications. It has been pointed out that the method presented here allows quick and easy use. Furthermore, it does not require many experimental resources.
An efficient technique to avoid positional errors in image piling has been established. Owing to the size of a wide number of nodes, an alternate method was adopted and presented without jeopardizing the precision of the results.