Package net.imglib2.neighborsearch
Class KNearestNeighborSearchOnIterableRealInterval<T>
- java.lang.Object
-
- net.imglib2.neighborsearch.KNearestNeighborSearchOnIterableRealInterval<T>
-
- All Implemented Interfaces:
EuclideanSpace
,KNearestNeighborSearch<T>
,NearestNeighborSearch<T>
public class KNearestNeighborSearchOnIterableRealInterval<T> extends java.lang.Object implements KNearestNeighborSearch<T>
k-nearest-neighbor search onIterableRealInterval
implemented as linear search.- Author:
- Stephan Saalfeld
-
-
Field Summary
Fields Modifier and Type Field Description protected RealCursor<T>[]
elements
protected IterableRealInterval<T>
iterable
protected int
k
protected int
n
protected double[]
referenceLocation
protected double[]
squareDistances
-
Constructor Summary
Constructors Constructor Description KNearestNeighborSearchOnIterableRealInterval(IterableRealInterval<T> iterable, int k)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KNearestNeighborSearchOnIterableRealInterval<T>
copy()
Create a copy.double
getDistance()
Access the Euclidean distance between the reference location as used for the last search and the nearest neighbor, ordered by square Euclidean distance.double
getDistance(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.int
getK()
Get the of k nearest neighbor points used in this searchRealLocalizable
getPosition()
Access the position of the nearest neighbor, ordered by square Euclidean distance.RealLocalizable
getPosition(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.RealCursor<T>
getSampler(int i)
Access the data of the ith nearest neighbor, ordered by square Euclidean distance.double
getSquareDistance()
Access the square Euclidean distance between the reference location as used for the last search and the nearest neighbor, ordered by square Euclidean distance.double
getSquareDistance(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.int
numDimensions()
Gets the space's number of dimensions.void
search(RealLocalizable reference)
Perform k-nearest-neighbor search for a reference coordinate.protected double
squareDistance(RealLocalizable query)
Calculate the square Euclidean distance of a query location to the location stored in referenceLocation.
-
-
-
Field Detail
-
iterable
protected final IterableRealInterval<T> iterable
-
k
protected final int k
-
n
protected final int n
-
elements
protected final RealCursor<T>[] elements
-
squareDistances
protected final double[] squareDistances
-
referenceLocation
protected final double[] referenceLocation
-
-
Constructor Detail
-
KNearestNeighborSearchOnIterableRealInterval
public KNearestNeighborSearchOnIterableRealInterval(IterableRealInterval<T> iterable, int k)
-
-
Method Detail
-
squareDistance
protected final double squareDistance(RealLocalizable query)
Calculate the square Euclidean distance of a query location to the location stored in referenceLocation.
-
numDimensions
public int numDimensions()
Description copied from interface:EuclideanSpace
Gets the space's number of dimensions.- Specified by:
numDimensions
in interfaceEuclideanSpace
-
getK
public int getK()
Description copied from interface:KNearestNeighborSearch
Get the of k nearest neighbor points used in this search- Specified by:
getK
in interfaceKNearestNeighborSearch<T>
- Returns:
- the number of nearest neighbor points k used for this search
-
search
public void search(RealLocalizable reference)
Description copied from interface:KNearestNeighborSearch
Perform k-nearest-neighbor search for a reference coordinate.- Specified by:
search
in interfaceKNearestNeighborSearch<T>
- Specified by:
search
in interfaceNearestNeighborSearch<T>
-
getPosition
public RealLocalizable getPosition(int i)
Description copied from interface:KNearestNeighborSearch
Access the position of the ith nearest neighbor, ordered by square Euclidean distance.- Specified by:
getPosition
in interfaceKNearestNeighborSearch<T>
-
getSampler
public RealCursor<T> getSampler(int i)
Description copied from interface:KNearestNeighborSearch
Access the data of the ith nearest neighbor, ordered by square Euclidean distance. Data is accessed through aSampler
that guarantees write access if the underlying data set is writable.- Specified by:
getSampler
in interfaceKNearestNeighborSearch<T>
-
getSquareDistance
public double getSquareDistance(int i)
Description copied from interface:KNearestNeighborSearch
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.- Specified by:
getSquareDistance
in interfaceKNearestNeighborSearch<T>
-
getDistance
public double getDistance(int i)
Description copied from interface:KNearestNeighborSearch
Access 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:
getDistance
in interfaceKNearestNeighborSearch<T>
-
getPosition
public RealLocalizable getPosition()
Description copied from interface:NearestNeighborSearch
Access the position of the nearest neighbor, ordered by square Euclidean distance.- Specified by:
getPosition
in interfaceNearestNeighborSearch<T>
-
getSampler
public Sampler<T> getSampler()
Description copied from interface:NearestNeighborSearch
Access the data of the nearest neighbor. Data is accessed through aSampler
that guarantees write access if the underlying data set is writable.- Specified by:
getSampler
in interfaceNearestNeighborSearch<T>
-
getSquareDistance
public double getSquareDistance()
Description copied from interface:NearestNeighborSearch
Access 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:
getSquareDistance
in interfaceNearestNeighborSearch<T>
-
getDistance
public double getDistance()
Description copied from interface:NearestNeighborSearch
Access the Euclidean distance between the reference location as used for the last search and the nearest neighbor, ordered by square Euclidean distance.- Specified by:
getDistance
in interfaceNearestNeighborSearch<T>
-
copy
public KNearestNeighborSearchOnIterableRealInterval<T> copy()
Description copied from interface:KNearestNeighborSearch
Create a copy.- Specified by:
copy
in interfaceKNearestNeighborSearch<T>
- Specified by:
copy
in interfaceNearestNeighborSearch<T>
-
-