import cv2
import os
import numpy as np
def cv2_la(img_path):
img = cv2.imread(img_path)
# 使用 cv2.Laplacian 实现 Laplace 卷积算子
imgLaplace2 = cv2.Laplacian(img, -1, ksize=3)
imgRecovery = cv2.add(img, imgLaplace2) # 恢复原图像
return imgRecovery
def read_path(file_pathname):
for filename in os.listdir(file_pathname):
print(filename)
image_np = cv2_la(file_pathname + '/' + filename)
cv2.imwrite('new_pic' + "/" + filename, image_np)
read_path("pic")
参考来源:https://blog.csdn.net/youcans/article/details/122091412