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?
The question is solved using the option 'I;16' in the Image.fromarray function. Many thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With