python对图片二值化处理(yen算法)

 时间:2024-10-13 00:23:29

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

python对图片二值化处理(yen算法)

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

python对图片二值化处理(yen算法)

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

python对图片二值化处理(yen算法)

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

python对图片二值化处理(yen算法)

5、查看结果如下。

python对图片二值化处理(yen算法)
  • 打开http://localhost时,出现404错误的解决方法
  • 如何用c语言打印出Helloworld
  • vue-cli 卸载不掉怎么办
  • 如何在win server中审核登录策略
  • Windows Server 2008 R2操作系统如何设置跨区卷
  • 热门搜索
    扁平疣怎么治 腰上的赘肉怎么减 陈寅恪怎么读 45岁闭经怎么办 工作展望怎么写 怎么能减肥 怎么让头发蓬松 静脉曲张怎么预防 炒鸡蛋怎么做 怎么锁电脑屏幕