13 Star 41 Fork 7

Ross / ImageRecognition

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
autohist.py 544 Bytes
一键复制 编辑 原始数据 按行查看 历史
Ross 提交于 2016-06-11 18:52 . 灰度阈值函数
#!/usr/bin/python2
#-*- coding:utf-8 -*-
from skimage import data, filters, io
from PIL import Image
import matplotlib.pyplot as plt
image = io.imread('testgray.png', as_gray = True)
#image = data.camera()
print image
thresh = filters.threshold_otsu(image) #返回一个阈值
print thresh
dst =(image >= thresh)*1.0 #根据阈值进行分割
plt.figure('thresh',figsize=(8,8))
plt.subplot(121)
plt.title('original image')
plt.imshow(image,plt.cm.gray)
plt.subplot(122)
plt.title('binary image')
plt.imshow(dst,plt.cm.gray)
plt.show()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/rx_z/ImageRecognition.git
git@gitee.com:rx_z/ImageRecognition.git
rx_z
ImageRecognition
ImageRecognition
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891