In this post we will be creating a Python script that will convert a Numpy array to an image, to do this we will be using the Python Imaging Library also known as PIL enabling us to image processing capabilities.
See the sample of Python code where we make use of PIL library to convert a Numpy array to an image and save it as a new file. To help us achieve this we utilize the ‘Image.fromarray()’ method which is used to create an image memory from an object exporting the array interface
from PIL import Image
img = Image.fromarray(img_array)
img.save('array_image.png')
Take a look at some of our other content around the Python programming language by clicking here.