0
点赞
收藏
分享

微信扫一扫

OpenCV Laplacian算子

飞进科技 2022-06-01 阅读 10

laplacian = cv2.Laplacian(src, ddepth[, dst[, ksize[, scale[, delta[, borderType]]]]])

  • Src: 需要处理的图像,
  • Ddepth: 图像的深度,-1表示采用的是原图像相同的深度,目标图像的深度必须大于等于原图像的深度;
  • ksize:算子的大小,即卷积核的大小,必须为1,3,5,7。

import cv2 as cv
from matplotlib import pyplot as plt
# 1 读取图像
img = cv.imread('./1.png', 0)

# 2 laplacian转换
result = cv.Laplacian(img, cv.CV_16S)
Scale_abs = cv.convertScaleAbs(result)

# 3 图像展示
plt.figure(figsize=(10, 8), dpi=100)
plt.subplot(121),
plt.imshow(img, cmap=plt.cm.gray),
plt.title('原图')
plt.xticks([]),
plt.yticks([])
plt.subplot(122),
plt.imshow(Scale_abs,cmap = plt.cm.gray)
plt.title('Laplacian检测后结果')
plt.xticks([]),
plt.yticks([])
plt.show()

OpenCV Laplacian算子_读取图像


举报

相关推荐

0 条评论