Your array of "binary values" is an array of bytes?
If so, you can do (using Pillow) after resizing it:
from PIL import Image
im = Image.fromarray(arr)
And then im.show()
to see it.
If your array has only 0's and 1's (1-bit depth or b/w) you may have to multiply it to 255
im = Image.fromarray(arr * 255)
Here an example:
>>> arr = numpy.random.randint(0,256, 100*100) #example of a 1-D array
>>> arr.resize((100,100))
>>> im = Image.fromarray(arr)
>>> im.show()
Edit (2018):
This question was written in 2011 and Pillow changed ever since requiring to use the mode='L'
parameter when loading with fromarray
.
Also on comments below it was said arr.astype(np.uint8)
was needed as well, but I have not tested it
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…