Package net.imglib2.neighborsearch
Class KNearestNeighborSearchOnKDTree<T>
- java.lang.Object
-
- net.imglib2.neighborsearch.KNearestNeighborSearchOnKDTree<T>
-
- All Implemented Interfaces:
EuclideanSpace,KNearestNeighborSearch<T>,NearestNeighborSearch<T>
public class KNearestNeighborSearchOnKDTree<T> extends java.lang.Object implements KNearestNeighborSearch<T>
Implementation ofKNearestNeighborSearchsearch for kd-trees.
-
-
Field Summary
Fields Modifier and Type Field Description protected KDTreeNode<T>[]bestPointsprotected double[]bestSquDistancesprotected intkprotected intnprotected double[]posprotected KDTree<T>tree
-
Constructor Summary
Constructors Constructor Description KNearestNeighborSearchOnKDTree(KDTree<T> tree, int k)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KNearestNeighborSearchOnKDTree<T>copy()Create a copy.doublegetDistance()Access the Euclidean distance between the reference location as used for the last search and the nearest neighbor, ordered by square Euclidean distance.doublegetDistance(int i)Access the Euclidean distance between the reference location as used for the last search and the ith nearest neighbor, ordered by square Euclidean distance.intgetK()Get the of k nearest neighbor points used in this searchRealLocalizablegetPosition()Access the position of the nearest neighbor, ordered by square Euclidean distance.RealLocalizablegetPosition(int i)Access the position of the ith nearest neighbor, ordered by square Euclidean distance.Sampler<T>getSampler()Access the data of the nearest neighbor.Sampler<T>getSampler(int i)Access the data of the ith nearest neighbor, ordered by square Euclidean distance.doublegetSquareDistance()Access the square Euclidean distance between the reference location as used for the last search and the nearest neighbor, ordered by square Euclidean distance.doublegetSquareDistance(int i)Access the square Euclidean distance between the reference location as used for the last search and the ith nearest neighbor, ordered by square Euclidean distance.intnumDimensions()Gets the space's number of dimensions.voidsearch(RealLocalizable reference)Perform k-nearest-neighbor search for a reference coordinate.protected voidsearchNode(KDTreeNode<T> current)
-
-
-
Field Detail
-
n
protected final int n
-
pos
protected final double[] pos
-
k
protected final int k
-
bestPoints
protected KDTreeNode<T>[] bestPoints
-
bestSquDistances
protected double[] bestSquDistances
-
-
Method Detail
-
numDimensions
public int numDimensions()
Description copied from interface:EuclideanSpaceGets the space's number of dimensions.- Specified by:
numDimensionsin interfaceEuclideanSpace
-
getK
public int getK()
Description copied from interface:KNearestNeighborSearchGet the of k nearest neighbor points used in this search- Specified by:
getKin interfaceKNearestNeighborSearch<T>- Returns:
- the number of nearest neighbor points k used for this search
-
search
public void search(RealLocalizable reference)
Description copied from interface:KNearestNeighborSearchPerform k-nearest-neighbor search for a reference coordinate.- Specified by:
searchin interfaceKNearestNeighborSearch<T>- Specified by:
searchin interfaceNearestNeighborSearch<T>
-
searchNode
protected void searchNode(KDTreeNode<T> current)
-
getSampler
public Sampler<T> getSampler(int i)
Description copied from interface:KNearestNeighborSearchAccess the data of the ith nearest neighbor, ordered by square Euclidean distance. Data is accessed through aSamplerthat guarantees write access if the underlying data set is writable.- Specified by:
getSamplerin interfaceKNearestNeighborSearch<T>
-
getPosition
public RealLocalizable getPosition(int i)
Description copied from interface:KNearestNeighborSearchAccess the position of the ith nearest neighbor, ordered by square Euclidean distance.- Specified by:
getPositionin interfaceKNearestNeighborSearch<T>
-
getSquareDistance
public double getSquareDistance(int i)
Description copied from interface:KNearestNeighborSearchAccess the square Euclidean distance between the reference location as used for the last search and the ith nearest neighbor, ordered by square Euclidean distance.- Specified by:
getSquareDistancein interfaceKNearestNeighborSearch<T>
-
getDistance
public double getDistance(int i)
Description copied from interface:KNearestNeighborSearchAccess the Euclidean distance between the reference location as used for the last search and the ith nearest neighbor, ordered by square Euclidean distance.- Specified by:
getDistancein interfaceKNearestNeighborSearch<T>
-
getPosition
public RealLocalizable getPosition()
Description copied from interface:NearestNeighborSearchAccess the position of the nearest neighbor, ordered by square Euclidean distance.- Specified by:
getPositionin interfaceNearestNeighborSearch<T>
-
getSampler
public Sampler<T> getSampler()
Description copied from interface:NearestNeighborSearchAccess the data of the nearest neighbor. Data is accessed through aSamplerthat guarantees write access if the underlying data set is writable.- Specified by:
getSamplerin interfaceNearestNeighborSearch<T>
-
getSquareDistance
public double getSquareDistance()
Description copied from interface:NearestNeighborSearchAccess the square Euclidean distance between the reference location as used for the last search and the nearest neighbor, ordered by square Euclidean distance.- Specified by:
getSquareDistancein interfaceNearestNeighborSearch<T>
-
getDistance
public double getDistance()
Description copied from interface:NearestNeighborSearchAccess the Euclidean distance between the reference location as used for the last search and the nearest neighbor, ordered by square Euclidean distance.- Specified by:
getDistancein interfaceNearestNeighborSearch<T>
-
copy
public KNearestNeighborSearchOnKDTree<T> copy()
Description copied from interface:KNearestNeighborSearchCreate a copy.- Specified by:
copyin interfaceKNearestNeighborSearch<T>- Specified by:
copyin interfaceNearestNeighborSearch<T>
-
-