A new recognition algorithm for high-voltage lines based on improved LSD and convolutional neural networks

With the development of high-voltage transmission and artiﬁcial intelligence technology, unmanned line inspection has become the inevitable trend of current electric power inspection. A new recognition algorithm for high-voltage lines is proposed based on colour (Red, Green, Blue) RGB image to support the unmanned line inspection. Firstly, in order to solve the problem of missing weak edges in image edge detection, an improved Canny algorithm is proposed. Fourier transform Gaussian ﬁlter is introduced to enhance the high-frequency signal of the image, which makes the extracted edge information more complete. At the same time, an improved line segment detector (LSD) algorithm is developed to extract the high-voltage line. The complementary edge information of the three channels of the colour RGB image is analyzed, and the calculation formula of the horizontal line angle is improved, which greatly reduces the possibility of false detection and missed detection in the high-voltage line extraction. In addition, the convolution neural network (CNN) is used to accurately recognize the extracted high-voltage lines, which reduces the interference of non–high-voltage lines. Simulation results show that the proposed algorithm has high


INTRODUCTION
With the rapid development of economy, the demand for electricity is increasing continuously, and the stability of power system is closely related to the economic stability of the country. As the key equipment for high-voltage transmission, the length of high-voltage lines is as high as tens of kilometres, or even thousands of kilometres. High-voltage lines are usually used in the outdoor environment, which is far away from urban areas and roads, and thus the environment is very complex and harsh. High-voltage lines are not only damaged by the natural environment for a long time, but also have to bear their own weight. The internal voltage and current of the line are constantly changing. All these conditions can lead to line damage and line failure. If there is a line failure, it may cause a regional power outage, which will lead to very serious losses to people and various industries, or even bring serious disasters to the normal operation of the power system [1][2][3]. Therefore, the recognition of high-voltage lines from the complex environment not only is conducive to the image are obtained by straight line extraction algorithms, and the target wires are selected from them according to the characteristics of the wires. The methods of straight line extraction mainly include three methods, Radon transform method, Hough transform [14] method, Freeman chain code method and line segment detector (LSD) algorithm. In [15], the preliminary line segments are obtained by combining image clustering into Radon transform, and then the wires are obtained according to the characteristics of transmission lines. In [16], edge pixels are sampled to reduce the voting count, and then a one-to-one voting strategy is applied to improve the extraction of continuous and accurate line segments using the information of the main direction. In [17], a heuristic search on binary images is proposed to extract straight lines by improving the search method and ending criterion. These algorithms reduce the problem of broken short lines to a great extent, but it is still easy to produce pseudo-lines in wire extraction. Compared with other line segment detection methods, the particularity of LSD algorithm [18][19][20][21] is to quickly detect the ability of line segments in the picture, and the error control method is used to deal with the detection results. The most important thing is that the algorithm can achieve sub-pixel accuracy in linear time. Recently, the convolution neural network (CNN) deep learning method has shown its powerful ability in the field of computer vision. CNN [22][23][24] can automatically extract powerful features for tasks such as classification. In [25], a classification network based on pixel level-SegNet is proposed, which can segment and detect lanes, trees, buildings, pedestrians and so on. Considering the complexity of the environment of highvoltage lines, the isolated use of traditional image feature detection methods has some limitations [26,27]. A new high-voltage line recognition algorithm is proposed, which introduces a deep neural network and improved Canny algorithm to enhance the recognition and classification ability. First of all, this algorithm uses improved Canny algorithm to pre-process and extract the high-voltage line, which reduces the burden of high-voltage line detection. Then, the CNN is used to classify the high-voltage lines to avoid the interference of pseudo-high-voltage lines. In brief, the main contributions of this paper are summarized as follows: (1) In order to make the detected edge information more complete, an improved Canny algorithm is proposed. Fourier transform Gaussian filter is introduced to enhance the highfrequency signal of the image, which can realize the image edge extraction more effectively.
(2) In order to reduce the false detection and missed detection in the high-voltage line extraction, an improved LSD algorithm is proposed, which combines the complementary information of the three channels of the colour image, and updates the calculation formula of the horizontal line angle, so that the algorithm can extract the high-voltage line more accurately.
(3) In order to reduce the interference of non-high-voltage lines, the CNN is introduced to train a large number of positive samples of high-voltage lines and negative samples of non-high-voltage lines. It not only effectively distinguishes high-voltage lines from non-high-voltage lines, but also greatly improves the accuracy of high-voltage line recognition. This paper is organized as follows. In the second section, the preliminary knowledge used is formulated. In the third section, a new recognition algorithm for high-voltage lines is described in detail. The effectiveness of the proposed algorithm is verified in the fourth section. The fifth section makes a concluding remark.

