直方图与均值化
直方图
(个人看法:他就是把一个图像(一大堆的矩阵数字)全部按照中方图统计一下从0-255)
三个颜色统计出来三个线
代码
import cv2
from matplotlib import pyplot as plt
img=cv2.imread(‘cat.jpg’)
color=(‘b’,‘g’,‘r’)
for i,col in enumerate(color):
hist=cv2.calcHist([img],[0],None,[256],[0,256])
plt.plot(hist,color=col)
plt.xlim([0,256])
plt.imshow(hist)
plt.show()
print(hist.shape)
掩码mask操作
第一步创建掩码mask操作