我是python的初学者,我有一个numpy文件,形状为(200,256,256)。我想用jpeg格式保存每个切片(:,256,256)。我如何使用for循环?提前感谢
我试过这个方法,但是对于形状为(256,256)的图像your text
from PIL import图像your text
import numpy as npyour text
A= np.load('image.npy',allow_pickle = True)your text
im = Image.fromarray(A)your text
im.save(“image.jpeg”)
但是我想用for循环来处理一个形状为(200,256,256)的文件,因为我有一些这样的文件。
1条答案
按热度按时间v2g6jxz61#
您可以在第一维上循环,提取图像切片并保存它们
图像将保存为
image_0.jpeg
、image_1.jpeg
等