我在目录中有一张图像列表。我正在尝试从每个图像中提取一列(图像大小为403 px x 1288 px x 3波段),并使用我想另存为图像的numpy append从这些列中依次构建一个数组。我正在尝试使用numpy和pillow从此附加数组制作图像。
我研究了Pillor,Numpy文档
# !/usr/bin/python3
import numpy as np
from numpy import array
from PIL import Image
import os, time, sys, subprocess
savpath =
'C:/data/marsobot/spectral/pushbroom/zwoexperiments/fullsuntheframes/'
os.chdir('C:/ data / marsobot / spectral / pushbroom / zwoexperiments / fullsuntheframes /')
toappendarr = np.empty ([403, 1288, 3])
for root, dirs, files in os.walk(".", topdown = False):
for name in files:
img = Image.open(name)
arr = array(img)
value = arr[:, 300, 1]
toappendarr = np.append(toappendarr, value, axis=1)
print(toappendarr.shape)
imgout = Image.fromarray(arr)
imgout.save("output.jpg")
我希望有一张照片,但我得到了:
ValueError:所有输入数组的维数必须相同