1、打开Python shell:

2、载入工具包:载入要使用到的工具包,代码如下(若是报错说明可能没安装先关的工具包),from skimage import data,colorimport matplotlib.pyplot as pltfrom skimage.morphology import diskimport skimage.filters.rank as sfr

3、读入一个图片:读入我们要处理的图片,代码如下,这里读取的是工具包中自带的图片,img=color.rgb2gray(data.coffee())

4、对图片进行滤波:可采用以下方法进行滤波,也就是我们的文中所给的方法,auto =sfr.enhance_contrast(img, disk(5))

5、显示效果:采用下面的代码显示我们的效果。plt.figure('filters')plt.subplot(121)plt.imshow(img,plt.cm.gray)plt.subplot(122)plt.imshow(auto,plt.cm.gray)plt.show()

6、结果:可得到我们的结果如下。
