网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

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

时间:2024-11-20 19:09:52

1、打开IDLE,即Python shell黢茕茚痔界面;载入相关的库文件:from skimage import data,color,filtersimport 罪焐芡拂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算法)
© 2025 小知经验
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com