使用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 opencv 实现对图像边缘扩充

python opencv 实现对图像边缘扩充

原始图像 根据图像的边界的像素值,向外扩充图片,每个方向扩充50个像素。 a = cv2.copyMakeBorder(img,50,50,50,50,cv2.BORDER_REPL...

Python Pillow Image Invert

本文主要是利用Python的第三方库Pillow,实现单通道灰度图像的颜色翻转功能。 # -*- encoding:utf-8 -*- import os import sys fr...

Python中__init__和__new__的区别详解

__init__ 方法是什么? 使用Python写过面向对象的代码的同学,可能对 __init__ 方法已经非常熟悉了,__init__ 方法通常用在初始化一个类实例的时候。例如:...

浅谈Python 对象内存占用

一切皆是对象 在 Python 一切皆是对象,包括所有类型的常量与变量,整型,布尔型,甚至函数。 参见stackoverflow上的一个问题 Is everything an objec...

python将txt文件读入为np.array的方法

原文件: 7.8094,1.0804,5.7632,0.012269,0.008994,-0.003469,-0.79279,-0.064686,0.11635,0.68827,5....