# Follow-Up Control and Image Recognition of Neck Level for Standard Metal Gauge
## 5 Extraction and Reconstruction of the Concave Meniscus  
The influence of gravity and surface tension causes the liquid in the tube to form a concave meniscus, which can be identified in the images from the sudden change in pixel values. After applying an adaptive graying method, Sobel edge detection was used to extract the liquid level, as shown in Figure 13. This adaptive approach, demonstrated in Figure 13c, can effectively improve the accuracy of liquid level detection beyond conventional techniques (see Figure 13d). The resulting image after edge detection and removal of smaller connected domains is shown in Figure 13e). \begin{table}
\begin{tabular}{l c c c c c c c c c} \hline \hline Scale Reading (\(n\)) & 21 & 20 & 19 & 18 & 17 & 16 & 15 & 14 & 13 \\ \hline Pixel Coordinate (\(l\)) & 59 & 157 & 255 & 353 & 451 & 549 & 647 & 745 & 843 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: A relationship table between the scale indicator and pixel values. Figure 11: Recognition results for the 1 cm calibration line (right rotation 90 degrees). Figure 12: Recognition results for digital and scale line. Figure 13: Recognition results for the adaptive gray method applied to the liquid tube, including (**a**) the original image, (**b**) the adaptive gray image, (**c**) edge detection results for the adaptive grayscale image, (**d**) results for the traditional grayscale image, and (**e**) the removal of smaller connected domains. Although the tube edges are clear, the meniscus boundaries are obscured by factors such as lighting and latent fluid on the tube walls. As such, a fitting reconstruction was performed to determine precise liquid level coordinates. The liquid level curve equation is fixed by the constraint that hardware and environmental conditions in the verification system remain constant. An image was acquired in standard test conditions and a leveling curve was produced by data fitting. Inaccurate data in the conventional test process were then calibrated using the known standard level curve, as shown in Figure 14.  
The liquid level was collected and extracted multiple times at a temperature of 25 \({}^{\circ}\)C, a relative humidity of 50%, an atmospheric pressure of 101 kPa, and sufficient lighting, according to volume verification regulations [25]. The best image was selected after processing and used for fitting, as shown in Figure 15e. The lower edge of the extracted region provided the 'C' line for meniscus measurements and the data were fitted to the level curve using a least squares algorithm. This process can be described as follows. For a given set of data \(\{(x_{i},y_{i}),i=0,1,2\ldots m\}\), the interpolating function \(f(x)\) is defined as the sum of the squared errors for the fitted model and the original data:  
\[S(a_{0},a_{1},a_{2}\ldots a_{n})=\sum_{i=0}^{m}[f(x)-y_{i}]^{2} \tag{10}\]  
The optimal approximation to the original data, the least squares fitting curve \(f(x)\), is then found by minimizing the sum of squared errors [26]. Polynomial fitting involves the use of a model function defined as \(f(x)=a_{0}+a_{1}x+\ldots a_{n}x^{n}\). Input coordinates were collected from the lower edge of the standard concave meniscus image and used to calculate the quadratic function:  
\[f(x)=-0.003367(x+a)^{2}+0.4137(x+a)+b \tag{11}\]  
The resulting fitting curve for the concave meniscus, in which \(a=0\) and \(b=625.6\), is shown in Figure 16. The results of using this function to reconstruct a liquid level line are shown in Figure 17. The white curve in Figure 17b represents the measured level and the red curve defines the reconstructed  
Figure 14: A block diagram for the curve fitting and reconstruction algorithms applied to modeling the concave meniscus. Figure 11:0 The extraction of standard concave liquid level images, including (**a**) the adaptive gray image, (**b**) the edge detection image, (**c**) the outline image, (**d**) the maximum outline, and (**e**) the smoothness processing image. meniscus surface.