public FalseColourImage(double[,] underlyingData) { this.underlyingData = underlyingData.ArrayEnumerator(EnumerationOrder2D.RowMajor); width = underlyingData.GetLength(0); height = underlyingData.GetLength(1); Initialize(true); }
internal FalseColourImage(Rect bounds, double[,] underlyingData, bool newColourBar) { this.underlyingData = underlyingData.ArrayEnumerator(EnumerationOrder2D.ColumnMajor); width = underlyingData.GetLength(0); height = underlyingData.GetLength(1); Initialize(newColourBar); Bounds = bounds; }
/// <summary> /// Create an enumerator suitable for constructing images (i.e. travels along the first dimension, /// then the second). If not 2D, first element is null. /// </summary> /// <param name="enumerable"></param> /// <returns></returns> public static IEnumerable <double> ToImageEnumerator(IEnumerable <object> enumerable, out int xLength, out int yLength) { int[] dimensions = GeneralArray.GetDimensions(enumerable); xLength = dimensions[0]; yLength = 0; if (dimensions.Length > 2) { return(null); } // If this is a list of lists, then create enumerator, otherwise convert to a rectangular array first. // This gives better performance if not indexable or if this is a Numpy array. Type arrayType = enumerable.GetType(); if (dimensions.Length == 2 && arrayType.Name != "ndarray" && IsIListOfILists(enumerable)) { List <int> dimensionList = new List <int>(); IList parent = enumerable as IList; int minLength = int.MaxValue; int maxLength = int.MinValue; int count = parent.FastCount(); for (int i = 0; i < count; ++i) { IList child = parent[i] as IList; if (child == null) { minLength = 0; } else { minLength = Math.Min(minLength, child.Count); maxLength = Math.Max(maxLength, child.Count); } } yLength = maxLength; if (minLength == 0) { return(null); } else { return(Jagged2DImageEnumerable(parent, minLength, maxLength)); } } else if (dimensions.Length == 1) { return(Enumerable1D(enumerable)); } else { double[,] array = (double[, ])GeneralArray.ToDoubleArray(enumerable); yLength = dimensions[1]; return(array.ArrayEnumerator(EnumerationOrder2D.ColumnMajor)); } }
protected void CreateMesh(double[,] x, double[,] y, double[,] z) { CreateMesh(x.ArrayEnumerator(EnumerationOrder2D.ColumnMajor), y.ArrayEnumerator(EnumerationOrder2D.ColumnMajor), z.ArrayEnumerator(EnumerationOrder2D.ColumnMajor), x.GetLength(0), x.GetLength(1)); }
protected void CreateMesh(double[] x, double[] y, double[,] z) { CreateMesh(MathHelper.MeshGridX(x, y.Length), MathHelper.MeshGridY(y, x.Length), z.ArrayEnumerator(EnumerationOrder2D.ColumnMajor), x.GetLength(0), x.GetLength(1)); }