public static void SetTerrains(Pixel[,] matrix) { var bytes = matrix.ToByteArray(); foreach (var terrain in Terrains) { var height = Percentile(bytes, terrain.Percentile); terrain.SetHeight(height); } }