PRELIMINARY KNOWLEDGE
High-voltage transmission line is the key equipment in the power system, and its safe operation is related to the stability of the whole power grid. On the one hand, it always has damage accidents and equipment aging problems. On the other hand, most of the high-voltage lines are located in remote areas, and the environment is very complex and harsh. The damage of high-voltage lines caused by the natural environment for a long time will lead to the problem of line failures. It bring serious disasters to the normal operation of the power system. Therefore, it is necessary to carry out regular inspection of high-voltage lines. Considering the above problems, this paper proposes a new recognition algorithm for high-voltage lines. Next, we are ready to introduce the canny algorithm and LSD algorithm used in image preprocessing and high-voltage line extraction.

Basic canny algorithm
Canny algorithm is not easy to be disturbed by noise and can detect real weak edges. The following is a brief introduction of the canny algorithm. First of all, the Gaussian filter is used to reduce noise in the image. The noise in the image can be effectively removed by weighted averaging according to the grey values of the pixels and neighbourhood points of the image.
where, represents spatial scale factor. The value of is large, the filter has a better signal-to-noise ratio. The value of is small, the filter has more accurate positioning and the signal-tonoise ratio is lower. Therefore, the appropriate could achieve a good denoising effect according to the specific situation. After the partial derivative is obtained, the amplitude and direction of the gradient are calculated, respectively.
where, G (i, j ) is the amplitude, G x (i, j ) and G y (i, j ), respectively, indicate the partial derivative of the image along the x direction and the y direction. (i, j ) is direction of the gradient. Non-maximum suppression is performed on the smoothed image to obtain a single-edge image with accurate positioning. Then connect with the double threshold method.

LSD algorithm
LSD is a linear detection and segmentation algorithm. It accumulates a lot of advantages of traditional methods and discards their shortcomings. It can calculate subpixel-level precision detection results in linear time. The LSD algorithm is described in detail as follows. In order to reduce or even eliminate aliasing in many images, the Gaussian filter is used for the image, and down sampling is carried out. Then level-line angles and the gradient of the image are calculated.
where, is the angle of level-line. g x (x, y) and g y (x, y), respectively, represent the image gradient. G (x, y) is the gradient amplitude. Pseudo-sort all points and update the angle of the horizontal region.
where, ang j is the angle of the horizontal line. After traversing the pixels of the whole image, all the line support areas are found, and the Number of False Alarms (NFA) value of the line segment is calculated to verify the accuracy of the line segment detection.

Edge enhancement based on an improved canny algorithm
It can be seen from the principle of canny algorithm, the smooth noise of the image is realized by the Gaussian filter, the large difference of pixel grey values in the fixed area and the edges of some images are not clear. This leads to the loss of a large amount of image information. Therefore, an improved canny algorithm is proposed.
The basic principle of the algorithm is to pre-process the image, the Fourier transform Gaussian filter is used to enhance the high-frequency signal of the image. For a discrete signal such as an image, the frequency represents the severity of the signal change or the speed at which the signal changes. The high-frequency signal usually represents the edge signal or noise signal in the image. Therefore, the Fourier transform Gaussian filter is introduced to increase the high-frequency signal in the image to achieve the purpose of image enhancement. Next, the Gaussian function with Fourier transform is described and used in the improved canny algorithm.
The Gaussian two-dimensional function is simplified as: The two-dimensional Fourier transform can be expressed as: where, let = 2 , = 2 . Then, the two-dimensional Fourier transform can be simplified.
Fourier transform is introduced into Gaussian function.
After finishing calculations where, a = 16. end

end
Then F ( , ) is multiplied by a factor 1 2 2 .
It can be seen that the Gaussian function is still Gaussian after Fourier transform. The distribution in the frequency domain still obeys the Gaussian distribution, so the edge information of the image is obtained by adding high-frequency signals in the image. Based on the above Gaussian filter, the pseudo code for the improved canny algorithm is shown in Algorithm 1.

