private void clamp(double[][] noise) {
        int w = noise.length;
        int h = noise[0].length;
        double max = -1, min = 1;
        for (int i = 0; i < w; i++) {
            for (int j = 0; j < h; j++) {
                max = Math.max(max, noise[i][j]);
                min = Math.min(min, noise[i][j]);
            }
        }
        double range = max - min;
        for (int i = 0; i < w; i++) {
            for (int j = 0; j < h; j++) {
                noise[i][j] = (noise[i][j] - min) / range;
            }
        }
    }