Skip to content Skip to sidebar Skip to footer

Pil: Using Fromarray() With Binary Data And Writing Coloured Text

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 transformed the 'binary' data in an image with th

Solution 1:

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()

Post a Comment for "Pil: Using Fromarray() With Binary Data And Writing Coloured Text"