OpenCV4 edge detection

Detection process

1. Gaussian filtering: filter out noise to smooth the image
2. Calculate the gradient intensity and direction of each pixel in the image
3. Non-maximum suppression: retain the gradient with the highest recognition degree
4. Double threshold: filter again. Keep only the most authentic. (Upper threshold and lower threshold)
5. Suppress isolated weak edges

The Canny function already contains the above five steps

img = cv2.imread("123.png",cv2.IMREAD_GRAYSCALE)

v1 = cv2.Canny(img,80,150)  
v2 = cv2.Canny(img,50,100)  
v3 = cv2.Canny(img,60,70)  

cv2.imshow("v0",img)
cv2.imshow("v1",v1)
cv2.imshow("v2",v2)
cv2.imshow("v3",v3)

Insert picture description here

Guess you like

Origin blog.csdn.net/helloworld573/article/details/105284064