# Damage Detection of Insulators in Catenary Based on Deep Learning and Zernike Moment Algorithms
## 3 Insulator Damage Detection Based on Zernike Moment
### Image Preprocessing  
In order to improve the accuracy of insulator damage detection and reduce the amount of calculation during detection, the image preprocessing protocol is designed in this paper, as shown in Figure 3, which mainly includes four steps: filtering, super-resolution, binarization, and contour extraction. The filtering step adopts a bilateral filter, which is a nonlinear filter [26]. Two Gaussian basis functions are used to describe the spatial proximity and grayscale similarity of the image, respectively, so that the proximity relationship between the central pixel and the surrounding pixel in geometric space and the difference between pixel gray values can be considered at the same time. Therefore, the bilateral filter can preserve the edge characteristics on the premise of smooth denoising. After insulator recognition and positioning, the cutout image is usually blurry due to its low resolution, which is not conducive to further judging about whether they are damaged. Therefore, it is necessary to improve the clarity of small image. In this paper, the RAISR (Rapid and Accurate Image Super-Resolution) algorithm is adopted. Figure 4 shows the process of the RAISR algorithm. The core idea behind RAISR is to enhance the quality of the bilinear interpolation method by applying a set of pre-learned filters on the image patches, which is chosen by an efficient hashing mechanism. The filters are learned based on pairs of low-resolution and high-resolution training image patches, and the hashing is done by estimating the local gradients' statistics. Finally, in order to avoid artifacts, the initial upscaled image and its filtered version are locally blended by applying a weighted average, where the weights are a function of a structure descriptor [27; 28]. Figure 3: The process of image preprocessing. In order to further extract the contour of the insulator, it is necessary to binarize the insulator image after filtering and super-resolution processing. Equation (2) describes the main principle of image binarization. When the gray value of the image pixel is less than the threshold \(T\), it is set to 0, and when it is greater than or equal to the threshold \(T\), it is set to 255. \[g(x,y)=\left\{ \begin{array}{ll}255,f(x,y)\geq T\\ 0\quad,f(x,y)<T\end{array} \right. \tag{2}\]  
Due to the difference in the pixel gray value of each insulator image, it is difficult to determine the threshold \(T\) during image binarization. Therefore, it is considered to use the method of dynamically adjusting the threshold \(T\) to complete the binarization of each image. As shown in Figure 5, firstly, the initial value \(T_{0}\) is set to 70, and the number of insulator pieces \(k_{0}\) should be 11. Secondly, the image binarization and the extraction of the contours of the insulator pieces are carried out respectively, and then the number \(k\) of contours is recorded as the number of insulator pieces. In order to avoid inaccurate recording of the number \(k\) of contours due to the influence of strong light on the connecting parts between insulator pieces, the contour with height less than a certain range is ignored when it is extracted. Finally, a judgment is made whether the number \(k\) of insulator pieces extracted is equal to the set value \(k_{0}\); if not, 1 is added to the threshold \(T\), and then binarization and contour extraction until the number of insulator pieces is equal to \(k_{0}\); if the condition of \(k=k_{0}\) is not met when the threshold \(T\) is increased to 255, \(k_{0}\) is reduced by 1, \(T\) is restored to the initial value of 70, and then binarization and contour extraction are performed until the requirements are met. According to the binarized image, all the contours of the insulator image can be extracted by saving the outer arc contour of the insulator piece and connecting the head and tail of the arc with a straight line [15]. Figure 6 shows the original image, binarized image, the whole contour image, and the contour extraction image of the insulator pieces.