Extraction of high-voltage lines based on the improved LSD algorithm
In the LSD algorithm, the first step of the search is performed only on greyscale pixels. For a colour image, it needs to convert the intensity components of R, G and B into greyscale images by weighted fusion, which cause the complementary edge information to be smoothed [21]. The greyscale image would restrain the line segment detection of the RGB image, resulting in the increase of false detection and missed detection in the highvoltage line extraction.
In view of this situation, an improved LSD algorithm is proposed. Next the improvement process of the algorithm is described.
Due to the complementary characteristics of RGB colour images, the largest gradient amplitude in the four channels of R, G, B and greyscale is selected as the final gradient amplitude, and the horizontal line angle is modified.
where, ′ is the new angle of the horizontal line. y)), (14) g maxy (x, y) = max(g Ry (x, y), g Gy (x, y), g By (x, y), g y (x, y)), (15) where, g maxx (x, y), g maxy (x, y), respectively, represent the maximum vertical and horizontal gradient values of the pixel. i is pixels that traverse the entire image. The final gradient amplitude needs to be changed.
where, G ′ (x, y) indicates the new gradient amplitude.
The approximate rectangle is used to verify the line segment.
where G ( j ) is the gradient intensity of the pixel. The subscript j is to traverse all the pixels in the rectangular area.
In the improved LSD algorithm, the formation correlation of the four image channels is considered, the pixels are lost because the small gradient amplitude in a single image can be detected, and the line pixels with consistent horizontal line angles in one channel but do not meet the conditions in other channels would be abandoned. Therefore, the improved LSD algorithm can reduce the cases of false detection and missed detection, and accelerate the post-processing of high-voltage line detection.
In order to explain the LSD algorithm more clearly, the pseudo code of the algorithm is shown in Algorithm 2. for(j = i + 1; j ≠ ntl→ size; ++j )

Recognition of high-voltage lines
Although the effect of the high-voltage line detection algorithm mentioned above is good, there are some limitations, such as objects with similar line segments in the surrounding environment. Therefore, deep learning is used to combine the highvoltage line extraction algorithm, and design a line segment classifier based on RGB image for accurate recognition of highvoltage lines. Convolutional neural networks generally consist of a convolutional layer, a maximum pooling layer and a fully connected layer. The composition diagram of the convolutional neural network is shown in Figure 1.
The construction of the CNN designed is shown in Figure 2. In Figure 2, c1 and c2 are convolutional layers, and P1 and P2 are maximum pooling layers. f3, f4, f5 are fully connected layers. The input layer of the network is an RGB colour image of 480 * 872. Among them, CNN uses stochastic gradient descent algorithm for training. Dropout technology is used in f3 and f4 to prevent overfitting of the network. The output layer normalizes the result vector of f5 by softmax so that the two-dimensional vector is mapped to the probability space.
In the CNN proposed, the samples are input into the network and the output variables are calculated. Based on the fact that the weights of the network are updated many times in the process of transmission, the step-by-step transmission from the input layer to the output layer is realized.
where, F N is the activation function, and w n represents the weight value. The output variable is obtained through the forward propagation of CNN, then adjust the network parameters by back propagation.
where, the probability of real value is p(x), and the probability of predicted value is q(x). The output of each unit in the middle layer is shown as follows.   where, V i j represents the weight of the input layer data i to the hidden layer output data j . x is the unit data of input layer j . j is the threshold of the hidden layer unit. f (x) is the activation function. In order to obtain higher classification performance of highvoltage lines, data needs to be used to train the convolutional neural network. The data set of the high-voltage line is made by the video from the UAV during the power inspection. One thousand three hundred fifty pictures are extracted from the video by frame for the production of the data. Its positive and negative samples ratio is 1: 3. The composition of the data is shown in Table 1.
In Figure 3, Figures 3(a) and 3(b) are positive samples. It can be seen that the UAV should recognize the high-voltage lines and remove foreign objects during the inspection. Figures 3(c) and 3(d) are negative samples. From the picture, we can see that the background environment of the high-voltage line is complicated, and it is difficult to distinguish the high-voltage line.
CNN is trained using stochastic gradient descent algorithm. Batch-size is 200, and learning rate is 0.01. The truncated Gaussian distribution is used to initialize network parameters. After training, the recognition accuracy of video 1 is about 96.26%, and the recognition accuracy of video 2 is about 95.75%.

Post-processing
The high-voltage lines detected above are different short lines.
In order to get a complete high-voltage line, the extracted high-voltage lines need to be processed. Generally speaking, an object is unique in its colour distribution. Because the high-voltage lines are bare wires or covered by the same insulating material, they should have uniform brightness and colour compared to the background in the image. For a power inspection image taken by a UAV, the pixels on the same high-voltage line should have the same colour characteristics. Therefore, the high-voltage line area can be divided into colour or monochrome models to facilitate the connection of a complete high-voltage line. Colour or monochrome characteristics are clearer in the HSV colour space than in the colour space. The value of H is affected by S and V . V < 0.25, the colour is classified as black. S < 0.2 or V > 0.75, the colour is classified as white. The remaining colours are divided into colour models. The intensity R, G , B of a pixel, and V , S can be calculated.
where V represents the value that distinguishes tones from black. S represents saturation, and is often used to distinguish between chromaticity and colourless. The extracted high-voltage line segments is connected into a quadrangular area R = -x i˝= -H i , S i , V i˝. The potential area of the high-voltage line is shown in Figure 4.
In Figure 4, L i1 and L i2 are different high-voltage line segments. R is the potential region of high-voltage power lines.
For the HSV colour model in each region, V R and S R of each region can be defined. where, V R is the regional variable. S R is the saturation variable.
If V R or S R of an area is small enough, that is, V R < 0.25, S R < 0.2, the corresponding potential areas of highvoltage lines can be thought of as monochromatic features. On the contrary, the potential high-voltage line area is regarded as a colour feature. After marking all the potential high-voltage line areas, Hough transform is used to connect the line pixels of the same colour model into the same high-voltage line.

