How to convert an image to an array in Python

Converting an image to an array represents an image as a numpy.ndarray of RGB pixel values.

Solution for How to convert an image to an array in Python : You can use PIL.Image.Image.getdata() to convert an image to an array Call PIL.Image.Image.getdata() to convert PIL.Image.Image to a sequence of pixel values. Use numpy.array(object) to convert the previous result object to a numpy.ndarray.


how-to-convert-an-image-to-an-array-in-python