1 Introduction

Wire and arc additive manufacturing (WAAM) is one of the most promising additive manufacturing (AM) processes that enable the rapid fabrication of large components with moderate or low complexity, where this process has a high build-up rate, a limitless build-up volume, and low cost (Ref 1). WAAM uses wire feedstock to manufacture parts layer by layer from various metallic materials. However, the AMed parts using the WAAM process may show high roughness (Ref 2), poor reliability (Ref 3), and high residual stresses and distortion (Ref 4). Anisotropy in mechanical properties is a major issue facing AM technologies because of the grain morphology and crystallographic texture (Ref 5, 6). A significant number of studies have investigated the effects of microstructural properties on mechanical properties, including tensile, compressive, and fatigue strengths (Ref 7, 8).

Aluminum and its alloys are the second most used materials, which show high specific strength, corrosion resistance, thermal conductivity, processability, and low density. WAAM process can be used to fabricate Al components for various industries such as automotive, energy, aerospace, etc. Cold metal transfer (CMT), a modified metal inert gas (MIG) welding machine, has been widely applied to AM components with low heat input, spatter-free, and high control of the process parameters during fabrication. Fang et al. (Ref 9) investigated the effect of the arc modes, including CMT, CMT advance, and CMT pulse, on the density and mechanical properties of WAAM parts from ER 5183.

Microstructural characterization of the AM fabricated components is vital for understanding the relationships between microstructural quantities and mechanical properties as well as performance. Among the microstructural quantities, the grain size of the AM parts is one of the essential microstructural quantities, where it correlates with various mechanical properties, including tensile and fatigue strength, hardness, and tribological properties such as wear behavior. In addition, grain morphology has a significant influence on inhomogeneity and anisotropy in mechanical properties. Therefore, analyzing the grain size quickly and objectively is vital in predicting the mechanical behavior. Various techniques have been applied to analyze the microstructural properties, such as machine learning (Ref 10), image processing (Ref 11), and cellular automata models (Ref 12). Among them, image processing is a useful tool in microstructural analysis, particularly in identifying the size and sphericity of grains. However, only a few studies have investigated image processing of the grain features in depth and systematically, while it can be challenging to reveal the grain boundaries of some alloys, particularly aluminum alloys. Despite significant improvements in the image processing techniques, the methods for grain size measurement presented high error and standard deviation in grain size measurements (Ref 13). Hence, further research is needed to improve the image processing techniques, where these techniques could reveal the details of the microstructure. This improvement in the image processing techniques will be vital to advance the analysis of the microstructure of the AM parts, and these techniques can be used to analyze various samples automatically with a significant reduction in time and cost.

Accordingly, in the present research work, the microstructural analysis via digital image processing of fabricated additively manufactured ER 5183 parts using WAAM was investigated systematically and in depth. The statistical analysis and quantitative description of grain size distribution in the AM parts were carried out through MATLAB-based image analysis, which employed an in-house code in order to perform the measurements.

2 Materials and Methods

The AM components were fabricated using ER 5183 (AlMg4.5Mn0.7 (A)) wire with a diameter of 1.2 mm. The AM specimens were manufactured on an AA 5083 platform with 200 × 200 × 15 mm dimensions, and the platform was fixed on the working table. The WAAM system was built by a cold metal transfer CMT TPS 4000 R (Fronius, Austria), a VR 7000-CMT wire feeder (Fronius, Austria), a Robacta Drive CMT PAP W Pro torch (Fronius, Austria), and a Föhrenbach robot (Germany). Figure 1 shows the schematic of the WAAM process. The WAAM alloys produced the multichannel forming path with the dimension of (length × width × height) 150 × 10 × 100 mm. During fabrication, a wire feeding speed of 4 m/min and a (welding) speed of 0.5 m/s were used to fabricate WAAM components. The WAAM process parameters are shown in Table 1. A pure Argon gas was used as the protective process gas with 20 l/min flow rate to prevent any contamination. The microstructure analysis of the WAAM specimens was carried out on the low, middle, and top parts of the fabricated samples, and at least three samples were investigated in each part. Standard metallographic practices were used for the mounting and polishing of the samples, and Keller's reagent consisting of 2.5 ml of HNO3, 1.5 ml of HCl, 1.5 ml of HF, and 95 ml of distilled water was used as an etchant. The microstructural characterization was carried out using a Zeiss FEG scanning electron microscope fitted with an energy-dispersive x-ray (EDX) and optical microscopy (OM) (KEYENCE VH-Z100UR). The structural analysis of the alloys was performed using an x-ray diffractometer Rigaku SmartLab SE with a D/teX Ultra 250 1D detector with Cu-Kα radiation (λ = 0.154056 nm). During the measurement, a step size of 0.01 with an exposure time of 5 s per step along the direction of deposition was used. The crystallite size was determined using the Scherer equation as follows (Ref 14):

