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来保持单通道


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM