原图和结果图片:
代码实现:
import matplotlib.pyplot as plt import cv2 img = cv2.imread('./1.jpg', 0) new=img.flatten() plt.hist(new, bins=256, range=(0, 256), facecolor='green') plt.xlabel("histogram plot") plt.ylabel('frequency') plt.show()