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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.