imageio: 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.arrayuint8255HWCRGB

使用很简单

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.arrayuint8255HWCRGB

使用也很简单

from imageio import imread, imwrite
img1 = imread('color.jpg')
imwrite("./color.jpg", img1)
  • 9
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值