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

相关文章

django实现用户注册实例讲解

创建一个apps包 专门来放子应用 创建users子应用 处理用户事务 追加导包路径 在settings中用 print(sys.path) 查看现有导包路径 sys.path.i...

Python控制多进程与多线程并发数总结

Python控制多进程与多线程并发数总结

一、前言 本来写了脚本用于暴力破解密码,可是1秒钟尝试一个密码2220000个密码我的天,想用多线程可是只会一个for全开,难道开2220000个线程吗?只好学习控制线程数了,官方文档...

Python pygorithm模块用法示例【常见算法测试】

本文实例讲述了Python pygorithm模块用法。分享给大家供大家参考,具体如下: pygorithm:一个用纯粹python编写的Python模块,用于纯粹的教育目的。只需导入所...

Python读取本地文件并解析网页元素的方法

如下所示: from bs4 import BeautifulSoup path = './web/new_index.html' with open(path, 'r') as f...

python字符串分割及字符串的一些常规方法

字符串分割,将一个字符串分裂成多个字符串组成的列表,可以理解为字符串转列表,经常会用到 语法:str.split(sep, [,max]),sep可以指定切割的符号,max可以指定切割...