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

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

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

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

# 폰트 사이즈
fs = 30

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

plt.subplot(2, 2, 1)
plt.title("Original Image", fontsize=fs)
plt.imshow(image, cmap='gray')
plt.axis('off')

plt.subplot(2, 2, 2)
plt.title("Laplacian Edge Detection", fontsize=fs)
plt.imshow(laplacian_abs, cmap='gray')
plt.axis('off')

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