@[TOC](imread & imwrite)
1. 安装
imageio 官网:https://imageio.readthedocs.io/en/stable/
安装:pip install imageio
2. 读写操作
2.1 imread
imageio.imread(uri)
- uri:路径
从指定路径读取一张图片
Reads an image from the specified file. Returns a numpy array
Note that the image data is returned as-is, and may not always have a dtype of uint8 (and thus may differ from what e.g. PIL returns).
返回属性为 np.array
、uint8
、255
、HWC
、RGB
使用很简单
from imageio import imread
img1 = imread('color.jpg')
2.2 imwrite
imageio.imwrite(uri, im)
- uri:要存储的路径
- im:保存的图片 The image data. Must be HxW, HxWx3 or HxWx4.
保存图片到特定路径 uri
Write an image to the specified file.
类似于 imread 的镜像操作,读入的是什么类型,保存时也是什么类型,即np.array
、uint8
、255
、HWC
、RGB
使用也很简单
from imageio import imread, imwrite
img1 = imread('color.jpg')
imwrite("./color.jpg", img1)
本文由 Yonghui Wang 创作,采用
知识共享署名4.0
国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为:
Dec 19, 2024 12:13 pm