// Creates a slice from the middle of the volume and maps all values in a single byte range static int[,] CreateSlice(float[,,] data) { int sizeX = data.GetLength(0); int sizeY = data.GetLength(1); int sizeZ = data.GetLength(2); int[,] slice = new int[sizeX, sizeY]; int depth = (int)sizeZ / 2; float min = data.Cast <float>().Min(); float max = data.Cast <float>().Max(); for (int i = 0; i < sizeX; i++) { for (int j = 0; j < sizeY; j++) { slice[j, i] = (int)Math.Round(Utils.Map(data[i, j, depth], min, max, 0, 255)); } } return(slice); }