使用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设计】网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

相关文章

python实现在windows服务中新建进程的方法

本文实例讲述了python实现在windows服务中新建进程的方法。分享给大家供大家参考。具体实现方法如下: 需要安装的软件:python和pywin32,我这里装的分别是python-...

深入flask之异步非堵塞实现代码示例

官方其实已经给出了方案,只不过藏的有点深,在加上网上有很多不太靠谱的帖子误导了我(当然不排除我没理解的原因哈)。所以为了让有些朋友的少走点弯路,也为给自己做个备忘。 完整代码:https...

Python深入学习之上下文管理器

上下文管理器(context manager)是Python2.5开始支持的一种语法,用于规定某个对象的使用范围。一旦进入或者离开该使用范围,会有特殊操作被调用 (比如为对象分配或者释放...

用python求一重积分和二重积分的例子

首先是对一元函数求积分,使用Scipy下的integrate函数: from scipy import integrate def g(x): return (1-x**2)**...

Python比较配置文件的方法实例详解

工作中最常见的配置文件有四种:普通key=value的配置文件、Json格式的配置文件、HTML格式的配置文件以及YMAML配置文件。 这其中以第一种居多,后三种在成熟的开源产品中较为...