x = Image.open('im1.jpg', 'r')
x = x.convert('L')
y = np.asarray(x.getdata(), dtype=np.float64).reshape((x.size[1], x.size[0]))
Converting an RGB image to grayscale and manipulating the pixel data in python