import cv2 as cv
import numpy as np
import matplotlib.pyplot as pltimg = cv.imread("../SampleImages/pomeranian.png", cv.IMREAD_GRAYSCALE)
print(img.shape)#拉普拉斯边缘检测
#cv.Laplacian(src, ddepth, dst, ksize, scale, delta, borderType)
#src:原图
#ddpeth:图像深度。-1表示与原图深度一致,目标图像的深度必须大于等于原图深度
#ksize:算子大小,卷积核大小,必须为1,3,5,7,默认为3
#scale:缩放比例系数,默认为没有缩放
#boarderType:边界模式,默认为cv2.BOARDER_DEFAULT
#参考资料:https://blog.csdn.net/qq_45832961/article/details/122429117
img_laplacian = cv.Laplacian(img, cv.CV_64F)
img_laplacian = cv.convertScaleAbs(img_laplacian)
#显示图像
fig,axes = plt.subplots(nrows=1, ncols=2, figsize=(15,15), dpi=100)
axes[0].set_title("Original")
axes[0].imshow(img, plt.cm.gray)
axes[1].set_title("Laplacian")
axes[1].imshow(img_laplacian, plt.cm.gray)