原图 索贝尔 拉普拉斯和canny 登录后复制 # -*- coding: utf-8 -*- import sysimport cv2 import numpy as np# 加载图片 # 转换灰度图 input_file = sys.argv[1] img = cv2.imread(input_file, cv2.IMREAD_GRAYSCALE) h, w = img.shape# 索贝尔边缘检测-水平 sobel_horizontal = cv2.Sobel(img, cv2.CV_64F, 1, 0, ksize=5) # 索贝尔边缘检测-垂直 sobel_vertical = cv2.Sobel(img, cv2.CV_64F, 0, 1, ksize=5) # 拉普拉斯边缘检测 laplacian = cv2.Laplacian(img, cv2.CV_64F) # canny边缘检测 canny = cv2.Canny(img, 50, 240)cv2.imshow('Original', img) cv2.imshow('Sobel horizontal', sobel_horizontal) cv2.imshow('Sobel vertical', sobel_vertical) cv2.imshow('Laplacian', laplacian) cv2.imshow('Canny', canny)cv2.waitKey() 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18. 原创作者: u_15862653 转载于: https://blog.51cto.com/u_15862653/11888524