使用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 locals()的陷阱

在工作中, 有时候会遇到一种情况: 动态地进行变量赋值, 不管是局部变量还是全局变量, 在我们绞尽脑汁的时候, Python已经为我们解决了这个问题. Python的命名空间通过一种字典...

快速解决安装python没有scripts文件夹的问题

安装Python2.7,好多次都不会产生scripts文件夹,导致无法使用pip。 折腾了一下,找到了解决办法。 让人无法接受的是,只要是我给的安装包一定不会产生scripts文件夹,所...

python matplotlib画图库学习绘制常用的图

python matplotlib画图库学习绘制常用的图

本文实例为大家分享了python matplotlib绘制常用图的具体代码,供大家参考,具体内容如下 github地址 导入相关类 import numpy as np import...

python 通过logging写入日志到文件和控制台的实例

如下所示: import logging # 创建一个logger logger = logging.getLogger('mylogger') logger.setLev...

Python 面试中 8 个必考问题

1、下面这段代码的输出结果是什么?请解释。 def extendList(val, list=[]): list.append(val) return list list...