write numpy ndarray to Image write numpy ndarray to Image numpy numpy

write numpy ndarray to Image


Image needs unsigned bytes, i1 means signed bytes. If the sign is irrelevant (all values between 0 and 127), then this will work:

svimg=im.fromarray(data.astype('uint8'))

If you need the full range 0-255, you should use 'uint8' throughout.