使用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快速搭建HTTP服务和文件共享服务的实例讲解

使用Python快速搭建HTTP服务和文件共享服务的实例讲解

SimpleHTTPServer SimpleHTTPServer是Python自带的一个HTTP服务类,通过使用它,我们能够在任意平台(Window,Linux,MacOS)快速搭建一...

在Django的URLconf中进行函数导入的方法

看下这个 URLconf: from django.conf.urls.defaults import * from mysite.views import hello, curre...

python 字典 setdefault()和get()方法比较详解

python 字典 setdefault()和get()方法比较详解

dict.setdefault(key, default=None) --> 有key获取值,否则设置 key:default,并返回default,default默认值为None...

解决Mac下首次安装pycharm无project interpreter的问题

Pycharm本身并不带编译器,所以第一次用需要自己下载编译器插件。 1、首先去 https://www.python.org/downloads/ 这个网址去下载对应的python版本...

Python matplotlib画图实例之绘制拥有彩条的图表

Python matplotlib画图实例之绘制拥有彩条的图表

生产定制一个彩条标签。 首先导入: import matplotlib.pyplot as plt import numpy as np from matplotlib import...