write numpy ndarray to Image

前端 未结 1 790
我寻月下人不归
我寻月下人不归 2021-02-12 01:57

I\'m trying to read a binary file (8 bit RGB tuples) in Python, do some conversion on it and then write it as a png image. I\'m doing the following:

typeinfo = n         


        
相关标签:
1条回答
  • 2021-02-12 02:48

    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.

    0 讨论(0)
提交回复
热议问题