Answer by aravinda_gn for How to convert a NumPy array to PIL image applying...
input = numpy_imagenp.uint8 -> converts to integersconvert('RGB') -> converts to RGBImage.fromarray -> returns an image object from PIL import Image import numpy as np PIL_image =...
View ArticleAnswer by Shital Shah for How to convert a NumPy array to PIL image applying...
The method described in the accepted answer didn't work for me even after applying changes mentioned in its comments. But the below simple code worked:import matplotlib.pyplot as...
View ArticleAnswer by fraxel for How to convert a NumPy array to PIL image applying...
Quite a busy one-liner, but here it is:First ensure your NumPy array, myarray, is normalised with the max value at 1.0.Apply the colormap directly to myarray.Rescale to the 0-255 range.Convert to...
View ArticleHow to convert a NumPy array to PIL image applying matplotlib colormap
I have a simple problem, but I cannot find a good solution to it.I want to take a NumPy 2D array which represents a grayscale image, and convert it to an RGB PIL image while applying some of the...
View Article