TypeError: Cannot handle this data type: (1, 1, 3), < f8 and Image.fromarray() function after conversion image distortion

The error shows 1.

The error shows 2.

(Predicted as RGB image, turned out distorted as black)

Reason: Use matplotlib.image to read in the image array. Note that the array read here is of float32 type, the range is 0-1, and the PIL.Image data is uinit8 type, and the range is 0-255

(can be analyzed according to python PIL image processing - jujua - Blog Park (cnblogs.com) )

Change plan:

image=Image.fromarray(image)——>image=Image.fromarray(np.uint8(image*255))

Guess you like

Origin blog.csdn.net/weixin_45866058/article/details/124838012