1

I have an array of pixels

np.shape(pred2)
Out[35]: (3000, 3, 32, 32)

It has 3000 images, 3 values rgb and is 32*32 in size for each image. I want to create an image from this.

Here is what I have so far:

img = Image.new( 'RGB', (32,32), "black") # create a new black image
pixels = img.putdata(pred2[1,:])

Can anyone give me a hand here as to what I am doing wrong?

1
  • 1
    What seems to be the problem? What output/error message do you get? Commented Apr 26, 2016 at 15:57

1 Answer 1

3

Images are shape (h, w, 3), not (3, h, w). You need to permute your axes accordingly. Depending on whether you care about width vs height, it appears you can just do:

im = pred2[1].T
scipy.misc.imsave('the_image_file.png', im)
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.