PIL: using fromarray() with binary data and writing coloured text

前端 未结 1 936
天命终不由人
天命终不由人 2020-12-15 22:24

I\'ve a basic problem with Python\'s library PIL. I have some .txt files containing only 0 and 1 values arranged in matrices. I have transf

相关标签:
1条回答
  • 2020-12-15 22:45

    You can get a RGB image from a monochromatic one like this:

    from PIL import Image
    from numpy import eye                                                            
    arr = (eye(200)*255).astype('uint8') # sample array
    im = Image.fromarray(arr) # monochromatic image
    imrgb = im.convert('RGB') # color image
    imrgb.show()
    
    0 讨论(0)
提交回复
热议问题