我一直在尝试在jupyter笔记本中使用Ruby语言。使用Python时,我可以这样做:
import matplotlib.image as mpimg
有人知道 Ruby 的等效方法吗?我在 iRuby 或 sciruby 的文档中没有找到它。
稍微澄清一下,在我的 gemfile 中我有这个:
gem 'iruby'
gem 'cztop'
gem 'matplotlib'
但是我似乎无法访问我在Python中使用的matplotlib
的image
部分。
我正在尝试找到Ruby版本,就像在Python中我会这样写:
#importing some useful packages
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
...
%matplotlib inline
#reading in an image
image = mpimg.imread('test_images/solidWhiteRight.jpg')
#printing out some stats and plotting
print('This image is:', type(image), 'with dimesions:', image.shape)
plt.imshow(image) #call as plt.imshow(gray, cmap='gray') to show a grayscaled image
非常感谢您提供的建议。
Python具有灵活的命名空间处理
部分以及这个答案。 - Maciej NędzaIRuby.display png.to_blob, mime: "image/png"
将其图像放入 iRuby 中)。 - Amadan