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

# 이미지 읽기 (컬러 이미지, 기본적으로 BGR 형식으로 읽음)
color_img_bgr = cv2.imread( 'example.jpg' )

# 이미지를 그레이스케일로 변환
gray_img = cv2.cvtColor(color_img_bgr, cv2.COLOR_BGR2GRAY)

# 그레이스케일 이미지 출력
plt.figure(figsize=(6, 6))  # 출력 크기 설정
# 그레이스케일 이미지를 표시할 때는 cmap='gray' 사용
plt.imshow(gray_img, cmap='gray') #cmap -> color mapping
plt.title('Grayscale Image')
plt.axis('off')  # 축 제거
plt.show()
No description has been provided for this image