Image processing: Canny edge detection

# Canny edge detection

Canny edge detection process :

1. Use Gaussian filtering to smooth the image and filter out noise (normalization processing)

2. Calculate the gradient strength and direction of each pixel in the image (Sobel operator calculates Gx, Gy)

3. Apply non-maximum suppression (NMS) to eliminate spurious effects caused by edge detection

4. Apply dual threshold detection to identify real and potential edges

5. Finalize edge detection by suppressing isolated edges

The larger the last parameter, the more "detailed" the edge detection

v1 = cv2.Canny(img_,50,100)
v2 = cv2.Canny(img_,50,50)

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

plt.imshow(res)


#LOG算子
gaussian = cv2.GaussianBlur(img_, (3,3), 0) #先通过高斯滤波降噪
dst = cv2.Laplacian(gaussian, cv2.CV_16S, ksize = 3) #再通过拉普拉斯算子做边缘检测
LOG = cv2.convertScaleAbs(dst)

cv_show(LOG,'LOG')
plt.imshow(LOG)

Guess you like

Origin blog.csdn.net/Crabfishhhhh/article/details/127694015