I have a tiff image of shape (6,500,500)
and I read it as numpy array
>>>type(image)
<type 'numpy.ndarray'>
>>> image.shape
(6, 500, 500)
I transpose it to make (500,500,6)
image = image.transpose((1, 2, 0))
>>> image.shape
(500, 500, 6)
Then when I try to transform it into PIL image
>>> image = Image.fromarray(image)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/dfd/env27/local/lib/python2.7/site-packages/PIL/Image.py", line 2419, in fromarray
raise TypeError("Cannot handle this data type")
TypeError: Cannot handle this data type
>>
I get the above error.
My array is uint8
image
array([[[122, 104, 77, 255, 145, 71],
[123, 102, 77, 252, 140, 71],
[122, 99, 72, 249, 123, 57],
[[133, 113, 90, 106, 45, 22],
[129, 98, 77, 96, 36, 18],
[126, 99, 77, 102, 39, 18],
...,
[124, 105, 76, 255, 120, 54],
[123, 104, 74, 254, 114, 51],
[119, 102, 69, 8, 117, 51]]], dtype=uint8)