python+opencv图像处理(四十三)
Luplacian算子
1、Luplacian算子
2、Luplacian算子实现
dst = cv2.Laplacian(src, ddepth[, dst[, ksize[, scale[, delta[, borderType]]]]])
其中,src是需要处理的图像;
第二个参数是图像的深度,-1表示采用的是与原图像相同的深度。目标图像的深度必须大于等于原图像的深度;
ksize是算子的大小,必须为1、3、5、7。默认为1。
scale是缩放导数的比例常数,默认情况下没有伸缩系数;
delta是一个可选的增量,将会加到最终的dst中,同样,默认情况下没有额外的值加到dst中;
borderType是判断图像边界的模式。这个参数默认值为cv2.BORDER_DEFAULT。

其完整代码为:
import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt
def Luplacian(img):
dst=cv.Laplacian(img,cv.CV_32F)
res=cv.convertScaleAbs(dst)
return res
img = cv.imread("E:\image\lena.jpg")
cv.imshow("origin",img)
dst=Luplacian(img)
cv.imshow("Luplacian",dst)
cv.waitKey(0)
赞 (0)
