import cv2
from matplotlib import pyplot as plt
import os
import numpy as np
filepath = './Input'
pathDir = os.listdir(filepath)
for allDir in pathDir:
picpath = r'./Input/' + allDir
pc = cv2.imdecode(np.fromfile(picpath, dtype=np.uint8), 0)
plt.hist(pc.ravel(),256,[0,256])
plt.suptitle(allDir[:-4],fontsize = 20,color ='black')
plt.savefig(allDir)
plt.close()
print('
','运行结束!直方图在当前目录下……')