原图
索贝尔
拉普拉斯和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()
标签:Sobel,sobel,img,检测,imshow,cv2,边缘,240723,canny
From: https://blog.51cto.com/u_15862653/11888524