opencv-04-Canny edge detection

Canny edge detection

    1. Use a Gaussian filter to smooth the image and filter out noise.
    1. Calculate the gradient intensity and direction of each pixel in the image.
    1. Non-Maximum Suppression is applied to eliminate the spurious response caused by edge detection.
    1. Double-Threshold detection is used to determine the true and potential edges.
    1. Finalize edge detection by suppressing isolated weak edges

1: Gaussian filter

2: gradient and direction

3: Non-maximum suppression

4: Double threshold detection

img=cv2.imread("lena.jpg",cv2.IMREAD_GRAYSCALE)

# minVal和maxVal
v1=cv2.Canny(img,80,150)
v2=cv2.Canny(img,50,100)

res = np.hstack((v1,v2))
cv_show(res,'res')

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

v1=cv2.Canny(img,120,250)
v2=cv2.Canny(img,50,100)

res = np.hstack((v1,v2))
cv_show(res,'res')

(80-150) and (50-100)

Published 225 original articles · Like 140 · Visit 250,000+

Guess you like

Origin blog.csdn.net/jankin6/article/details/105294041