python - 如何在不使用 imageio 或 scikit 图像的情况下将图像读入脚本?

标签 python image scipy

我正在尝试在 python 中读取 png 图像。 scipy 中的 imread 函数是 deprecated他们建议使用 imageio 库。

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

python 或 scipynumpymatplotlib 中是否有任何方法可以读取图像,这些方法不会被弃用?

最佳答案

你可以使用matplotlib(如matplotlib documentation所示)

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

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

如果需要,还可以绘制图像

imgplot = plt.imshow(img)

关于python - 如何在不使用 imageio 或 scikit 图像的情况下将图像读入脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48729915/

相关文章:

python - 使用 python 创建 Mysql 数据库 - 不断收到 1064 错误(...在 '%s' 附近使用正确的语法)

python - 在 Python 中使用过滤函数

python - 从 Amazon S3、AWS CLI 或 Boto3 下载?

c++ - 从 bmp(或其他图像类型)中提取第 "n"个图像

javascript - 如何使用javascript中的箭头键在 Canvas 上移动图像

python - 在 cygwin/win7 上安装 scipy

python - 从 MySQL 获取行值

python - Numpy:通过组合先前数组的子集来创建新数组

python - `ValueError: A value in x_new is above the interpolation range.` - 除了不提升值还有什么其他原因?

html - 将背景图像以其原始宽度和高度的 50% 居中