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 java.lang.ObjectStores the KDTree data, that is, positions and values.Positions are stored in either
FLATorNESTEDlayout. WithNESTEDlayout, positions are stored as a nesteddouble[][]array wherepositions[d][i]is dimensiondof thei-th point. WithFLATlayout, positions are stored as a flatdouble[]array, wherepositions[d + i*n]is dimensiondof thei-th point, withnthe number of dimensions.Values (of type
T) are stored as either a 1DRandomAccessibleInterval<T>, or aList<T>. Individual values can be accessed byvaluesSupplier().get().apply(i).valueSupplier().get()returns a reusableIntFunction<T>. HereTmaybe a proxy that is reused in subsequentapply(i).values()returns all values as a 1DRandomAccessibleInterval<T>. (If data is stored asList<T>, it is wrapped into aListImg.)
-
-
Field Summary
Fields Modifier and Type Field Description private RealIntervalboundingBoxprivate KDTreePositionspositionsprivate Ttypeprivate RandomAccessibleInterval<T>valuesImgprivate java.util.function.Supplier<java.util.function.IntFunction<T>>valuesSupplier
-
Constructor Summary
Constructors Constructor Description KDTreeData(KDTreePositions positions, java.util.List<T> values)KDTreeData(KDTreePositions positions, java.util.List<T> values, RealInterval boundingBox)KDTreeData(KDTreePositions positions, RandomAccessibleInterval<T> values)KDTreeData(KDTreePositions positions, RandomAccessibleInterval<T> values, RealInterval boundingBox)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RealIntervalboundingBox()static <L extends RealLocalizable,T>
KDTreeData<T>create(int numPoints, java.lang.Iterable<T> values, java.lang.Iterable<L> positions, boolean storeValuesAsNativeImg)TgetType()KDTreePositionspositions()RandomAccessibleInterval<T>values()Get the values as a 1DRandomAccessibleInterval, for serialization.java.util.function.Supplier<java.util.function.IntFunction<T>>valuesSupplier()Get aSupplierthat returnIntFunction<T>to provide values for a given node indices.
-
-
-
Field Detail
-
positions
private final KDTreePositions positions
-
valuesImg
private final RandomAccessibleInterval<T> valuesImg
-
valuesSupplier
private final java.util.function.Supplier<java.util.function.IntFunction<T>> valuesSupplier
-
type
private final T type
-
boundingBox
private volatile RealInterval boundingBox
-
-
Constructor Detail
-
KDTreeData
public KDTreeData(KDTreePositions positions, java.util.List<T> values)
-
KDTreeData
public KDTreeData(KDTreePositions positions, java.util.List<T> values, RealInterval boundingBox)
-
KDTreeData
public KDTreeData(KDTreePositions positions, RandomAccessibleInterval<T> values)
-
KDTreeData
public KDTreeData(KDTreePositions positions, RandomAccessibleInterval<T> values, RealInterval boundingBox)
-
-
Method Detail
-
positions
public KDTreePositions positions()
-
getType
public T getType()
-
values
public RandomAccessibleInterval<T> values()
Get the values as a 1DRandomAccessibleInterval, for serialization. (If the underlying storage is aList<T>, it will be wrapped as aListImg.)
-
valuesSupplier
public java.util.function.Supplier<java.util.function.IntFunction<T>> valuesSupplier()
Get aSupplierthat returnIntFunction<T>to provide values for a given node indices. If the returnedIntFunction<T>is stateful (Tmaybe a proxy that is reused in subsequentapply(i)} everySupplier.get()creates a new instance of theIntFunction<T>.
-
boundingBox
public RealInterval boundingBox()
-
create
public static <L extends RealLocalizable,T> KDTreeData<T> create(int numPoints, java.lang.Iterable<T> values, java.lang.Iterable<L> positions, boolean storeValuesAsNativeImg)
CreateKDTreeDatafrom the givenvaluesandpositions). (copiespositionsand sorts into a KDTree structure).- Parameters:
numPoints- number of points (number of elements invaluesandpositions).values- values associated with pointspositions- points positionsstoreValuesAsNativeImg- IftrueandTis aNativeType, store values intoNativeImg. Otherwise, store values as aList<T>.
-
-