使用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实现购物车功能的方法。分享给大家供大家参考,具体如下: 1、程序的源代码如下: salary = input('input your salary:') i...

Python读写及备份oracle数据库操作示例

Python读写及备份oracle数据库操作示例

本文实例讲述了Python读写及备份oracle数据库操作。分享给大家供大家参考,具体如下: 最近项目中需要用到Python调用oracle实现读写操作,踩过很多坑,历尽艰辛终于实现了。...

python nmap实现端口扫描器教程

python nmap实现端口扫描器教程

NMap,也就是Network Mapper,最早是Linux下的网络扫描和嗅探工具包。 nmap是一个网络连接端扫描软件,用来扫描网上电脑开放的网络连接端。确定哪些服务运行在哪些连接端...

Python转码问题的解决方法

比如,若要将某个String对象s从gbk内码转换为UTF-8,可以如下操作 s.decode('gbk').encode('utf-8′) 可是,在实际开发中,我发现,这种办法经常会出...

python之virtualenv的简单使用方法(必看篇)

什么是virtualenv? virtualenv可以创建独立Python开发环境,比如当前的全局开发环境是python3.6,现在我们有一个项目需要使用django1.3,另一个项目需...