Applying morphology to improve Canny operator's image segmentation method

When a single image segmentation method is used for image segmentation of wind turbine blade images under a complex background, the results obtained are not accurate and complete. This article proposes an image segmentation algorithm that applies morphology to Canny edge detection. It uses morphological opening to erode and dilate the binary image after Canny algorithm processing, and removes redundant edge information to obtain a complete fan blade image. Experimental results show that the results obtained by the image segmentation method proposed here have good integrity and accuracy, and can improve the segmentation effect of the image.


Introduction
Today, the development of artificial intelligence and machine vision technology has brought new research ideas to many professional fields. The wind turbine blades act as the main components of directly contacting with the natural wind. The degree of its integrity is directly related to the operating efficiency of the fan, so it is very meaningful to troubleshoot the fan blades. In wind turbine blade fault diagnosis, most of the traditional diagnostic techniques are vibration signal detection and are subject to environmental conditions. Therefore, in the fault diagnosis of wind turbine blades, machine vision technology is used to diagnose faults of wind turbine blades. The image of the fan blades collected by the drone is processed and analysed. In the process, the image of the fan blade is first segmented to remove the background of the blade.
As the basis for image analysis and understanding, the image segmentation effect is directly related to the final result of fan blade fault diagnosis, and is the basis for feature extraction and recognition of fan blade images. At present, many researchers have improved the image segmentation algorithm to adapt to the needs of image segmentation in different backgrounds. For example, Hu et al. [1] used the segmentation values of two one-dimensional Otsu methods to replace the segmentation values of the traditional two-dimensional Otsu method, reduced the computational complexity, introduced the concept of minimum dispersion within the class, and used genetic algorithms to automatically optimise parameters to improve the segmentation effect; Xuet al. [2] improved the sensitivity of traditional Canny algorithm in calculating gradients by improving the filtering method. Otsu algorithm was introduced to adaptively generate high and low thresholds according to image grey levels. Based on twodimensional Otsu, Yuan and Cheng [3] proposed a fast Otsu segmentation algorithm based on two-histogram bislope partitioning. These methods improve image segmentation efficiency, but they are not suitable for image segmentation of fan blade images under the complex background [4].
Here, image segmentation method based on morphological improved Canny operator is used to perform image segmentation processing for wind turbine blades under the complex background [5]. Compared with the single image segmentation method, the binary image after Canny operator edge detection is morphologically processed to remove the redundant edge information, and the complete image segmentation result can be obtained [6].

Image outline extraction algorithm
Image contour extraction algorithm, also known as image edge detection algorithm, is a common algorithm for image segmentation [7]. As the edge is the most intense place in the image, the traditional edge detection is to use the feature to differentiate the pixels of the image or find the second-order differential to determine the edge pixels. The peak of the first-order differential image corresponds to the edge point of the image; the zero-crossing of the second-order differential image corresponds to the edge of the image [8]. According to the characteristics of the digital image, the difference operation replaces the derivative operation and performs a simple first derivative operation on the image. Fig. 1 shows (a) and (b) as fan blade images under two different backgrounds. Fig. 2 shows the result of processing Fig. 1 using the classic Sobel algorithm.
From the results of Fig. 2, we can see that when a single Sobel operator performs fan blade image segmentation, a complete segmentation result can be obtained for a fan blade image under a simple background, but when it segments a image under the background complex shown in the original image (b). The accuracy of the edge positioning is low, and it is easy to misjudge the noise as an edge boundary. In this case, a single segmentation algorithm cannot get the complete leaf area.

Threshold-based image segmentation method
The Otsu algorithm is an adaptive threshold segmentation method. The algorithm obtains an optimal threshold by processing the grayscale image, and finally uses the threshold to binarise the grayscale image. It can be seen in the image histogram that the optimal threshold selected in the image segmentation of the Otsu algorithm is roughly the value of the trough between the two peaks of the histogram [9]. For the background image of fan blades under the complex background, the optimal threshold is 0, as shown in Fig. 3. Therefore, Otsu's segmentation method is not suitable for wind turbine blade image segmentation. The Otsu algorithm's segmentation results are shown in Fig. 4

