使用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将一个CSV文件里的数据追加到另一个CSV文件的方法

Python将一个CSV文件里的数据追加到另一个CSV文件的方法

在做数据处理工作时,有时需要将数据合并在一起,本文主要使用Python将两个CSV文件内数据合并在一起,合并方式有很多,本文只追加方式。 首先给定两个CSV文件的内容 1.CSV 2....

Python中实现的RC4算法

闲暇之时,用Python实现了一下RC4算法 编码 UTF-8 class 方式 #/usr/bin/python #coding=utf-8 import sys,os,hash...

Python3 入门教程 简单但比较不错

本文适合有Java编程经验的程序员快速熟悉Python 本文程序在windows xp+python3.1a1 测试通过. 本文提到的idle指python shell,即安装pytho...

Python KMeans聚类问题分析

Python KMeans聚类问题分析

今天用python实现了一下简单的聚类分析,顺便熟悉了numpy数组操作和绘图的一些技巧,在这里做个记录。 from pylab import * from sklearn.clus...

wxPython事件驱动实例详解

wxPython事件驱动实例详解

本文实例讲述了wxPython的事件驱动机制,分享给大家供大家参考。具体方法如下: 先来看看如下代码: #!/usr/bin/python # moveevent.py...