I want to stack several small images into one big. This code works, but gives mi warning:
FutureWarning: arrays to stack must be passed as a "sequence" type such as list or tuple. Support for non-sequence iterables such as generators is deprecated as of NumPy 1.16 and will raise an error in the future.
Code:
import PIL
from PIL import Image
import numpy as np
# my images are 2000x2000 resolution, but you can place here any photos with the same width and height
list_im = ['1.jpeg', '2.jpeg', '3.jpeg', '4.jpeg']
# reading images to columns:
imgsv = [PIL.Image.open(i) for i in reversed(list_im[::2])]
imgsv2 = [PIL.Image.open(i) for i in reversed(list_im[1::2])]
# vertical stacking:
imgs_comb1 = np.vstack((np.asarray(i) for i in imgsv))
imgs_comb1 = PIL.Image.fromarray(imgs_comb1)
imgs_comb1.save('V1.jpg')
imgs_comb2 = np.vstack((np.asarray(i) for i in imgsv2))
imgs_comb2 = PIL.Image.fromarray(imgs_comb2)
imgs_comb2.save('V2.jpg')
# horizontal stacking:
imgsv3 = [imgs_comb1, imgs_comb2]
imgs_comb3 = np.hstack((np.asarray(i) for i in imgsv3))
imgs_comb3 = PIL.Image.fromarray(imgs_comb3)
imgs_comb3.save('V1.jpg')
P.S. In the future I will need to stack more than 4 images (i.e. 25)
I will be very grateful for some solution on this problem! :D
question from:
https://stackoverflow.com/questions/65894101/images-stacking-in-numpy-futurewarning-arrays-to-stack-must-be-passed-as-a-s 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…