《OpenCV系列教程》
项目位置:OpenCV-Sample
代码位置:19-ImageLaplacian.py
iimport cv2
from matplotlib import pyplot as plt
img = cv2.imread('./res/CarID.jpeg',0)
laplacian = cv2.Laplacian(img, cv2.CV_64F)
sobelx = cv2.Sobel(img, cv2.CV_64F, 1, 0, ksize=3)
sobely = cv2.Sobel(img, cv2.CV_64F, 0, 1, ksize=3)
sobleXplusY = sobelx + sobely
titles = ['Original', 'Laplacian', 'SobelX', 'SobelY', 'sobleXplusY']
imgs = [img, laplacian, sobelx, sobely, sobleXplusY]
plt.figure(figsize = (10, 5))
for i in range(5):
plt.subplot(2,3,i+1)
plt.imshow(imgs[i], 'gray')
plt.title(titles[i])
plt.axis('off')
plt.show()

- Laplacian 实现 Laplacian 算子 的离散模拟。
- Sobel 多X轴,Y轴求导。
- sobleXplusY 为X轴求导,Y轴求导后的相加数值。
这篇博客介绍了OpenCV中用于图像处理的Laplacian算子和Sobel算子的实现。通过示例代码19-ImageLaplacian.py,展示了如何进行离散模拟Laplacian操作,以及Sobel算子在X轴和Y轴上的求导应用。此外,还提到了sobleXplusY,即X轴与Y轴求导相加的处理方式。
1万+





