【Python】图像数据读写利器 -- imageio

Backto Python Index

极简化的图像数据读写库,官方文档 .

两大特性

  1. 依赖少
Python 3.5+
Numpy
Pillow

有扩展包,历史版本 Imageio version 2.6.x supports Python 2.7 and 3.4.

  1. 接口简洁
import imageio
im = imageio.imread('imageio:chelsea.png')  # read a standard image
im.shape  # im is a numpy array
>> (300, 451, 3)
imageio.imwrite('~/chelsea-gray.jpg', im[:, :, 0])

API style

imread() and imwrite() - for single images
mimread() and mimwrite() - for image series (animations)
volread() and volwrite() - for volumetric image data
get_reader() and get_writer() - for more control (e.g. streaming or compression)
See the user api for more information

最近 ImageIO 的应用越来越广泛,一大原因就是 scipy.misc.imread is deprecated! imread is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use imageio.imread instead

# old
#import scipy.misc 
#input_image = imread(IMG_PATH) 

# new
import imageio
input_image = imageio.imread(IMG_PATH)

你可能感兴趣的:(python,imageio,人工智能)