1、打开idle界面,并且载入需要用到的工具箱:
from skimage import data,filters,color
import matplotlib.pyplot as plt

2、读取一个图片,并且进行灰度化处理,这里读取了工具包自带的图片:
image=color.rgb2gray(data.astronaut())

3、采用以下方法对图片进行二值化处理:
thresh = filters.threshold_yen(image)
dst =(image <= thresh)*1.0

4、采用下面代码查看效果:
plt.figure('yen二值化')
plt.subplot(121)
plt.imshow(image,plt.cm.gray)
plt.subplot(122)
plt.imshow(dst,plt.cm.gray)
plt.show()

5、查看结果如下。
