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