Bash script to convert an image to a matrix, using grayscale information (0=black, 255=white)