Convert image to a matrix in python Convert image to a matrix in python numpy numpy

Convert image to a matrix in python


scipy.misc.imread() will return a Numpy array, which is handy for lots of things.


Up till now no one told about matplotlib.image:

import matplotlib.image as imgimage = img.imread(file_name)

Now the image would be a 3D numpy array

print image.shape

Would be something like: (317, 504, 3)