是否有在ruby中使用matplotlib.image的等价物
发布时间:2020-12-17 04:15:38 所属栏目:百科 来源:网络整理
导读:一直在尝试在jupyter笔记本中使用 Ruby.使用 Python我可以做到这一点 import matplotlib.image as mpimg 有没有人知道Ruby的等价物,我还没有能够在任何iRuby或sciruby文档中找到它? 为了澄清一点,在我的gemfile中我有这个 gem 'iruby'gem 'cztop'gem 'matpl
一直在尝试在jupyter笔记本中使用
Ruby.使用
Python我可以做到这一点
import matplotlib.image as mpimg 有没有人知道Ruby的等价物,我还没有能够在任何iRuby或sciruby文档中找到它? 为了澄清一点,在我的gemfile中我有这个 gem 'iruby' gem 'cztop' gem 'matplotlib' 但似乎无法访问我用于在python中使用的matplotlib的图像部分. 我试图找到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 非常感谢任何建议 解决方法
这是我可以在MacOSX上的jupyter笔记本中使用它的程度:
require 'matplotlib/pyplot' plt = Matplotlib::Pyplot image = plt.imread 'test.png' puts "This image's dimensions: #{image.shape}" plt.imshow(image) plt.show() 我使用你的Gemfile和额外的gem rbczmq来避免内核死亡(提示找到here): gem 'iruby' gem 'cztop' gem 'matplotlib' gem 'rbczmq' 请注意,我使用了.png,因为matplotlib只能在没有安装PIL的情况下本地读取PNG. 这是结果的样子: 在python版本中显示内联结果: 似乎是不可能的. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- c – getchar_unlocked()VS scanf()VS cin
- Swift2.0--文档学习笔记
- vb.net – 如何将进度报告从内部函数传递给main函数?
- 详解从零搭建 vue2 vue-router2 webpack3 工程
- React Native声明属性和属性确认
- ReactiveCocoa Unknown warning group ‘-Wreceiver-is-wea
- unity3d 不同平台载入XML文件的方法——IOS MAC Android
- flash – 这个[“instancename”]语法
- ruby-on-rails – has_many通过其他属性
- 利用Cocos2dx3.2制作重力版俄罗斯方块(Crazy Tetris)