$$D = \frac{K\lambda }{{\beta \cos \theta }}$$
(1)

where D is the crystallite size, K is the shape factor, λ is the wavelength, β is the full width at half maximum (FWHM) of the diffraction peak, and θ is the Bragg angle. Bragg's law and the plane spacing equations were used to calculate the lattice parameters (Ref 15), respectively, as follows:

$$\lambda = 2d\sin \theta$$
(2)
$$\frac{1}{{d^{2} }} = \frac{{h^{2} + k^{2} + l^{2} }}{{a^{2} }}$$
(3)

where d is the interplanar spacing, \(a\) is the lattice constant, and h, k, and l are the Miller indices. The density of the AM WAAM samples based on Archimedes' principle was measured using an analytical balance (SHIMADZU AUW120D) with a precision of ± 0.00001 g.

Fig. 1
figure 1

(a) Schematic of the WAAM system. (b) Tensile sample fabricated by WAAM according to ASTM standard (E8/E8M-09, subsize specimen)

Table 1 Selected process parameters during WAAM by CMT

The tensile tests of the WAAM samples were conducted by a universal testing machine SCHENCK TREBEL equipped with a 160 kN load cell at a strain rate of 0.2 mm/min, and at least three WAAM samples were tested to evaluate the reproducibility of the results. The extensometer was detached when the strain reached ~ 10% to prevent damage to the extensometer. To measure the fracture strain, the tensile test samples were marked on the gage length with a 30 mm block, and the elongation was measured. The hardness tests were conducted using a Vickers hardness test (Emco-Test) with a force of 100 g for wire and 500 g for WAAM samples and a dwell time of 10 s.

The statistical analysis of AM specimens using the WAAM process was carried out using a MATLAB-based image analysis tool, and the image processing methodology flowchart is shown in Fig. 2. An in-house MATLAB code (R2021b; Mathworks, Natick, Massachusetts, USA) was developed for determining the grain properties, such as size, area, perimeter, and sphericity. The two-dimensional sphericity technique was used to measure the sphericity of the grains. Different methods and definitions were used to determine the sphericity, and among those, the one with the lowest error (real grains recognition error) was chosen. The sphericity of the grains was obtained from a general ratio of perimeter to the area (Ref 16), as follows:

$$C = \frac{4\pi A}{{P^{2} }}$$
(4)

where C is the circularity; P and A are the perimeter and the area of the grains, respectively. The optical image was filtered to determine the grain properties using two 2-dimensional (2D) median filters. The execution time of the program was 4.77 s for the computer with an Intel Core i7, 2.30 GHz, eight cores CPU, and 16 GB RAM.

Fig. 2
figure 2

Methodology flowchart for image processing using MATLAB. The MATLAB code is available on request from the authors

Here, the output unit of the image processing using MATLAB is either µm or circularity index. To verify the output of the MATLAB program, the grain properties, including size, area, and perimeter of the WAAM samples, were measured using the Image J software, according to American Society for Testing and Materials (ASTM) standard. For each dimension, around 60 readings were measured from several optical images, which were obtained from different parts of the WAAM samples. The average values of these measurements were reported.

3 Results and Discussion

Figure 3(a) and (b) shows the etched surface of the ER 5183 wire at the top (transverse section with 1.6 mm diameter) and edge (longitudinal section), respectively. It can be observed that the grain boundaries were not observed on the top and edge of the wire, even though different etching techniques, as well as different magnifications, were used. Cheng et al. (Ref 17) studied the effect of multi-pass drawing of wire on the microstructural properties, and no grain boundary was observed in the wires with different diameters. The hardness test of the ER 5183 wire in both the top and edge sections was carried out, and an indentation is shown in Fig. 3(c). The average Vickers hardness values of the top and edge of the wire were found to be 136 ± 3 and 133 ± 2 HV, respectively.

