0

How can I plot a numpy array with dimensions (x, y, r, g, b) in one image in Python? Basically, I have to convert these three channels to one?

1
  • You want the array to be 3-dimensional: rows, columns, channels. Commented Nov 19, 2019 at 1:18

1 Answer 1

1

Install Pillow:

python -m pip install Pillow

Assuming your numpy array's shape is in fact (x, y, (r, g, b)) rather than the unlikely (x, y, r, g, b), and for the sake of the example is named arr, run in python:

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

then plot your output image file with any usual means.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.