次のURLが参考になる。
How to convert a NumPy array to PIL image applying matplotlib colormap[例] from PIL import Image from matplotlib import cm import cv2 import matplot.pyplot as plt img = np.asarray(img) # numpy array img = np.clip(np.nan_to_num(img), 0.0, 1.0) # ensure [0,1] img = Image.fromarray(np.uint8(cm.jet(img)*255)) # apply colormap and rescale between [0,255] # if you want to resize the image img = np.asarray(img.convert('RGB')) img = cv2.resize(img,(HEIGHT,WIDTH),interpolation=cv2.INTER_CUBIC) # display plt.imshow(img) plt.show()