2024-05-12 17:07:13 发布
网友
这一定很简单,但是如果不使用urllib模块并手动获取远程文件,我现在想不通
我想用远程图像覆盖plot(比如“http://matplotlib.sourceforge.net/_static/logo2.png”),而imshow()和imread()都不能加载图像。
imshow()
imread()
你知道哪个功能可以加载远程图像吗?
你可以用这个代码来做
from matplotlib import pyplot as plt a = plt.imread("http://matplotlib.sourceforge.net/_static/logo2.png") plt.imshow(a) plt.show()
这在python 3.5的笔记本中对我很有用:
from skimage import io import matplotlib.pyplot as plt image = io.imread(url) plt.imshow(image) plt.show()
确实很容易:
import urllib2 import matplotlib.pyplot as plt # create a file-like object from the url f = urllib2.urlopen("http://matplotlib.sourceforge.net/_static/logo2.png") # read the image file in a numpy array a = plt.imread(f) plt.imshow(a) plt.show()
你可以用这个代码来做
这在python 3.5的笔记本中对我很有用:
确实很容易:
相关问题 更多 >
编程相关推荐