Python如何对图像二值化(li算法)

 时间:2026-04-23 03:19:34

1、打开IDLE,即Python shell界面;

载入相关的库文件:

from skimage import data,color,filters

import matplotlib.pyplot as plt

Python如何对图像二值化(li算法)

2、读取一个图片,这里读取包内的图片文件,并将其灰度化处理:

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

Python如何对图像二值化(li算法)

3、对图片进行li算法运算,采用以下代码:

thresh = filters.threshold_li(image)

dst =(image <= thresh)*1.0

Python如何对图像二值化(li算法)

4、采用下面的代码查看,二值化以后的图片:

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

plt.show()

Python如何对图像二值化(li算法)

5、查看我们的图片效果如下。

Python如何对图像二值化(li算法)

  • 微型计算机接口技术及应用(第三版)刘乐善知识点
  • 溶解度大小怎么判断
  • 什么是RFID技术
  • 计算机二级c语言考试复习技巧
  • 介绍什么是酸洗卷
  • 热门搜索
    华山旅游网 越南旅游地图 去土耳其旅游 西安旅游纪念品 江苏旅游景点推荐 福建龙岩旅游 福建漳州旅游 背包客旅游网 坦桑尼亚旅游 崆峒山旅游