利用Python语言进行简单的数字图像处理(直方图、均衡化、高斯滤波)
文章目录
一、 利用Python语言绘制直方图
图像直方图为反映一幅图像中各灰度级与各灰度级像素出现的频率之间的关系图。
PIL (Python Imaging Library)图像库提供了很多常用的图像处理及很多有用的图像基本操作。PIL库下载地址链接: link.
实现
原图片
(课本代码)
from PCV.tools import imtools
from PIL import Image
# 添加中文字体支持
from matplotlib.font_manager import FontProperties
from pylab import *
from scipy.ndimage import filters
font = FontProperties(fname=r"c:\windows\fonts\SimSun.ttc", size=14)
im = array(Image.open('flower.jpg').convert('L')) # 打开图像,并转成灰度图像
#im = array(Image.open('../data/AquaTermi_lowcontrast.JPG').convert('L'))
im2, cdf = imtools.histeq(im)
figure()
subplot(3, 3, 1)
axis('off')
gray()
title(u'原始图像', fontproperties=font)
imsh