dst = cv2.Canny(image, threshold1, threshold2)
参数:
import cv2 as cv
import matplotlib.pyplot as plt
import numpy as np
src = cv.imread("E:\\qi.png", 0) # 直接以灰度图方式读入
img = src.copy()
# Canny边缘检测
threshold1 = 0
threshold2 = 160
img_Canny = cv.Canny(img, threshold1, threshold2)
# 显示图像
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(10, 8), dpi=100)
axes[0].imshow(img, cmap=plt.cm.gray)
axes[0].set_title("原图")
axes[1].imshow(img_Canny, cmap=plt.cm.gray)
axes[1].set_title("Canny检测后结果")
plt.show()