Canny边缘检测
步骤 :噪声去除,计算图像梯度,非极大值抑制, 滞后阈值
cv2.Canny()可以完成以上几步。
![](https://img2018.cnblogs.com/i-beta/1766866/202002/1766866-20200207122734773-51570057.png)
import cv2 import numpy as np from matplotlib import pyplot as plt img = cv2.imread('messi5.jpg',0) edges = cv2.Canny(img,100,200) plt.subplot(121),plt.imshow(img,cmap = 'gray') plt.title('Original Image'), plt.xticks([]), plt.yticks([]) plt.subplot(122),plt.imshow(edges,cmap = 'gray') plt.title('Edge Image'), plt.xticks([]), plt.yticks([]) plt.show()