Java Integer Create toInt(double[][] doubles)

Here you can find the source of toInt(double[][] doubles)

Description

to Int

License

Open Source License

Declaration

private static int[][] toInt(double[][] doubles) 

Method Source Code

//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;
    }
}

Related

  1. toInt(double[] arr)
  2. toInt(double[] array)
  3. toInt(double[] layer)
  4. toInt(double[] v)
  5. toInt(double[][] data)
  6. toInt(final Boolean value)
  7. toInt(final byte b)
  8. toInt(final byte b)
  9. toInt(final byte[] buffer, final int offset, final int length)