使用Python实现图像标记点的坐标输出功能

yipeiwu_com6年前Python基础

Sometimes we have need to interact  with an application,for example by marking points in an image,or you need to annotation some training data.PyLab comes with a simple function ginput() the let's you do just that .Here's a short example.

from PIL import Image
from pylab import *
im = array(Image.open('test.jpg'))
imshow(im)
print 'Please click 3 points'
x =ginput(3)
print 'you clicked:',x
show()

This plots an image and waits for the user to click three times in the image region of the figures window.The coordinates[x,y] of the clicks are saved in a list x.

总结

以上所述是小编给大家介绍的使用Python实现图像标记点的坐标输出功能 ,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对【听图阁-专注于Python设计】网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

相关文章

利用matplotlib实现根据实时数据动态更新图形

利用matplotlib实现根据实时数据动态更新图形

我就废话不多说了,直接上代码吧! from time import sleep from threading importThread import numpy as np impo...

导入tensorflow时报错:cannot import name 'abs'的解决

导入tensorflow时报错:cannot import name 'abs'的解决

一,问题背景 作者在用tensorflow做实验时,import tensorflow忽然报错:cannot import name 'abs'。错误情况如下所示: 这个问题出现的比较...

解决django model修改添加字段报错的问题

解决django model修改添加字段报错的问题

关于django models中添加字段的一个小节,记录下 django的models中已经写好了字段,可是后面我又想在添加一些字段,于是就在models中添加了字段 ,发现报错了 报...

python numpy 按行归一化的实例

如下所示: import numpy as np Z=np.random.random((5,5)) Zmax,Zmin=Z.max(axis=0),Z.min(axis=0) Z...

django进阶之cookie和session的使用示例

django进阶之cookie和session的使用示例

Cookies :是浏览器为 Web 服务器存储的一小段信息。 每次浏览器从某个服务器请求页面时,它收到服务器回发送过来的cookies。它保存在浏览器下的某个文件夹下。 Sessi...