I am trying to parse a folder with images into a numpy array. I want to obtain an array which looks like this:
import numpy as np
from sklearn.datasets import fetch_mldata
#load 70,000 MNIST images (28 X 28 pixels)
mnist = fetch_mldata("MNIST original")
X = mnist.data
print X.shape
Desired output:
(70000L, 784L)
This is what I tried:
from PIL import Image
import numpy
import matplotlib.pyplot as plt
import glob
#I have two colour images, each 64 X 64 pixels, in the folder
imageFolderPath = 'C:\\Users\\apples\\Desktop\\t-sne\\pics'
imagePath = glob.glob(imageFolderPath+'/*.JPEG')
im_array = numpy.array( [numpy.array(Image.open(imagePath[i])) for i in range(len(imagePath))] )
print im_array.shape
But it produces the following output:
(2L, 64L, 64L, 3L)
How can I obtain an array with the following dimensions:
(m, n)