简体   繁体   English

有没有办法从包含 RGB 值的元组列表列表中创建图像?

[英]Is there a way to create an image from list of lists of tuples containing RGB values?

I am trying to turn a list of rgb values into an image.我正在尝试将 rgb 值列表转换为图像。 For the sake of simplicity I will show an example of what I am trying to do instead of my actual code.为了简单起见,我将展示一个我正在尝试做的事情的例子,而不是我的实际代码。

I need to turn this list:我需要翻一下这个清单:

[[(255, 255, 0), (128, 128, 128), (211, 211, 211)], [(0, 0, 255), (255, 165, 0), (0, 255, 0)], [(128, 0, 0), (0, 255, 0), (255, 215, 0)]]

Into an image using python.使用python转换为图像。

I am trying to do this using the pillow module but because of the nature of the way the rgb values are stored, i'm struggling to understand how I can go about this.我正在尝试使用枕头模块来做到这一点,但由于 rgb 值的存储方式的性质,我正在努力理解我如何做到这一点。

You can use imgshow from matplotlib您可以使用imgshow从matplotlib

import matplotlib.pyplot as plt

img = [[(255, 255, 0), (128, 128, 128), (211, 211, 211)], [(0, 0, 255), (255, 165, 0), (0, 255, 0)], [(128, 0, 0), (0, 255, 0), (255, 215, 0)]]
plt.imshow(img);

Out:出去:

图像

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

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