Reputation: 3239
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?
Upvotes: 1
Views: 805
Reputation: 97691
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)
Upvotes: 3