1、打开IDLE界面。
导入要用的工具软件:
from skimage import data,color
import skimage.morphology as sm
import matplotlib.pyplot as plt

2、读取相关的图片,图片库内部的:
img=color.rgb2gray(data.coffee())

3、采用下面的代码进行黑帽处理:
dst=sm.black_tophat(img,sm.square(11))

4、查看我们的处理结果:
plt.figure('black-tophat')
plt.subplot(121)
plt.imshow(img,plt.cm.gray)
plt.subplot(122)
plt.imshow(dst,plt.cm.gray)
plt.show()

5、查看我们的效果如下图。
