from PIL import Image
from pylab import *
file=open('C:/Users/root/Desktop/1.txt')
im=array(Image.open('C:/Users/root/Desktop/1.png'))
imshow(im)
sourceInLine=file.readlines()
pointsposi=[]
for line in sourceInLine:
temp1=line.strip('\n')
temp2=temp1.split( )
pointsposi.append(temp2)
#每行都是横坐标,纵坐标
for i in range(0,len(pointsposi)):
x=float(pointsposi[i][0])
y=float(pointsposi[i][1])
plot(x, y, 'r.')
axis('off')
show()
【备忘】python从txt中读取横纵坐标并把点标在图片上
最新推荐文章于 2024-01-03 23:28:33 发布
本文介绍如何使用Python的PIL和PyLab库进行图像读取与标注,通过读取图片文件和文本文件中记录的坐标信息,在图像上标注出特定的点,实现了图像数据的可视化处理。

950





