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

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

# 평균 필터 커널 생성
ks = kernel_size = 17 # 커널 사이즈
kernel = np.ones((ks, ks), np.float32)/ks**2

# filter2D를 사용하여 커널을 이미지에 적용 (평균 블러)
blurred_image = cv2.filter2D(image, -1, kernel)

# 원본 이미지와 평균 블러 적용된 이미지 비교 출력
plt.figure(figsize=(10, 5))

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

# 평균 블러링된 이미지 출력
plt.subplot(1, 2, 2)
plt.imshow(blurred_image, cmap="gray")
plt.title( f'{ks}x{ks} Average Blurred Image' )
plt.axis('off')

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