A图:
B图:
拼接后:
import os
import numpy as np
import PIL
from PIL import Image
dirname_read_A = "D:\paper\\3low_light_image\dataset\\train_translste_model_data\image_translate\\trainA_concat\\"
names_A=os.listdir(dirname_read_A)
names_A.sort(key= lambda x:int(x[:-6]))
dirname_read_B = "D:\paper\\3low_light_image\dataset\\train_translste_model_data\image_translate\\trainB_concat\\"
names_B=os.listdir(dirname_read_B)
names_B.sort(key= lambda x:int(x[:-6]))
k = 1
for i in range(2940):
imgA = dirname_read_A + names_A[i]
imgB = dirname_read_B + names_B[i]
imgA = Image.open(imgA)
imgB = Image.open(imgB)
img_array_A = np.array(imgA)
img_array_B = np.array(imgB)
img_array_AB = np.hstack((img_array_A, img_array_B))
# print(img_array_A.shape)
# print(img_array_B.shape)
print(img_array_AB.shape)
imgAB = Image.fromarray(img_array_AB.astype('uint8')).convert('RGB')
imgAB.save(str(k) + '.jpg')
k = k + 1