def hist(path):
from PIL import Image
from matplotlib import pyplot as plt
import numpy as np
image = Image.open(path).convert('L')
plt.figure(figsize=(15, 8))
plt.gray()
plt.subplot(121)
plt.hist(np.array(image).flatten(), 128)
plt.subplot(122)
plt.imshow(image)
plt.show()
if __name__ == '__main__':
path = '../data/imgs/hdrplus.png'
hist(path)