소스 뷰어
import cv2
import matplotlib.pyplot as plt

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

# 다양한 Canny Edge 임계값 설정 (5개 조합)
thresholds = [
    (50, 100),   # 낮은 임계값
    (100, 200),  # 중간 임계값
    (150, 300),  # 약간 높은 임계값
    (200, 400),  # 높은 임계값
    (300, 600),  # 아주 높은 임계값
]

# 결과 출력
fs = 15  # 폰트 사이즈 설정
plt.figure(figsize=(16, 10))

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

# 각 임계값에 대한 Canny Edge 결과 출력
for i, (t1, t2) in enumerate(thresholds):
    canny_edge = cv2.Canny(image, t1, t2)
    plt.subplot(2, 3, i+2)  # 2행 3열 중 해당 위치
    plt.title(f"Canny Edge ({t1}, {t2})", fontsize=fs)
    plt.imshow(canny_edge, cmap='gray')
    plt.axis('off')
pass

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