Here you can find the source of toInt(double[][] doubles)
private static int[][] toInt(double[][] doubles)
//package com.java2s; // GNU Affero General Public License as published by the Free Software Foundation, either version public class Main { private static int[][] toInt(double[][] doubles) { final int width = doubles.length; final int height = doubles[0].length; double max = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { max = Math.max(max, doubles[x][y]); }/* w ww . ja va2 s . co m*/ } int[][] ints = new int[width][height]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { ints[x][y] = (int) Math.rint((doubles[x][y] * 255) / max); } } return ints; } }