public static void savePGM ( GrayU8 gray , String fileName ) throws IOException { File out = new File ( fileName ) ; DataOutputStream os = new DataOutputStream ( new FileOutputStream ( out ) ) ; String header = String . format ( "P5\n%d %d\n255\n" , gray . width , gray . height ) ; os . write ( header . getBytes ( ) ) ; os . write ( gray . data , 0 , gray . width * gray . height ) ; os . close ( ) ; }
Saves an image in PGM format .