简体   繁体   English

将用plt.imshow打印的图像作为变量

[英]Take the image printed with plt.imshow as a variable

I'm using a custom library to transform a 1D signal to a 2D representation.我正在使用自定义库将一维信号转换为二维表示。 The output it's printed through plt.imshow(), used by a function inside of the library. output 它是通过 plt.imshow() 打印的,由库内的 function 使用。 I have the result but i don't want to save the picture locally.我有结果,但我不想在本地保存图片。 There is a way to get as a PIL image what is being used by plt.imshow?有一种方法可以获取 plt.imshow 正在使用的 PIL 图像吗?

EDIT: The answer is yes, as @Davide_sd is pointing out ax.images[idx].get_array() can be used to retrieve the data编辑:答案是肯定的,因为@Davide_sd 指出 ax.images[idx].get_array() 可用于检索数据

You can use ax.images[idx].get_array() to retrieve the data, after which you can use it on PIL.您可以使用ax.images[idx].get_array()检索数据,之后您可以在 PIL 上使用它。 ax is the axes where the image has been plotted. ax是绘制图像的轴。 idx is the index of the image you are interested: if you have plotted a single image, then idx=0 . idx是您感兴趣的图像的索引:如果您绘制了单个图像,则idx=0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM