python如何对图片二值化处理(isodata算法)

 时间:2026-02-15 08:22:34

1、这里要使用winPython软件,且要安装有相关的工具包;

这里首先打开IDLE界面,也就是shell;

导入时的代码(若是报错,则可能没有安装相关的包)

from skimage import color,filters,data

import matplotlib.pyplot as plt

python如何对图片二值化处理(isodata算法)

2、采用以下代码读取一张图片,并灰度化处理,这里用到了包内自带的图片:

image=color.rgb2gray(data.camera())

python如何对图片二值化处理(isodata算法)

3、isodata是具体的算法是比较复杂的方法,这里不介绍理论了,采用以下指令就可以进行灰度化处理:

thresh = filters.threshold_isodata(image)

dst =(image <= thresh)*1.0

python如何对图片二值化处理(isodata算法)

4、采用以下代码查看我著块们的二值化后的图片:

plt.figure('畜罪伐isodata') 

plt.subplot(121) 

plt.title('原图')

plt.imshow(image,plt.cm.gray) 

plt.subplot(122)

plt.title('二值化图') 

plt.imshow(dst,plt.cm.gray) 

plt.show()

python如何对图片二值化处理(isodata算法)

5、查愁联看二值化后的结果如下。

python如何对图片二值化处理(isodata算法)

  • XP/win7系统中VS2008安装方法(离线安装)
  • 使用Windows server 2008 R2如何停止证书服务器
  • 如何二次开发永中office
  • 如何恢复回收站文件?教你一招解决
  • FN功能键大全:[6]华硕篇
  • 热门搜索
    淘宝怎么取消订单 七日杀怎么联机 内存卡读不出来怎么办 胸贴怎么清洗 qq保护模式怎么解除 罗马数字怎么写 凝结的近义词 男孩短发发型 怎么过生日 婴儿湿疹怎么治疗