You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
622 B
23 lines
622 B
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') |