Canny edge detection algorithm
The Canny edge detection method is a common and very practical image processing method that first smooths the image, then takes the derivative [10]. The edge detection algorithm is divided into five steps: Gaussian filtering, grayscale conversion, gradient calculation, non-maximum signal suppression, and high-and lowthreshold output binary images. Compared with other edge detection operators, the Canny operator has good edge detection performance. It can be less susceptible to noise interference and detect weak edges, then obtain an ideal binary edge image [11].

Grayscale RGB images:
Generally, the images captured by the camera are all colour images, and the images processed by the camera need to be grayscale images [12]. Therefore, when the Canny algorithm is used, the image is first subjected to grayscale processing. Take the colour picture in RGB format as an example, the greying method is usually used as follows: grey = (R + G + B)/3.

Gaussian filtering of the image:
The realisation of Gaussian filtering can be achieved by using two one-dimensional Gaussian kernels with two weightings, and it can also be achieved by one-dimensional convolution of a two-dimensional Gaussian kernel [13].
The Gaussian kernel implementation formula is: The above formula is a discretised one-dimensional Gaussian function, and the one-dimensional kernel vector can be obtained by determining the parameters in the function.
The above formula is a discretised two-dimensional Gaussian function. The two-dimensional kernel vector can be obtained by determining the parameters in the function. Under normal circumstances, edge detection and filtering of images are conflicting. Reducing image noise will blur the edges of the image and increase the difficulty of image edge positioning. On the contrary, improving the sensitivity of edge detection will also increase the noise sensitivity, making it more difficult to extract edges. However, the Gaussian kernel determined by the Gaussian function can find a way to effectively filter the noise in the image

Calculate the magnitude and direction of the gradient:
The first-order finite-difference approximation is used to find the gradient of the image grey value, and two matrices of partial derivatives of the image in the x and y directions are obtained. Common operators based on gradients including Roberts operator, Sobel operator, Prewitt operator etc. are simple, but they have disadvantages such as high inaccuracy of edge location, poor filtering performance, and low accuracy. Normally, the edges detected by these methods are discontinuous and irregular. Based on the above research, the Canny algorithm is used to detect the edge of the fan blade image [14].
The convolution operator expression used in the Canny algorithm implemented here is: The mathematical expression of its gradient magnitude and gradient direction is: Canny algorithm processing results are shown in Fig. 5.

Morphological analysis
Morphological analysis can keep the edge contour of the image unchanged, while it suppresses the image noise. This feature is of great significance for removing the noise from the wind field under a complex environment and extracting the target blade parts. Morphological operations include erosion, dilation, and opening and closing. The morphological calculation process from a mathematical perspective is: It assumes that the two-dimensional Euclidean space is represented by Ω. B is a mathematical structural element that operates with A, where A and B are both subsets of Ω. Here, in order to improve the ability of the algorithm to avoid noise interference and obtain better image contours, it combines morphological operations (corrosion and expansion) with Canny operator edge extraction to improve the final extraction.

Canny algorithm combined with morphological analysis
The process of image segmentation that bases on combining Canny operator and morphological opening operation for image of wind turbine blade under the complex background is shown in Fig. 6.
Here, the image of the fan blade image under the complex background is processed to get the grey image. Gaussian filter is used to process grayscale image to remove noise. The first-order partial derivative is used to calculate the magnitude and direction of the gradient, then non-maximal suppression of amplitude is obtained. Finally, the image is subjected to detection of a doublethreshold algorithm and connects edges, which obtains edge information in the image. However, the detection result contains the edge information of the background. It is necessary to morphologically erode the resulting binary image reducing the highlights in the image, and to morphologically dilate the resulting binary image increasing the highlights in the image. Finally, it removes the complex background of the image and gets a complete segmented image.
The segmentation result of combining Canny operator combined with morphology is shown in Fig. 7.
Comparing the results of image segmentation using different methods, the combination of morphological opening operation and Canny edge detection algorithm can effectively remove noise interference in image segmentation under the complex background and improve the accuracy of image contour extraction. Here, by comparing and analysing the results of wind turbine blade image segmentation between Sobel operator, Canny operator and Otsu operator, it is concluded that the image segmentation result of a single image segmentation method does not have integrity under the complex background. A method combining morphological opening operation and Canny algorithm is proposed to perform image segmentation on fan blade images to remove the noise in the image and finally obtain a complete segmentation result. Experimental results show that compared with a single detection algorithm, this algorithm improves the edge detection effect, and has important significance for the next wind turbine blade feature extraction and recognition.