I need to read 64x64 pgm plain format image files and put the resulting values in a numpy matrix. I can do it only if I use Opencv and PIL functions to open the image, but the final numpy matrix yielded has 3-channel and the values returned are 0 and 255, instead of 0 and 1 (the image is binary). I also tried to use genfromtxt but it can't put the values in a numpy matrix.
I only want a 1 channel numpy matrix with 0 and 1's from the pgm image. How can I do that with python?