Class KDTreeData<T>

java.lang.Object
net.imglib2.kdtree.KDTreeData<T>
Type Parameters:
T - the type of values stored in the tree.

public class KDTreeData<T> extends Object
Stores the KDTree data, that is, positions and values.

Positions are stored in either FLAT or NESTED layout. With NESTED layout, positions are stored as a nested double[][] array where positions[d][i] is dimension d of the i-th point. With FLAT layout, positions are stored as a flat double[] array, where positions[d + i*n] is dimension d of the i-th point, with n the number of dimensions.

Values (of type T) are stored as either a 1D RandomAccessibleInterval<T>, or a List<T>. Individual values can be accessed by valuesSupplier().get().apply(i). valueSupplier().get() returns a reusable IntFunction<T>. Here T maybe a proxy that is reused in subsequent apply(i).

values() returns all values as a 1D RandomAccessibleInterval<T>. (If data is stored as List<T>, it is wrapped into a ListImg.)

  • Field Details

  • Constructor Details

  • Method Details

    • positions

      public KDTreePositions positions()
    • getType

      public T getType()
    • values

      public RandomAccessibleInterval<T> values()
      Get the values as a 1D RandomAccessibleInterval, for serialization. (If the underlying storage is a List<T>, it will be wrapped as a ListImg.)
    • valuesSupplier

      public Supplier<IntFunction<T>> valuesSupplier()
      Get a Supplier that return IntFunction<T> to provide values for a given node indices. If the returned IntFunction<T> is stateful (T maybe a proxy that is reused in subsequent apply(i)} every Supplier.get() creates a new instance of the IntFunction<T>.
    • boundingBox

      public RealInterval boundingBox()
    • create

      public static <L extends RealLocalizable, T> KDTreeData<T> create(int numPoints, Iterable<T> values, Iterable<L> positions, boolean storeValuesAsNativeImg)
      Create KDTreeData from the given values and positions). (copies positions and sorts into a KDTree structure).
      Parameters:
      numPoints - number of points (number of elements in values and positions).
      values - values associated with points
      positions - points positions
      storeValuesAsNativeImg - If true and T is a NativeType, store values into NativeImg. Otherwise, store values as a List<T>.