Fig. 3
figure 3

Microstructure of the etched ER 5183 in (a) top (transverse section with 1.6 mm diameter) and (b) edge (longitudinal section) view. (c) The hardness indentation on the longitudinal section. The microstructure of the fabricated samples using WAAM-CMT in low (d) and high (e) magnification. (f) The XRD pattern of the WAAM-CMT ER 5183

The microstructure of the additively manufactured parts using WAAM-CMT ER 5183 is shown in Fig. 3(d) and (e), in which fine equiaxed grain can be observed. It can be observed that the grains show irregular morphology, and the black spots (with a dimension of ~ 200 nm) could be seen. Zhang et al. (Ref 18) investigated the microstructural properties of WAAM-CMT ER 5183 and reported fine and equiaxed grain (with an average grain size of ~ 37 μm). The theoretical density of the AM parts using WAAM-CMT was found to be 99.0 ± 0.2%. In addition, the x-ray diffraction (XRD) of the WAAM-CMT ER 5183 was carried out (Fig. 3f), where the XRD patterns indicated the presence of face-centered cubic (FCC) phase (α-Al) along with Al3Mg2. The XRD result here agrees with Geng et al. (Ref 19), which investigated the microstructural and mechanical properties of electrospark deposition additive manufacturing AA 5183 and reported an FCC α-Al phase. The crystallite size and lattice parameter (\(a\)) of the WAAM Al sample were observed to be 27.8 ± 7 nm and 0.4065 ± 0.0007 nm, respectively. The lattice parameter (\(a\)) calculated here is close (0.4070 nm) to the report by (Ref 20) for Al5Mg, where they have also mentioned an increase in the lattice constant of Al (~ 0.4047 nm) with the addition of Mg (~ 4.6 × 10−4 nm for every 1 at.%). Furthermore, the chemical compositions of the wire and WAAM-CMT samples using the EDX point scan are tabulated in Table 2, in which it can be observed that the chemical composition of the WAAM-CMT samples is close to the wire.

Table 2 Chemical composition of ER 5183 wire and WAAM-CMT samples was measured using the dispersive energy x-ray (EDX)

The selected tensile stress–strain curve obtained at the room temperature of the WAAM-CMT specimens is shown in Fig. 4(a). The ultimate tensile strength (UTS) and the elongation of the WAAM-CMT specimens were found to be 303 ± 10 and 24 ± 2%, respectively. The UTS values reported here are similar to those reported by (Ref 21). It can be observed that the stress values fluctuated, as shown in the inset (Fig. 4a). The Lüder bands were observed on the width of tensile strength samples after the test, as shown in Fig. 4(b) and (c), which is because of the insufficient movement of the dislocations (Ref 22). Several studies have reported the presence of Lüder bands in Al-Mg alloys (Ref 23,24,25). Lloyd et al. (Ref 26) investigated the Lüders strain in AI-Mg alloy (AA5182) and reported the fluctuation (serration) of the stress and they concluded that the grain boundary structure and processing route play an important role. Figure 4(d) and (e) shows the fracture surface of the WAAM-CMT sample in low and high magnification, respectively, where deep dimples can be seen in the fracture surface of the ER 5183 samples, suggesting a ductile behavior of the WAAM-CMT ER 5183 samples. The surface hardness of the fabricated WAAM-CMT samples was observed to be 84 ± 4 HV. Zhang et al. (Ref 18) fabricated AM ER 5183 samples using WAAM-CMT and reported a Vickers hardness value of ~ 98 HV.

Fig. 4
figure 4

(a) Selected tensile stress–strain curve was obtained at room temperature for the WAAM-CMT ER 5183. The optical image of the surface of the tensile test sample: (b) low and (c) high magnification. The tensile sample and a micrograph of its surface before the test are shown in Appendix. Low magnification of the tensile sample width is shown in Appendix. The scanning electron microscope (SEM) images of the fracture surface of the tensile test samples: (d) low and (e) high magnification. To prevent damage, the extensometer was detached when strain reached ~ 10%, and the elongation was measured manually

