用imageio读灰度图

import scipy.misc 
img_array = scipy . misc . imread ( image_file_name , flatten = True)

在scipy 1.3.1版本下读取灰度图报错:

AttributeError: module 'scipy.misc' has no attribute 'imread'

查明原因:

imread was deprecated in SciPy 1.0.0, and is removed in 1.2.0. Use imageio.imread instead.

可以用 imageio 库代替:

github地址:https://github.com/imageio/imageio

import imageio
img_array = imageio.imread ( image_file_name , as_gray=True )

Transitioning from Scipy’s imread 指导文档

https://imageio.readthedocs.io/en/stable/scipy.html

你可能感兴趣的:(python)