The edge of an image is generally the transition area between the target and the environment, which is an area that needs special attention in image measurement and shape matching. The accuracy of edge positioning directly affects the output results. Image edge detection is judged by the first and second derivative of image pixel points. Because the gray value of the edge zone of the image and adjacent pixels changes violently and the gradient amplitude is large, the magnitude of the first derivative of the gray value can judge whether the image has edges, and the zero point of the same second derivative is the position of the edge.
Commonly used first-order derivative operators include Sobel, Roberts, Prewitt, etc. The second-order operator has Laplacian. The Canny operator used in this paper uses the first order partial derivative finite difference to calculate the gradient amplitude and direction. It first uses the Gaussian smoothing filter to smooth the picture to remove noise. It is a multi-stage optimization operator with filtering, enhancement and detection.

In practical processing, the Canny operator can more accurately locate the optimal edge than Sobel and Roberts, which are sensitive to grayscale gradient and noise. Use the Canny operator to extract sub pixel precision contours from the end face image of the helical gear, and the extraction results are shown in the figure.