from PIL import Image
Image.fromarray(np.uint8(img))
注意img如果是uint16的矩阵而不转为uint8的话,Image.fromarray这句会报错
所以加上np.uint8(img)很有必要
File “/usr/local/lib/python2.7/site-packages/PIL/Image.py”, line 1884, in fromarray
raise TypeError(“Cannot handle this data type”)
TypeError: Cannot handle this data type