To apply a colormap to an image, we first normalize the array with a max value of 1. It applies the plasma colormap from the Matplotlib package.
![400x400 image converter 400x400 image converter](http://www.fmwconcepts.com/misc_tests/vignette/vignette_0_0.jpg)
Convert a NumPy Array to PIL Image Python With the Matplotlib Colormap import numpy as np Here, we create a NumPy array of size 400x400 with random numbers ranging from 0 to 255 and then convert the array to an Image object using the omarray() function and display the image using show() method. import numpy as npĪrray = np.random.randint(255, size=(400, 400),dtype=np.uint8) We use the omarray() function to convert the array back to the PIL image object and finally display the image object using the show() method. We then convert this image object to a NumPy array using the numpy.array() method. It will read the image lena.png in the current working directory using the open() method from the Image and return an image object. Convert a NumPy Array to PIL Image in Python import numpy as np
![400x400 image converter 400x400 image converter](https://www.electronicscomp.com/image/cache/catalog/hexin-rs232-to-rs485-serial-port-data-interface-adapter-converter-800x800.jpg)
The omarray() function takes the array object as the input and returns the image object made from the array object. The Python Imaging Library ( PIL) is a library in Python with various image processing functions. This tutorial explains how we can convert the NumPy array to a PIL image using the omarray() from the PIL package. Display Multiple Images in One Figure Correctly in Matplotlib.Save Figures Identical to the Displayed Figures in Matplotlib.Display an Image in Grayscale in Matplotlib.Display an Image With Matplotlib Python.Convert a NumPy Array to PIL Image in Python.Display Greek Letters in Python Matplotlib.Set the Figure Title and Axes Labels Font Size in Matplotlib.Custom Colormap Using Python Matplotlib.Set Plot Background Color in Matplotlib.