## 2 Materials and Methods
### Application of Image Processing for Field Test
#### 2.3.1 UV Count Extraction  
The UV count could be noted manually by the operator, but this required a lot of time and effort. The potential for human error was also very high, especially related to its accuracy. The UV count in this research stage was extracted automatically by converting the image data into text data. The initial images (frames from video) had to be pre-processed  
Figure 1: The recording technique: (**a**) initial position for suspension string; (**b**) final position for suspension string; (**c**) initial position for tension string; (**d**) final position for tension string.  
before they were scanned using OCR [16]. The pre-processing included image cropping, image segmentation, morphological aperture, and image inversion.  
The initial image was cropped in the UV count display area at the pixel coordinates (520, 78) to (526, 178) where (0, 0) was the top leftmost pixel. This cropped area was applied to all zoom values. To implement the segmentation process, the image was first converted into a single channel 16-bit image (greyscale image) by using (1) [17].  
\[\text{I(m,n)}=0.229\ \text{R(m,n)}+0.587\ \text{G(m,n)}+0.114\ \text{B(m,n)} \tag{1}\]  
The grayscale image was then smoothed using Gaussian blur to reduce noise before thresholding. The Gaussian blur is a spatial filter in image processing that convolutes the input image with a Gaussian kernel, as written in (2) [14].  
\[\text{Gaussian Kernel}=\frac{1}{4.8976}\begin{bmatrix}0.3679&0.6065&0.3679\\ 0.6065&1&0.6065\\ 0.3679&0.6065&0.3679\end{bmatrix} \tag{2}\]  
The image segmentation process was the conversion of a 16-bit 3-channel image into a one-channel binary image. The smoothed image was segmented using the thresholding process. In this process, a thresholding value of 255 was used as the upper limit and 165 as the lower limit as given in (3) [14]. The process was run using the function of \(\text{cv2.threshold(img, 165, 255, cv2.THRESH_BINARY) [18].  
\[I(m,n)=\left\{\begin{aligned} & 1,\ \text{for}\ 165\ \leq\ \text{I(m,n)}\ \leq\ 255\\ & 0,\ \text{others}\end{aligned}\right. \tag{3}\]  
The morphological opening process was to remove noise in the binary image. It consisted of a dilation process followed by an erosion process. Both processes were morphological transformations that convoluted the input image with a structuring element in the form of a kernel by using (4)-(7) [14], with A as the set of foreground pixels, B as the structuring element, and z as the foreground pixel value. The kernel was a 3 \(\times\) 3 cross-shaped kernel. The opening process utilized the function of cv2.morphologyEx(img, cv.MORPH_OPEN, kernel) [19].  
\[\text{A}\ \circ\ \text{B}\ =\ \text{(A}\ \ominus\ \text{B)}\ \oplus\ \text{B} \tag{4}\]  
\[\text{A}\ \ominus\ \text{B}=\{\text{z}|\text{(B)}_{\text{z}}\ \subseteq\ \text{A}\} \tag{5}\]  
\[\text{A}\ \oplus\ \text{B}=\{\text{z}|\text{(B)}_{\text{z}}\ \subseteq\ \text{A}\ \
eq\ \varnothing\} \tag{6}\]  
\[\text{B}=\begin{bmatrix}0&1&0\\ 1&1&1\\ 0&1&0\end{bmatrix} \tag{7}\]  
The image inversion was the conversion from white to black, and vice versa. The image was inverted to match the input format accepted by the OCR. The image inversion could be written as in (8).  
\[I(m,n)=\left\{\begin{aligned} & 1,\ \text{I(m,n)}=0\\ & 0,\ \text{I(m,n)}=1\end{aligned}\right. \tag{8}\]  
The OCR was applied to images that had been pre-processed. Tesseract OCR was employed as an OCR engine and PyTesseract was chosen as a wrapper to run Tesseract OCR. Tesseract OCR was configured according to the desired input and output image forms [16].