在python中读取图像 [英] Reading images in python

查看:89
本文介绍了在python中读取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在python中读取png图像. scipy中的imread函数正在已弃用,他们建议使用imageio库.

I am trying to read a png image in python. The imread function in scipy is being deprecated and they recommend using imageio library.

但是,我宁愿将对外部库的使用限制为scipynumpymatplotlib库.因此,使用imageioscikit image对我来说不是一个好选择.

However, I am would rather restrict my usage of external libraries to scipy, numpy and matplotlib libraries. Thus, using imageio or scikit image is not a good option for me.

在python或scipynumpymatplotlib中是否有任何方法可以读取不被弃用的图像?

Are there any methods in python or scipy, numpy or matplotlib to read images, which are not being deprecated?

推荐答案

您可以使用matplotlib(如matplotlib

With matplotlib you can use (as shown in the matplotlib documentation)

import matplotlib.pyplot as plt
import matplotlib.image as mpimg

img=mpimg.imread('image_name.png')

并根据需要绘制图像

imgplot = plt.imshow(img)

这篇关于在python中读取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