python对图片二值化处理(yen算法)
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、查看结果如下。
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:175
阅读量:117
阅读量:151
阅读量:158
阅读量:82