Read PGM image into a matrix