import matplotlib.image as img
import os
from shutil import copyfile
path = 'D:\_Data\GTC_t1'
savePath = 'D:\_Data\GTC_t1_selected'
img_list = os.listdir(path)
for i in img_list:
t1 = img.imread(path+'\\'+i, 'gray')
if t1.shape == (256, 170):
img.imsave(savePath+'\\'+i, t1, cmap='gray') # 1
copyfile(path+'\\'+i,savePath+'\\'+i) # 2
用matplotlib复制.png,源图像(256,170),保存图像(256,170,4)
需要用copyfile来保持单通道
Python 图像保存与复制
推荐阅读
- Oracle在中国的裁员暗示了中国的云服务市场什么?
- 灰度共生矩阵
- Linux 常用命令
- [springboot jpa] [bug] Could not open JPA EntityManager for transaction
- [spring cloud] [error] java.lang.IllegalStateException: Only one connection receive subscriber allowed.
- [spring jpa] 解决SimpleJpaRepository的多数据源配置问题
- [ethereum源码分析](3) ethereum初始化指令
- [ethereum源码分析](4) ethereum运行开启console
- [ethereum源码分析](5) 创建新账号
- ReentrantLock源码赏析