parent
dad9e1b885
commit
60b5328f9f
@ -0,0 +1,23 @@
|
|||||||
|
from PIL import Image
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
# 读取文件中的坐标
|
||||||
|
with open('white_coords.txt') as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
|
||||||
|
coordinates = [tuple(map(int, line.strip().split(','))) for line in lines]
|
||||||
|
|
||||||
|
# 获取坐标的最大值和最小值来确定图像的大小
|
||||||
|
max_x = max(coordinates, key=lambda x: x[0])[0]
|
||||||
|
max_y = max(coordinates, key=lambda x: x[1])[1]
|
||||||
|
|
||||||
|
# 创建一个全黑的图像
|
||||||
|
img = Image.new('L', (max_x+1, max_y+1), 'black')
|
||||||
|
pixels = img.load()
|
||||||
|
|
||||||
|
# 将文件中的坐标点设为白色
|
||||||
|
for x, y in coordinates:
|
||||||
|
pixels[x, y] = 255
|
||||||
|
|
||||||
|
# 保存图像
|
||||||
|
img.save('output_image.png')
|
Loading…
Reference in new issue