imread & imwrite
安装
imageio官网:https://imageio.readthedocs.io/en/stable/
安装:pip install imageio
读写操作
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. 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)