Python 图像保存与复制

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来保持单通道
posted @ 2020-01-03 14:33  Junzhao  阅读(3837)  评论(0编辑  收藏  举报