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

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

# 가우시안 블러를 적용하여 노이즈 제거
blurred_image = cv2.GaussianBlur(image, (9, 9), 0)

# 라플라시안 엣지 검출 (LoG)
log = cv2.Laplacian(blurred_image, cv2.CV_64F)  # CV_64F는 출력 이미지의 데이터 타입

# 음수를 절댓값으로 변환하여 에지 강조
log_abs = np.abs(log).astype(np.uint8)

# 폰트 사이즈
fs = 30

# 결과 출력
plt.figure(figsize=(18, 6))

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

# 블러 이미지 출력
plt.subplot(1, 3, 2)
plt.title("Blurred Image", fontsize=fs)
plt.imshow(blurred_image, cmap='gray')
plt.axis('off')

# LoG 이미지 출력
plt.subplot(1, 3, 3)
plt.title("LoG Edge Detection", fontsize=fs)
plt.imshow(log_abs, cmap='gray')
plt.axis('off')

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