# -*- coding: utf-8 -*-
from PIL import Image
from pylab import *#添加中文支持
from matplotlib.font_manager import FontProperties
font = FontProperties(fname=r"c:\windows\fonts\方正喵呜体.ttf", size=14)
figure()img=array(Image.open("F:/pic/jiandan/70b86a16gw1dl7jmvvwlkj.jpg"))
subplot(141)
#gray()axis('off')
title(u'原图像',fontproperties=font)
imshow(img)im=array(Image.open("F:/pic/jiandan/70b86a16gw1dl7jmvvwlkj.jpg").convert('L'))
subplot(142)
gray()
contour(im,origin="image")
axis('equal')
axis('off')
title(u'图像轮廓',fontproperties=font)subplot(143)
hist(im.flatten(),128)
title(u'图像直方图',fontproperties=font)
plt.xlim([0,260])
plt.ylim([0,11000])subplot(144)
hist(img.flatten(),128)
title(u'元图像直方图',fontproperties=font)
plt.xlim([0,260])
plt.ylim([0,11000])show()
显示原图 灰度图
subplot(mnp),m行n列第p张