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

 时间:2026-02-15 17:42:26

1、打开idle界面,并且载入需要用到的工具箱:

from skimage import data,filters,color

import 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操作系统如何设置跨区卷
  • 热门搜索
    紧急制动是什么意思 百感交集的意思 石灰吟的意思 野旷天低树江清月近人的意思 四面楚歌意思 i miss you是什么意思 蝇营狗苟的意思 冬天像什么的比喻句 防火墙有什么作用 渣渣是什么意思