記錄讀取和保存圖像的幾種方式
1、讀取圖片
1.1、使用cv2
讀取圖片,注意:opencv打開路徑中不能有中文?。?!
img = cv2.imread(img_path+'/'+name)
1.2、使用rasterio
讀取遙感影像
img = rasterio.open(img_path+'/images/'+name).read()
1.3、使用Image
讀取圖像
image = Image.open(os.path.join(img_path, name))
2、保存圖片
2.1、使用cv2
保存圖片
cv2.imwrite(os.path.join(save_dir,name.replace('tif','png')),img)
2.2、使用numpy保存
img = rasterio.open(img_path+'/images/'+name).read()
img.save(save_path+'/'+filename +'.tif')
2.3、使用plt保存
image = Image.open(os.path.join(img_path, name))
plt.imshow(image)
plt.show()
plt.savefig('001.png')
參考:
https://blog.csdn.net/xzm961226xzm/article/details/120951317
https://blog.csdn.net/weixin_50727642/article/details/119743762文章來源:http://www.zghlxwxcb.cn/news/detail-509580.html
https://www.cnblogs.com/cgmcoding/p/14244735.html文章來源地址http://www.zghlxwxcb.cn/news/detail-509580.html
到了這里,關(guān)于Python保存圖像的幾種方式的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!