SIMULATION STUDY
A new recognition algorithm for high-voltage lines based on improved LSD and convolutional neural networks is proposed. In order to verify the effectiveness of the algorithm proposed, the video captured by a power grid in Northeast China is selected as the data source, and the pictures extracted by frame from the video are used to make data sets. Part of the sample data is shown in Figure 5.

Simulation results of edge detection
Through the comparison of different methods, it is proved that the improved canny algorithm can better detect the weakened edge information. Sobel operator, Prewitt operator, Canny algorithm and improved Canny algorithm are verified and compared in the environment of MATLAB 2019b. The high-voltage line edge enhancement process is shown in Figure 6. The comparison of different algorithms is shown in Figure 7. In Figure 6, Figure 6(b) indicates that the original image is processed by gradient magnitude. Figure 6(c) denotes the nonmaximum suppression of the original image. Figure 6(d) means to add a high-frequency signal to the canny algorithm.
As can be seen from the results in Figure 7, compared with Sobel operator, Prewitt operator, canny algorithm, the detection effect of improved canny algorithm has good practicability. The detected edge information is not completed in Figures 7(a) Figure 7(c). Therefore, we can draw a conclusion that the improved Canny algorithm has a good effect on image weak edge extraction.

The simulation results of extracting high-voltage lines
Through the comparison of different methods, it is verified that the improved LSD algorithm can better identify high-voltage lines. The image of the high-voltage line is shown in Figure 8. The comparison of different algorithms is shown in Figure 9.
In Figure 8, (a) shows the image of the selected high-voltage line, and there are many interferers in the image that lead to great difficulties in the extraction of high-voltage lines. Figure 8(b) is an image after pre-processing, and the image quality and resolution have been improved after image pre-processing. As can be seen from the results in Figure 9, Figures 9(a) and 9(b) produce many pseudo-lines, which seriously affect the extraction of high-voltage lines. The high-voltage line is the only target in the Figure 9(c) diagram, but there are many interferers and obvious fences in the background, which are the main sources of interference. In the Figure 9(d) diagram, there is little difference between the greyscale image of high-voltage line pixels and the background greyscale image, which leads to great difficulties in the extraction of high-voltage lines.
In the detection of high-voltage lines, LSD algorithm has achieved good results, but there are similar objects in the surrounding environment, which leads to false detection. And, some of the high-voltage lines pass through the tree, and the grey values of the two are similar, resulting in missed detection. In the improved LSD algorithm, good results are obtained by changing the formula of horizontal line angle. The false detection of the lines in the surrounding environment is reduced, and some of the high-voltage lines around the trees are successfully extracted. Simulation results show that the improved LSD algorithm is more effective for the detection of high-voltage lines.

The simulation results of CNN
In order to verify the accuracy of recognizing high-voltage lines through CNN, this paper selects two videos of UAV in the process of power inspection to make the data set of high-voltage lines. Through the comparison of data, it is found that using CNN to recognize high-voltage lines has a higher accuracy. The performance analysis of different algorithms are shown in Tables 2, 3 and 4, and the final recognition effect of high-voltage line is shown in Figure 10. Different methods are used as comparison algorithms to better verify the effectiveness of the algorithm proposed. Through the analysis of the data in Tables 2, 3 and 4, we can easily find that video 1 and video 2 have different degrees of improvement in recognition accuracy. It can be concluded that the CNN proposed is more effective in recognizing high-voltage lines.
In Figure 10, the red lines represent the finally identified highvoltage lines.
From Tables 2, 3, and 4 and Figure 10, we can infer from the above result that the CNN proposed has higher accuracy in the recognition of high-voltage lines.

FIGURE 10
The final recognition effect of high-voltage line

CONCLUSION
A new online recognition algorithm for high-voltage lines is proposed. In the aspect of edge enhancement, the edge information of the extracted high-voltage line is more complete by the improved canny algorithm. In the aspect of image extraction, an improved LSD algorithm is proposed to reduce the interference of high-voltage lines caused by complex background. Finally, the high-voltage line is accurately identified by CNN. Simulation results show that the algorithm proposed has strong robustness and high detection accuracy.