[英]Display an numpy array with PIL
I want to display a (512, 512)
numpy 2d-array of uint16
values with PIL. 我想用PIL显示
uint16
值的(512, 512)
numpy二维数组。 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
选项和其他选项的信息?
The question is solved using the option 'I;16' in the Image.fromarray function. 使用Image.fromarray函数中的选项“I; 16”解决了这个问题。 Many thanks.
非常感谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.