import numpy as np
import cv2
import matplotlib.pyplot as plt
from matplotlib import rc, font_manager
rc('font', family = "Malgun Gothic")
def showImage() :
imgfile = './images/iu.jpg'
img_bgr = cv2.imread(imgfile) # BGR 상태로 받음
img = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB) # convert color, BGR to RGB
img_gray = cv2.imread(imgfile, cv2.IMREAD_GRAYSCALE)
# 타이틀 사용
fig = plt.figure()
ax1 = fig.add_subplot(1, 2, 1) # 도화지에 1행 2열 1번째 칸
ax1.imshow(img)
ax1.set_title("아이유컬러")
ax1.set_xlabel('(오리지널)')
ax1.set_xticks([]), ax1.set_yticks([]) # 축 없어짐
ax1 부분 복사해서 붙여넣기
1을 2로 다 교체
ax2 = fig.add_subplot(1, 2, 2) # 도화지에 1행 2열 2번째 칸
ax2.imshow(img_gray, cmap='gray')
ax2.set_title("아이유흑백")
ax2.set_xlabel('(흑백사진)')
ax2.set_xticks([]), ax2.set_yticks([]) # 축 없어짐
plt.show()
showImage()