结果 :
或者横向排列(图略)
import numpy as np
from PIL import Image
import os
root_dir = r"D:\urbanVitality_gdb\结果\00jpg_shap\XXX\XXXr"
paths = []
for item in os.listdir(root_dir):
paths.append(item)
print(paths)
img_array = ''
img = ''
for i, v in enumerate(paths):
if i == 0:
img = Image.open(os.path.join(root_dir,v)) # 打开图片
img_array = np.array(img) # 转化为np array对象
if i > 0:
img_array2 = np.array(Image.open(os.path.join(root_dir,v)))
# img_array = np.concatenate((img_array, img_array2), axis=1) # 横向拼接
img_array = np.concatenate((img_array, img_array2), axis=0) # 纵向拼接
img = Image.fromarray(img_array)
# 保存图片
img.save('test.png')