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

相关文章

基于numpy中数组元素的切片复制方法

代码1: #!/usr/bin/python import numpy as np arr1 = np.arange(10) print(arr1) slice_data...

Python中使用PyQt把网页转换成PDF操作代码实例

代码很简单,功能也很简单 =w= webpage2pdf #!/usr/bin/env python3 import sys try: from PyQt4 import...

python如何通过twisted实现数据库异步插入

如何通过twisted实现数据库异步插入?   1. 导入adbapi   2. 生成数据库连接池   3. 执行数据数据库插入操作   4. 打印错误信息,并排错 #!/usr/b...

python实现简单温度转换的方法

本文实例讲述了python实现简单温度转换的方法。分享给大家供大家参考。具体分析如下: 这是一段简单的python代码,用户转换不同单位的温度,适合初学者参考 复制代码 代码如下:def...

详细讲解Python中的文件I/O操作

详细讲解Python中的文件I/O操作

 本章将覆盖所有在Python中使用的基本I/O功能。有关更多函数,请参考标准Python文档。 打印到屏幕上: 产生输出最简单的方法是使用print语句,可以通过用逗号分隔的...