首页 > 解决方案 > 在 python 中将多个图像保存在单个 TIFF 文件中

问题描述

我有多个图像,我想将每 22 个图像保存在 TIFF 文件中。我发现我应该先保存图像然后加载它们以保存在 TIFF 文件中。我想保存每张cropped图像,直到文件被 22 张图像击倒。我正在尝试超过 2 周的时间来寻找如何做到这一点。

任何帮助,将不胜感激。

代码

for i, ci in enumerate(coefficients):
        plt.imshow(ci.reshape(1, -1), extent=[0, 3844, i + 0.5, i +1.5], cmap='inferno', aspect='auto', interpolation='nearest')
        plt.ylim(0.5, len(coeffs)-0.5) 
        plt.yticks(range(1, len(coeffs)), ['cD5', 'cD4', 'cD3', 'cD2', 'cD1'])  

plt.axis('off')
 
plt.savefig(FirstPartPathOutput+SecondPartPathOutput+'/spec_'+isPreictal+'_'+str(nSpectogram+1)+'_'+str(k)+'.png')
for image in filePaths :
        image=Image.open(filePath)
        image.load()
        imageSize = image.size
   # remove alpha channel
        invert_im = image.convert("RGB") 
    # invert image (so that white is 0)
        invert_im = ImageOps.invert(invert_im)
        imageBox = invert_im.getbbox()
        cropped=image.crop(imageBox)

标签: pythonimageappendpython-imaging-librarytiff

解决方案


推荐阅读