1、打开IDLE:IDLE是Pythonshell界面,如图所示。

2、载入工具包:在Python中要实现某一个代码需要载入相关的软件包才可以实现。from skimage import data,colorimport matplotlib.pyplot as pltfrom skimage.morphology import diskimport skimage.filters.rank as sfr

3、读取图片:读取自己要处理的图片,并且将图片进行灰度化处理,这里读取skimage包内的图片。img=color.rgb2gray(data.coffee())

4、滤波处理:采用以下代码对图片进行最大值滤波处理。dst =sfr.maximum(img, disk(5))

5、查看效果:采用下面语句来查看我们滤波后的图片。plt.figure('filters')plt.subplot(121)plt.imshow(img,plt.cm.gray)plt.subplot(122)plt.imshow(dst,plt.cm.gray)plt.show()

6、滤波结果:
