参考:
https://stackoverflow.com/questions/4993082/how-to-sharpen-an-image-in-opencv
import cv2
import numpy as np
img=cv2.imread("messi5.jpg")
# 1
blur=cv2.GaussianBlur(img,(0,0),3)
image=cv2.addWeighted(img,1.5,blur,-0.5,0)
# 2
kernel = np.array([[-1,-1,-1], [-1,9,-1], [-1,-1,-1]])
image = cv2.filter2D(img, -1, kernel)
# 3
image=cv2.bilateralFilter(img,9,75,75)
# 4
sigma = 1; threshold = 5; amount = 1
blurred=cv2.GaussianBlur(img,(0,0),1,None,1)
lowContrastMask = abs(img - blurred) < threshold
sharpened = img*(1+amount) + blurred*(-amount)
image=cv2.bitwise_or(sharpened.astype(np.uint8),lowContrastMask.astype(np.uint8))
cv2.namedWindow("dst",cv2.WINDOW_FREERATIO)
cv2.imshow("dst",image)
cv2.waitKey(0)
cv2.destroyAllWindows()
本文介绍了使用OpenCV进行图像锐化的四种不同方法,包括基于加权平均、卷积核、双边滤波以及高斯模糊的锐化技术,并提供了详细的Python实现代码。
1136

被折叠的 条评论
为什么被折叠?



