import cv2 as cv def edge_demo(image): blurred = cv.GaussianBlur(image, (3, 3), 0) gray = cv.cvtColor(blurred, cv.COLOR_BGR2GRAY) xgrad = cv.Sobel(gray, cv.CV_16SC1, 1, 0) ygrad = cv.Sobel(gray, cv.CV_16SC1, 0, 1) edge_output = cv.Canny(xgrad,ygrad,50,150) ## 得出彩色边缘 cv.imshow("canny edge",edge_output) dst = cv.bitwise_and(image, image, mask=edge_output) ##灰度值与sobel边缘与 cv.imshow("Color Edge", dst) src = cv.imread("C:/Users/weiqiangwen/Desktop/sest/data/lena.jpg") # cv.namedWindow("input contours",cv.WINDOW_AUTOSIZE) cv.imshow("contours", src) edge_demo(src) cv.waitKey(0) cv.destroyAllWindows() print("--------- Python OpenCV Tutorial ---------")
十四天canny边缘检测
猜你喜欢
转载自blog.csdn.net/qq_32340685/article/details/83573007
今日推荐
周排行