参考:https://www.cnblogs.com/xuxugui/p/9815237.html
https://blog.csdn.net/GarfieldEr007/article/details/50757070
1.直方图
代码实现:# -- coding: utf-8 --
from PIL import Image
from pylab import *
from matplotlib.font_manager import FontProperties
font = FontProperties(fname=r"c:\windows\fonts\SimSun.ttc", size=14)
im = array(Image.open(’…/data/empire.jpg’).convert(‘L’)) # 打开图像,并转成灰度图像
figure()
subplot(121)
gray()
contour(im, origin=‘image’)
axis(‘equal’)
axis(‘off’)
title(u’图像轮廓’, fontproperties=font)
subplot(122)
hist(im.flatten(), 128)
title(u’图像直方图’, fontproperties=font)
plt.xlim([0,260])
plt.ylim([0,11000])
show()
运行上面代码,结果如图
<