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

相关文章

python3利用venv配置虚拟环境及过程中的小问题小结

python3利用venv配置虚拟环境及过程中的小问题小结

在利用python进行flask等开发过程中经常需要配置虚拟环境以方便针对不同的项目需求配置不同的生产环境。在python3.3之前,需要利用virtualenv等工具来实现python...

Python中使用装饰器和元编程实现结构体类实例

Ruby中有一个很方便的Struct类,用来实现结构体。这样就不用费力的去定义一个完整的类来仅仅用作访问属性。 复制代码 代码如下: class Dog < Struct.new(...

python开发之tkinter实现图形随鼠标移动的方法

python开发之tkinter实现图形随鼠标移动的方法

本文实例讲述了python开发之tkinter实现图形随鼠标移动的方法。分享给大家供大家参考,具体如下: 做这个东西的时候,灵感源自于一个js效果: 两个眼睛随鼠标移动而移动 运行效果:...

解决python大批量读写.doc文件的问题

前言: java语言读写.doc的出现乱码问题: 大家都知道当我们利用java语言读写.doc文件时,无论是利用流的方式将.doc文件的内容输出到控制台(console),还是将其写到其...

python网络编程之读取网站根目录实例

本文实例讲述了python网络编程之读取网站根目录的方法,分享给大家供大家参考。 具体实现方法如下: import socket, sys port = 70 host =...