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

相关文章

import的本质解析

上一篇文章中我们介绍了python中hashlib模块用法示例,详情参见:/post/127103.htm。今天我们看看import的有关内容。 编程时总是用到import导入,动不动就...

Python程序暂停的正常处理方法

将进程挂起(Suspend) 而非 阻塞(Block) 如果用sleep() 进程将阻塞 假设进程下有两个线程 那么这两个线程会继续运行 要使进程挂起 可以考虑使用psutil im...

使用C++扩展Python的功能详解

使用C++扩展Python的功能详解

本文主要研究的是使用C++扩展Python的功能的相关问题,具体如下。 环境 VS2005Python2.5.4Windows7(32位) 简介 长话短说,这里说的扩展Python功能与...

Flask解决跨域的问题示例代码

Flask解决跨域的问题示例代码

跨域文件上传的时候,浏览器会自动发起一个 OPTIONS 方法到服务器,现在后台解决前端跨域解决前端跨域请求的问题 客户端发起的这个 OPTIONS 可以说是一个“预请求”,用于探测后续...

django 自定义用户user模型的三种方法

django version: 1.7.1 最简单的推荐: 使用abstractuser扩充fields 复制代码 代码如下: profiles/models.py from djang...