I want to display a (512, 512) numpy 2d-array of uint16 values with PIL. If I wrote a function:
def display_PIL(nparray):
image = Image.fromarray(nparray)
image.show()
I get an error message:
Cannot handle this data type.
But if I add:
def display_PIL(nparray):
image = Image.fromarray(nparray,'L')
image.show()
it displays the image, but I have only the upper-right quarter of the image. Is there a solution to have the complete image? Where can I find information regarding the L option and other options?
'L'type is strictly 8-bit so you should use'I;16'instead. See pythonware.com/library/pil/handbook/concepts.htm