Sometimes, we want to convert a PIL Image into a numpy array with Python.
In this article, we’ll look at how to convert a PIL Image into a numpy array with Python.
How to convert a PIL Image into a numpy array with Python?
To convert a PIL Image into a numpy array with Python, we call numpy.array
with the PIL image.
For instance, we write
pix = numpy.array(pic)
to call numpy.array
with the pic
PIL image object to return an array with the pixel data of pic
.
Conclusion
To convert a PIL Image into a numpy array with Python, we call numpy.array
with the PIL image.