これは簡単なはずですが、urllib モジュールを使用してリモート ファイルを手動でフェッチしないと、今のところ方法がわかりません。
プロットをリモート画像(「http://matplotlib.sourceforge.net/_static/logo2.png」としましょう)でオーバーレイしたいのですが、画像を読み込めませimshow()
ん。imread()
リモート画像の読み込みを可能にする機能はありますか?
これは簡単なはずですが、urllib モジュールを使用してリモート ファイルを手動でフェッチしないと、今のところ方法がわかりません。
プロットをリモート画像(「http://matplotlib.sourceforge.net/_static/logo2.png」としましょう)でオーバーレイしたいのですが、画像を読み込めませimshow()
ん。imread()
リモート画像の読み込みを可能にする機能はありますか?
それは確かに簡単です:
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 のノートブックで機能します。
from skimage import io
import matplotlib.pyplot as plt
image = io.imread(url)
plt.imshow(image)
plt.show()
このコードでそれを行うことができます。
from matplotlib import pyplot as plt
a = plt.imread("http://matplotlib.sourceforge.net/_static/logo2.png")
plt.imshow(a)
plt.show()