I want to convert an rgb image to 2d matrix in gray. How can I do this using loops and PIL? I don\'t want to use a canned function. How can I do that ?