PIL Image.fromarray( ... , mode="1" )
Hans Georg Schaathun
H.Schaathun at surrey.ac.uk
Sat Oct 31 11:43:45 EDT 2009
Does anyone know how to save two-tone images represented as
numpy arrays? I handle grayscale images by converting to
PIL Image objects (mode="L") and then use the PIL save method,
but I cannot make this work with mode="1".
I have tried both boolean arrays and uint8 arrays (mod 2).
In both cases I get an image which is predominantly black,
with thin white stripes (possibly for every 8 pixels).
If, instead, multiply my (mod 2) image by 255, and then
convert with mode="L", I get the expected random-noise-looking
image.
Does anyone have any ideas? What do I do wrong? What is the
right/best way to save/convert two-tone images?
I have not managed to find proper documentation for the
Image.fromarray() method; the docstring seems to be empty )-:
TIA
:-- Hans Georg
More information about the Python-list
mailing list