May 2020
Beginner to intermediate
430 pages
10h 39m
English
The Sobel operator detects edges by calculating the gradient (Sobelx and Sobely in the following code) of the image intensity function. The gradient is calculated by applying a kernel to the image. In the following code, the kernel size (ksize) is 5. After this, the Sobel gradient (SobelG) is calculated by taking the ratio of the gradients (sobely/sobelx):
Sobelx=cv2.Sobel(gray,cv2.CV_64F,1,0,ksize=5)Sobely=cv2.Sobel(gray,cv2.CV_64F,0,1,ksize=5)mag,direction = cv2.cartToPolar(sobelx,sobely,angleInDegrees =True)sobelG = np.hypot(sobelx,sobely)