使用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排序搜索基本算法之希尔排序实例分析

本文实例讲述了Python排序搜索基本算法之希尔排序。分享给大家供大家参考,具体如下: 希尔排序是插入排序的扩展,通过允许非相邻的元素进行交换来提高执行效率。希尔排序最关键的是选择步长,...

Python跳出循环语句continue与break的区别

Python跳出循环语句continue与break的区别

虽然在Python中的for循环与其它语言不大一样,但跳出循环还是与大多数语言一样,可以使用关键字continue跳出本次循环或者break跳出整个for循环。 break 复制代码 代...

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

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

Python 正则表达式操作指南

原文作者:A.M. Kuchling (amk@amk.ca) 授权许可:创作共享协议 翻译人员:FireHare 校对人员:Leal 适用版本:Python 1.5 及后续版本http...

简单讲解Python中的数字类型及基本的数学计算

Python有四种类型的数字: 1.整型  a = 2 print a 2.长整型  b = 123456789 print b 3....