1) Gaussian filter smoothing the image. Canny operator uses Gaussian filter to reduce the impact of noise, through the convolution processing with the image, filter out the noise in the image, and smooth the image. 2) Calculate the gradient amplitude and direction of the image. When the Canny operator obtains the gradient image, the 2×2 template is used to calculate the gradient amplitude and gradient direction of the gray image. The gradient value in both horizontal and vertical directions is: