소스 뷰어
import cv2, numpy as np, matplotlib.pyplot as plt
# 이미지 불러오기
img = cv2.imread('blurred.jpg', cv2.IMREAD_GRAYSCALE)
# 샤프닝 커널 생성
kernel = np.array([[-1, -1, -1], [-1, 9, -1], [-1, -1, -1]])
# filter2D를 사용하여 커널을 이미지에 적용
img_sharpened = cv2.filter2D(img, -1, kernel)
# 원본 이미지와 샤프닝 이미지 비교 출력
plt.figure(figsize=(10, 5))
# 원본 이미지 출력
plt.subplot(1, 2, 1)
plt.imshow(img, cmap="gray")
plt.title('Original Image')
plt.axis('off')
# 샤프닝 이미지 출력
plt.subplot(1, 2, 2)
plt.imshow(img_sharpened, cmap="gray")
plt.title( f'Sharpened Image 02' )
plt.axis('off')
plt.tight_layout()
plt.show()