簡體   English   中英

我如何 plot 一個 numpy RGB 陣列?

[英]How do I plot a numpy rgb array?

How can I plot a numpy array with dimensions (x, y, r, g, b) in one image in Python? 基本上,我必須將這三個通道轉換為一個?

安裝枕頭:

python -m pip install Pillow

假設您的 numpy 陣列的形狀實際上是 (x, y, (r, g, b)) 而不是不太可能的 (x, y, r, g, b),並且為了示例而命名為arr ,運行python:

import PIL.Image
im = PIL.Image.fromarray(arr)
im.save('out.png')

然后 plot 您的 output 圖像文件使用任何常用方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM