def image_convert(path):
from PIL import Image
import matplotlib.pyplot as plt
image = Image.open(path).convert('L') # L = R * 299/1000 + G * 587/1000+ B * 114/1000
bi_image = Image.open(path).convert('1') # binary image
plt.figure("image", figsize=(15,8))
plt.subplot(121)
plt.imshow(image, cmap='gray')
plt.subplot(122)
plt.imshow(bi_image, cmap='gray_r')
plt.pause(5)
if __name__ == '__main__':
path = '../data/imgs/hdrplus.png'
image_convert(path)