计算亮度直方图

原图和结果图片:

     

代码实现:

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()
原文地址:https://www.cnblogs.com/czz0508/p/11042766.html