作者:ccccting
案列:© Fu Xianjun. All Rights Reserved.
目录
直方图处理
1.绘制直方图
import cv2
import matplotlib.pyplot as plt
img = cv2.imread('1.jpg')
plt.hist(img.ravel(),16)
plt.show()
2. 绘制统计直方图
import cv2
import matplotlib.pyplot as plt
img=cv2.imread("1.jpg")
histb = cv2.calcHist([img], [0], None, [256], [0,255])
histg = cv2.calcHist([img], [1], None, [256], [0,255])
histr = cv2.calcHist([img], [2], None, [256], [0,255])
plt.subplot(131)
plt.plot(histb, color='b')
plt.subplot(132)
plt.plot(histg, color='g')
plt.subplot(133)
plt.plot(histr, color='r')
plt.savefig('histogram.png')
plt.show()
1805

被折叠的 条评论
为什么被折叠?



