Edge detection OpenCV--

Canny edge detection

Using a Gaussian filter to smooth the image, filtering noise

Calculating image gradient magnitude and direction of each pixel

Application of a non-maximum value (Non-Maximum Suppression) inhibition, to eliminate the spurious response caused by the edge detection

Application of double threshold (Double-Threshold) detection to determine the real and potential edge

 Dual-threshold detection

Isolated by suppressing weak edges finalized edge detection

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

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

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

effect:

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')

效果:

Guess you like

Origin www.cnblogs.com/SCCQ/p/12291488.html