Image processing techniques were employed to analyze the grain features, including size, sphericity, area, and perimeter of the AM fabricated samples using WAAM-CMT, and a MATLAB code was developed to analysis these features. Figure 5(a) is used as the marker image for image analysis, where most of the grains are distinguishable and have a different color from their neighbors. On the other hand, the obtained microstructure of WAAM-CMT ER 5183 samples contains black dots, where these black dots are considered as noises in the image processing of grains morphology. These noises could be considered as individual grains during the processing of statistical analysis, which are distinguishable with different colors. Therefore, a median filter of MATLAB was applied to smooth the image and to illuminate the noises (e.g., black spots) from the marker image. The median filter can effectively remove the noises from an image, in particular salt-and-pepper noise (SPN), while preserving the edges and sharpness of the image (Ref 27). In addition, the bwareaopen function of MATLAB was used to remove the noises of the marker image. Figure 5(b) indicates the marker image before applying the filters and removing the noises. Then, the filtered image was used for edge detection of the grains, and Fig. 5(c) shows the image after filtering. It is worth mentioning that the filtering was applied in different stages to eliminate noises and improve the precision of measurement using image processing. The RGB images were converted to a hue, saturation, and value (HSV) image, as illustrated in Fig. 5(c).

Fig. 5
figure 5

Pre-processing of the image using MATLAB to obtain the grain features. (a) The marker image was obtained by an optical microscope. Conversion to HSV image: (b) before filtering and (c) after filtering. Several filtering steps were used in each stage to eliminate the noises. Note that different depths of focus and corrections in the optical microscope were chosen to reduce the number and size of the noises (black spots)

The MATLAB code was developed to analyze the grain features of the HSV image and the output of this statistical analysis is shown in Fig. 6(a), (b), (c), and (d). The grain morphology plays a vital role in the mechanical properties, reliability, and performance of the AM fabricated parts. The grain properties could result in anisotropic (directionally dependent) mechanical properties, and columnar grain microstructure may show anisotropic mechanical properties. Hence, the circularity index of grains can estimate the performance of the AM fabricated parts, where it is defined as the ratio of the perimeter to the area in image processing for the characterization of a two-dimensional (2D) sphericity. Here, the circularity was determined using Eq 4, and the values close to one show that the grain is close to a perfect circle, and the values close to zero show highly non-circular shapes. The obtained value of the mean circularity that was larger than one was converted to the 0-1 range. Figure 6(a) shows the measured circularity of the grains, and it can be observed that a relatively large number of the grains show a circularity index below ~ 0.5., and the mean circularity index was found to be 0.4536. In addition, the MATLAB method was used to estimate the boundary of the grains and determine their diameter. The analysis of the grain diameters is shown in Fig. 6(b), where the average diameter was observed to be ~ 32 ± 22 µm. García-García et al. (Ref 13) applied MATLAB-based image analysis to determine the grain morphology of steel weld joints, and they determined the grain size and reported a bimodal size, including fine and coarse grains.

Fig. 6
figure 6

Image processing using MATLAB program. (a) The circularity of the grains. Note that the maximum circularity is one. (b) Diameter, (c) area, and (d) perimeter of the grains. The obtained results in the pixel are displayed in Appendix

The area and perimeter of the grains can be used to justify the obtained results, such as circularity. In addition, the area and perimeter values can provide more details, where these details can be used to compare the mechanical properties of the AM parts. The area and perimeter of the grains were computed by identifying the color code associated with each grain using the MATLAB program, and outputs are displayed in Fig. 6(c) and (d), respectively. The average area (Fig. 6c) of the grains was observed to be ~ 1166 ± 1740 µm2, and the maximum and minimum areas were found to be 9339 and 139 µm2, respectively. The average perimeter (Fig. 6d) of the grains was observed to be ~ 203 ± 211 µm, and the maximum and minimum of the perimeter were found to be 981 and 43 µm, respectively.

