使用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编写生成树状结构的文件目录的脚本的教程

有时候需要罗列下U盘等移动设备或一个程序下面的目录结构的需求。基于这样的需求个人整理了一个使用Python的小工具,期望对有这方面需求的朋友有所帮助。以下为具体代码: 如果你所有要求的文...

Python中时间datetime的处理与转换用法总结

python中日期类datetime功能比较强大,使用起来很方便,把常用的两种用法总结如下: from datetime import datetime from datetime...

Android模拟器无法启动,报错:Cannot set up guest memory ‘android_arm’ Invalid argument的解决方法

Android模拟器无法启动,报错:Cannot set up guest memory ‘android_arm’ Invalid argument的解决方法

本文实例讲述了Android模拟器无法启动,报错:Cannot set up guest memory ‘android_arm': Invalid argument的解决方法。分享给大...

Python3.5 Json与pickle实现数据序列化与反序列化操作示例

Python3.5 Json与pickle实现数据序列化与反序列化操作示例

本文实例讲述了Python3.5 Json与pickle实现数据序列化与反序列化操作。分享给大家供大家参考,具体如下: 1、Json:不同语言之间进行数据交互。 (1)JSON数据序列化...

浅谈Python中的可变对象和不可变对象

什么是可变/不可变对象 不可变对象,该对象所指向的内存中的值不能被改变。当改变某个变量时候,由于其所指的值不能被改变,相当于把原来的值复制一份后再改变,这会开辟一个新的地址,变量再指向这...