1import cv2
2import numpy as np
3from matplotlib import pyplot as plt
4
5file0 = 'image.jpg'
6img = cv2.imread(file0)
7color = ('b','g','r')
8plt.figure()
9for i,col in enumerate(color):
10 histr = cv2.calcHist([img],[i],None,[256],[0,256])
11 plt.plot(histr,color = col)
12 plt.xlim([0,256])
13plt.show()
14