소스 뷰어
import cv2, numpy as np, matplotlib.pyplot as plt

# 이미지 불러오기
img = cv2.imread('blurred.jpg', cv2.IMREAD_GRAYSCALE) 

# 첫번째 샤프닝 커널 생성
kernel_01 = np.array([[0, -1, 0], [-1, 5,-1], [0, -1, 0]])

# filter2D를 사용하여 커널을 첫번째 이미지에 적용
img_sharpened_01 = cv2.filter2D(img, -1, kernel_01)

# 두번째 샤프닝 커널 생성
kernel_02 = np.array([[-1, -1, -1], [-1, 9, -1], [-1, -1, -1]])

# filter2D를 사용하여 커널을 두번째 이미지에 적용
img_sharpened_02 = cv2.filter2D(img, -1, kernel_02)

# 원본 이미지와 샤프닝 적용된 이미지 비교 출력
plt.figure(figsize=(10, 5))

# 원본 이미지 출력
plt.subplot(1, 3, 1)
plt.imshow(img, cmap="gray")
plt.title('Original Image')
plt.axis('off')

# 샤프닝 이미지 출력
plt.subplot(1, 3, 2)
plt.imshow(img_sharpened_01, cmap="gray")
plt.title( f'Sharpened Image 01' )
plt.axis('off')

# 샤프닝 이미지 출력
plt.subplot(1, 3, 3)
plt.imshow(img_sharpened_02, cmap="gray")
plt.title( f'Sharpened Image 02' )
plt.axis('off')

plt.tight_layout()
plt.show()
No description has been provided for this image