Convert image to a matrix in python
Up till now no one told about matplotlib.image:
import matplotlib.image as img
image = img.imread(file_name)
Now the image would be a 3D numpy array
print image.shape
Would be something like: (317, 504, 3)
scipy.misc.imread()
is deprecated now. We can use imageio.imread
instead of that to read it as a Numpy array
scipy.misc.imread()
will return a Numpy array, which is handy for lots of things.