The grain properties of the WAAM-CMT ER 5183 using image processing techniques were investigated and the obtained results from MATLAB were presented; however, the reliability and accuracy of these results need to be assessed. To verify the obtained results from the MATLAB program, the grains features, including the area, perimeter, radius, and circularity, were measured, and the results were compared with those computed by MATLAB, as shown in Fig. 7. It can be observed that there is a satisfactory agreement between the results obtained from the MATLAB and manual measurements. According to the Hall–Petch relationship, grain size of AM components has a significant influence on mechanical properties (Ref 28, 29). The average grain size measured manually was found to be ~ 36 ± 27 µm, indicating a neglectable error (~ 12%) from those obtained by MATLAB. It is worth mentioning that the mean measurement error is ~ 4 µm which is negligible. The effect of grain boundary is an important factor that affects the microstructural and mechanical properties of metallic materials. The average area of the grains measured manually is also in satisfactory agreement with the obtained output from MATLAB, where it was found to be ~ 1355 ± 1076 µm2, and the maximum and minimum area was found to be 4510 and 81 µm2, respectively. The average perimeter of the grains measured manually is also in satisfactory agreement with the obtained output from MATLAB, with an average perimeter of ~ 139 ± 80 µm. The maximum and minimum of the perimeter were found to be 329 and 38 µm, respectively.

Fig. 7
figure 7

Comparison of grain features determination using the MATLAB program with those obtained from manual measurements

Automatic image processing for identifying grain properties or defects could be a great benefit for engineers and scientists. On the other hand, determining the properties of the microstructure, in particular grain properties, has been a challenging task in image processing analysis. The images that contain noises, such as black spots and/or scratches, may show a degree of uncertainty and consider these noises as grains or grain boundaries, and their features can also be presented with other grains. In addition, the color of the grains also plays an important role in the reliability and certainty of the program output. In fact, the grains that have distinguishable color from their neighbor grains can be identified separately and improve the reliability of the output. It is worth mentioning that the neighbor grains that have a similar color may be considered as a single grain and have an impact on the output. Therefore, the quality of the image plays a vital role, and adjusting the contrast and resolution of the microstructure could resolve the issues and reduce the uncertainty of the output. Moreover, the noises, in particular the black spot, can be eliminated by adjusting the focus point of the microscope, which has an influence on the output of the program and may improve the precision of the measurement.

The additively manufacturing WAAM process has a relatively high cooling rate and high thermal gradient that can lead to the formation of columnar grain structure aligned to the heat flow direction and consequently result in anisotropy in the mechanical properties, such as tensile strength. In addition, defects, such as cracks, can appear in the AM parts because of the high heat input and thermal distortion, which significantly influence the performance and reliability of the parts. Moreover, the AM parts may show a degree of inhomogeneity in microstructure and mechanical properties (Ref 28). These issues of the WAAM parts, including the formation of coarse grains, the columnar microstructure, and the crack susceptibility, can be resolved with the reduction in grain size, in which grain refinement strategies have already been applied to the WAAM process (Ref 30, 31). An automatic image processing for identifying the grain properties or defects could benefit the manufacturing sector, which is of particular interest to small and medium-sized enterprises that can save research and development costs in this way. In addition, image processing techniques can be used to identify the lack of fusion or metallurgical (gas) porosities that have irregular and circular morphology, respectively, where these defects have a significant impact on the mechanical properties. Here, an automatic image processing for determining the grain properties was developed, and the results were compared with those obtained manually, in which a negligible error was observed. These findings can help to improve the microstructural characterization of the AM parts and provide further details, and consequently advance the analysis of the microstructure. This would lead to the possibility of characterizing the microstructure in a broader range and having more details and saving time and money.

4 Conclusion

Additively manufactured ER 5183 components using WAAM-CMT were fabricated, and the microstructure and mechanical properties (tensile strength and hardness) were investigated. The image processing techniques were applied to characterize the microstructural properties. The present paper investigated the methods for the determination of grain features, including size, sphericity, area, and perimeter, using the MATLAB program. Values for grain properties computed by MATLAB were compared with those obtained by manual measurements, where both methods showed similar results, indicating a negligible error. The present findings can help to improve the analysis of the microstructure properties and advance the present knowledge about image processing. In particular, the present finding can be applied to characterize the microstructure of the AM parts, which in turn could lead to estimating the mechanical properties of the fabricated parts. This would lead to the possibility of characterizing the microstructure in a broader range and having more details, and saving time and cost.