# An Image-Processing Method for Extracting Kinematic Characteristics of Droplets during Pulsed GMAW
## 3 Extraction of Droplet Region by Image Processing
### The Period with an Undetached Droplet
#### 3.1.2 Position Identification of the Minimum Diameter of the Neck  
In the period with an undetached droplet, the droplet and wire are still connected as a whole. As a result, the region of the droplet needs to be segmented artificially, which is the purpose of identifying the position of the minimum diameter of the droplet neck. Position identification of the minimum diameter of the neck is the premise of image cutting and detaching the region of the target droplet. Firstly, a new ROI near neck in Figure 3 was selected, which is the rectangle box region shown in Figure 13. Secondly, distances from all points in one edge of the neck to the other edge in this ROI were calculated. The minimum distance was the minimum diameter of neck, while the corresponding two points were the endpoints of the minimum diameter. Figure 14 shows the binary image of the ROI after the image enhancement mentioned in Section 3.1.1 (adaptive histogram equalization and gamma transformation) and Canny operator recognition. It can be found that the two edges of the neck extended continuously from the top to the bottom of the image. If the pixels in the first line and last line of the binary image were replaced with white pixels, the region of the neck could be sealed by white pixels. Thus, the region of neck could be filled with white pixels by using a hole-filling algorithm [28], and the result is displayed in Figure 15.  
Figure 14: Binary image of region of interest (ROI) after image enhancement and Canny operator recognition. Figure 13: Region of interest (ROI) selection at the neck. The whole white neck in Figure 15b could be extracted by finding the largest connected domain, and the extraction result is shown in Figure 16a. As a result, the background was divided into two parts. Next, these two parts were turned into white pixels, while the original white pixels were turned into black pixels. Thus, the edge of the two half areas could be identified by the Canny operator, so as to separate the two edges of the neck, as shown in Figure 16.  
In order to calculate the minimum distance between the two edges, the algorithm used in this study calculated all the distances from each pixel on one edge to each pixel on the other (Equation (2)) and found the minimum \(L_{\text{min}}\) by comparison (Equation (3)). \[d_{i,j}=\sqrt{\left(x_{i}-x_{j}^{\prime}\right)^{2}+\left(y_{i}-y_{j}^{\prime }\right)^{2}}. \tag{2}\]  
\[L_{\text{min}}=\min(d_{i,j}). \tag{3}\]  
In the two equations, \(d_{i,j}\) is the distance from pixel \(i\) on the left edge to pixel \(j\) on the right edge. \(x_{i}\) and \(y_{i}\) are the abscissa and ordinate, respectively, of pixel \(i\), while \(x^{\prime}_{j}\) and \(y^{\prime}_{j}\) are the abscissa and ordinate of point \(j\). If \(i=\text{I}\) and \(j=\text{J}\) when \(d_{i,j}\) is the minimum value, then the two edge coordinates of the minimum diameter of neck are \((x_{l},y_{l})\) and \((x_{l},y_{l})\). However, \((x_{l},y_{l})\) and \((x_{l},y_{l})\) are the coordinates of the ROI in Figure 14, which can be further converted into the coordinates \((X_{l},Y_{l})\) and \((X_{l},Y_{l})\) of the original image to locate the position of the minimum diameter of the droplet neck. In conclusion, for position identification of the minimum diameter of the neck, the key point is to divide the two edges of the neck and find the minimum distance of the pixels on the two edges. Above all, the position identification of the minimum diameter of the neck during the period with an undetached droplet can be summarized as follows:  
1. ROI selection near the neck;
2. Edge recognition;
3. Sealing the area of the neck;
4. Filling the area of the neck;
5. Neck recognition;
6. Image inversion;
7. Identification of the left and right background;
8. Separation of edges of the neck;  
Figure 16: The process of edge extraction of the droplet neck: (**a**) finding the largest connected domain; (**b**) image inversion; (**c**) edge detection of the left background; (**d**) edge detection of the right background.