python - 在 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)
解决方案
推荐阅读
- jsf - 无法从返回值导航到目录和查看页面
- javascript - 我已经在hackerrank中完成了这个代码,排名第二。在 javascript 中,但测试用例显示错误。下面是代码
- mysql - 从 MySQL 数据库中选择两行作为依赖于属性的行
- xamarin - 在 ListView.ItemSource 中点击触发命令
- python - 在哈希表 Django 中传递密码
- php - 意外的 Safari 页面加载计数行为
- php - PHP/CSS 如何实现棋盘格样式
- c++ - Clang++ 已更新,尽管它们位于包含目录中,但仍找不到某些标头
- vue.js - 纱线 monorepo 中的 rollup preserveModules 输出完整的项目路径
- javascript - 将变量从视图传递到控制器ajax