【每日coding】hist


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)

 

你可能感兴趣的:(Everyday,code,python)