使用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基于正则表达式实现文件内容替换的方法

本文实例讲述了Python基于正则表达式实现文件内容替换的方法。分享给大家供大家参考,具体如下: 最近因为有一个项目需要从普通的服务器移植到SAE,而SAE的thinkphp文件结构和本...

Python struct模块解析

Python struct模块解析

python提供了一个struct模块来提供转换。下面就介绍这个模块中的几个方法。     struct.pack(): struct.pack用于将Pyt...

python实现聚类算法原理

python实现聚类算法原理

本文主要内容: 聚类算法的特点 聚类算法样本间的属性(包括,有序属性、无序属性)度量标准 聚类的常见算法,原型聚类(主要论述K均值聚类),层次聚类、密度聚类 K均值聚类...

Python设计模式之建造者模式实例详解

Python设计模式之建造者模式实例详解

本文实例讲述了Python设计模式之建造者模式。分享给大家供大家参考,具体如下: 建造者模式(Builder Pattern):将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以...

python通过安装itchat包实现微信自动回复收到的春节祝福

python通过安装itchat包实现微信自动回复收到的春节祝福

itchat是一个开源的微信个人号接口,使用python调用微信从未如此简单。 开源地址 https://github.com/littlecodersh/ItChat 文档: http...