Here you can find the source of array2multidim(float[] arr, int width, int height)
Parameter | Description |
---|---|
width | a parameter |
height | a parameter |
public static float[][] array2multidim(float[] arr, int width, int height)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 Jay Unruh, Stowers Institute for Medical Research. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v2.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html ******************************************************************************/ public class Main { /********************** * converts a 1D image array to and array of rows * @param arr: the array/*www . j a v a 2 s. c om*/ * @param width * @param height * @return a 2D array with [height][width] indices */ public static float[][] array2multidim(float[] arr, int width, int height) { float[][] temp = new float[height][width]; int temp2 = 0; for (int i = 0; i < height; i++) { System.arraycopy(arr, temp2, temp[i], 0, width); temp2 += width; } return temp; } }