## 2 Materials and Methods
### Application of Image Processing for Field Test
#### 2.3.2 UV Pixel Calculation  
The initial image had to be cropped according to the selected zoom values. The cropping area was a white measurement window provided by the camera screen. The image was cropped at the coordinates (167, 212) to (407, 554) for the video with 1\(\times\) zoom and at the coordinates (227, 298) to (347, 469) for the video with 0.5\(\times\) zoom. The conversion from RGB color to HSV color (hue, saturation, value), as stated in (9)-(12), was to facilitate the next thresholding stage. The value was stored in 16-bit, so the HSV value became as in (13).  
\[\text{``}.\text{V }\leftarrow\text{``}\text{``}\text{``}\text{max''}\text{ (``}\text{R},\text{G},\text{B''}\text{ )} \tag{9}\]  
\[\text{S }\leftarrow\left\{\begin{array}{l}\frac{\text{V }-\text{min}(\text{R},\text{G},\text{B})}{\text{V}},\text{ if }\
eq 0\\ \\ 0\text{, others}\end{array}\right. \tag{10}\]  
\[\text{H}\leftarrow\left\{\begin{array}{l}\frac{60^{\circ}\text{ (G }-\text{B)}}{\text{V}-\text{min}(\text{R},\text{G},\text{B})},\text{ if V }=\text{R}\\ \\ 120^{\circ}+\frac{60^{\circ}\text{ (B }-\text{R)}}{\text{V}-\text{min}(\text{R},\text{G}, \text{B})},\text{ if V }=\text{G}\\ \\ 240^{\circ}+\frac{60^{\circ}\text{ (R }-\text{G)}}{\text{V}-\text{min}(\text{R},\text{G}, \text{B})},\text{ if V }=\text{B}\\ \\ 0^{\circ}\text{, if R }=\text{G}=\text{B}\end{array}\right. \tag{11}\]  
\[\text{I'}(\text{m},\text{n})=\left\{\begin{array}{l}1,\text{ I(m,n)}=0\\ 0,\text{ I(m,n)}=1\end{array}\right. \tag{12}\]  
\[\text{H }\leftarrow\text{ H}+360^{\circ},\text{ if H }<0^{\circ},\text{ with }0\leq\text{ V }\leq 1,\text{ }0\leq\text{ S }\leq 1 \tag{13}\]  
\[\text{V }\leftarrow\text{ }255\text{ V},\text{ S }\leftarrow\text{ }255\text{ S},\text{ H }\leftarrow\text{ H }/2 \tag{14}\]  
The image segmentation in this research stage was to segment the red pixels representing the UV emitted by the discharge phenomena of the insulator string. This process could not be carried out by selecting only one red color value (R = 255, G = 0, B = 0) because of the noise that caused a slight deviation in the RGB value. The noise might come from the rendering process or the compression by camera. The thresholding value was set in a range that was close to red color. In the HSV color, red had a hue value of 0\({}^{\circ}\) or 0 in the program representation. By taking a tolerance value of \(\pm 5^{\circ}\), the hue range was \(-5^{\circ}\leq\text{H(m,n)}\leq 5^{\circ}\) or \(175\leq\text{H(m,n)}\leq 180\cap 0\leq\text{H(m,n)}\leq 5\). The maximum value was 255 for the saturation and value range. With a tolerance value of 55, the ranges of saturation and value were \(200\leq\text{S(m,n)}\leq 255\) and \(200\leq\text{V(m,n)}\leq 255\). The thresholding process was as stated in (14).  
\[\text{I(m,n)}=\left\{\begin{array}{l}1,\text{ if }\left[175^{\circ} \right]^{\circ}\\ 200\\ \\ 0,\text{ others}\end{array}\right.\leq\left[\begin{array}{l}\text{H(m,n)}\\ \text{S(m,n)}\\ \\ 0,\text{ others}\end{array}\right]\leq\left[\begin{array}{l}5^{\circ}\\ 255\\ \\ 255\end{array}\right] \tag{15}\]  
The same threshold value was applied to every frame. The difference in threshold values allowed the different results of segmentation and UV emission area calculation for the same image.  
The sum of each red pixel in the segmented image gave the UV emission area. The result was then divided by the cropped image resolution according to the selected zoom value, so the calculation result was independent of the zoom level of the recorded video since the measurement window on the camera screen became smaller when the zoom value was increased. The final calculation result was the ratio between the UV pixel total and the cropped image resolution, as shown in (15). The final calculation result was then multiplied by 100 (%) to obtain the results in percentage units.  
\[\text{UV Emission Area}=\frac{1}{\text{M x N}}\sum_{\text{m =1}}^{\text{M}}\sum_{\text{n =1}}^{\text{N}}\text{I(m,n)} \tag{16}\] \[\text{with }0\leq\text{ UV Emission Area}\leq 1\]