Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itk::Statistics::KdTree< TSample > Class Template Reference

This class provides methods for k-nearest neighbor search and related data structures for a k-d tree. More...

#include <itkKdTree.h>

Inheritance diagram for itk::Statistics::KdTree< TSample >:

Inheritance graph
[legend]
Collaboration diagram for itk::Statistics::KdTree< TSample >:

Collaboration graph
[legend]
List of all members.

[NOHEADER]

int SearchLoop (KdTreeNodeType *node, MeasurementVectorType &query, MeasurementVectorType &lowerBound, MeasurementVectorType &upperBound)

Public Types

typedef KdTree Self
typedef Object Superclass
typedef SmartPointer< SelfPointer
typedef TSample SampleType
typedef TSample::MeasurementVectorType MeasurementVectorType
typedef TSample::MeasurementType MeasurementType
typedef TSample::InstanceIdentifier InstanceIdentifier
typedef TSample::FrequencyType FrequencyType
typedef EuclideanDistance<
MeasurementVectorType
DistanceMetricType
typedef KdTreeNode< TSample > KdTreeNodeType
typedef std::pair< InstanceIdentifier,
double > 
NeighborType
typedef std::vector< InstanceIdentifierInstanceIdentifierVectorType
typedef TSample::Iterator Iterator

Public Member Functions

virtual const char * GetClassName () const
 itkStaticConstMacro (MeasurementVectorSize, unsigned int, TSample::MeasurementVectorSize)
void SetBucketSize (unsigned int size)
void SetSample (TSample *sample)
TSample * GetSample ()
unsigned long Size ()
KdTreeNodeTypeGetEmptyTerminalNode ()
void SetRoot (KdTreeNodeType *root)
KdTreeNodeTypeGetRoot ()
MeasurementVectorType GetMeasurementVector (InstanceIdentifier id)
FrequencyType GetFrequency (InstanceIdentifier id)
DistanceMetricTypeGetDistanceMetric ()
void Search (MeasurementVectorType &query, unsigned int k, InstanceIdentifierVectorType &result)
void Search (MeasurementVectorType &query, double radius, InstanceIdentifierVectorType &result)
int GetNumberOfVisits ()
bool BallWithinBounds (MeasurementVectorType &query, MeasurementVectorType &lowerBound, MeasurementVectorType &upperBound, double radius)
bool BoundsOverlapBall (MeasurementVectorType &query, MeasurementVectorType &lowerBound, MeasurementVectorType &upperBound, double radius)
void DeleteNode (KdTreeNodeType *node)
void PrintTree (KdTreeNodeType *node, int level, unsigned int activeDimension)
Iterator Begin ()
Iterator End ()

Static Public Member Functions

Pointer New ()

Protected Member Functions

 KdTree ()
virtual ~KdTree ()
void PrintSelf (std::ostream &os, Indent indent) const
int NearestNeighborSearchLoop (KdTreeNodeType *node, MeasurementVectorType &query, MeasurementVectorType &lowerBound, MeasurementVectorType &upperBound)

Detailed Description

template<class TSample>
class itk::Statistics::KdTree< TSample >

This class provides methods for k-nearest neighbor search and related data structures for a k-d tree.

An object of this class stores instance identifiers in a k-d tree that is a binary tree with childrens split along a dimension among k-dimensions. The dimension of the split (or partition) is determined for each nonterminal node that has two children. The split process is terminated when the node has no children (when the number of measurement vectors is less than or equal to the size set by the SetBucketSize. That is The split process is a recursive process in nature and in implementation. This implementation doesn't support dynamic insert and delete operations for the tree. Instead, we can use the KdTreeGenerator or WeightedCentroidKdTreeGenerator to generate a static KdTree object.

To search k-nearest neighbor, call the Search method with the query point in a k-d space and the number of nearest neighbors. The GetSearchResult method returns a pointer to a NearestNeighbors object with k-nearest neighbors.

See also:
KdTreeNode, KdTreeNonterminalNode, KdTreeWeightedCentroidNonterminalNode, KdTreeTerminalNode, KdTreeGenerator, WeightedCentroidKdTreeNode

Definition at line 322 of file itkKdTree.h.


Member Typedef Documentation

template<class TSample>
typedef EuclideanDistance< MeasurementVectorType > itk::Statistics::KdTree< TSample >::DistanceMetricType
 

DistanceMetric type for the distance calculation and comparison Definition at line 348 of file itkKdTree.h.

Referenced by itk::Statistics::KdTree< TSample >::GetFrequency().

template<class TSample>
typedef TSample::FrequencyType itk::Statistics::KdTree< TSample >::FrequencyType
 

Definition at line 341 of file itkKdTree.h.

Referenced by itk::Statistics::KdTree< TSample >::GetMeasurementVector().

template<class TSample>
typedef TSample::InstanceIdentifier itk::Statistics::KdTree< TSample >::InstanceIdentifier
 

Definition at line 340 of file itkKdTree.h.

Referenced by itk::Statistics::KdTree< TSample >::GetMeasurementVector(), itk::Statistics::KdTree< TSample >::NearestNeighbors::GetNeighbors(), and itk::Statistics::KdTree< TSample >::GetRoot().

template<class TSample>
typedef std::vector< InstanceIdentifier > itk::Statistics::KdTree< TSample >::InstanceIdentifierVectorType
 

Definition at line 358 of file itkKdTree.h.

Referenced by itk::Statistics::KdTree< TSample >::GetDistanceMetric(), and itk::Statistics::KdTree< TSample >::NearestNeighbors::GetDistances().

template<class TSample>
typedef TSample::Iterator itk::Statistics::KdTree< TSample >::Iterator
 

Definition at line 523 of file itkKdTree.h.

Referenced by itk::Statistics::KdTree< TSample >::End(), and itk::Statistics::KdTree< TSample >::GetNumberOfVisits().

template<class TSample>
typedef KdTreeNode< TSample > itk::Statistics::KdTree< TSample >::KdTreeNodeType
 

Node type of the KdTree Definition at line 351 of file itkKdTree.h.

Referenced by itk::Statistics::KdTree< TSample >::GetEmptyTerminalNode(), itk::Statistics::KdTree< TSample >::GetNumberOfVisits(), itk::Statistics::KdTree< TSample >::SetRoot(), and itk::Statistics::KdTree< TSample >::Size().

template<class TSample>
typedef TSample::MeasurementType itk::Statistics::KdTree< TSample >::MeasurementType
 

Definition at line 339 of file itkKdTree.h.

template<class TSample>
typedef TSample::MeasurementVectorType itk::Statistics::KdTree< TSample >::MeasurementVectorType
 

Definition at line 338 of file itkKdTree.h.

Referenced by itk::Statistics::KdTree< TSample >::GetDistanceMetric(), itk::Statistics::KdTree< TSample >::GetNumberOfVisits(), and itk::Statistics::KdTree< TSample >::GetRoot().

template<class TSample>
typedef std::pair< InstanceIdentifier, double > itk::Statistics::KdTree< TSample >::NeighborType
 

Neighbor type. The first element of the std::pair is the instance identifier and the second one is the distance between the measurement vector identified by the first element and the query point. Definition at line 356 of file itkKdTree.h.

template<class TSample>
typedef SmartPointer<Self> itk::Statistics::KdTree< TSample >::Pointer
 

Reimplemented from itk::Object.

Definition at line 328 of file itkKdTree.h.

template<class TSample>
typedef TSample itk::Statistics::KdTree< TSample >::SampleType
 

typedef alias for the source data container Definition at line 337 of file itkKdTree.h.

template<class TSample>
typedef KdTree itk::Statistics::KdTree< TSample >::Self
 

Standard class typedefs

Reimplemented from itk::Object.

Definition at line 326 of file itkKdTree.h.

template<class TSample>
typedef Object itk::Statistics::KdTree< TSample >::Superclass
 

Reimplemented from itk::Object.

Definition at line 327 of file itkKdTree.h.


Constructor & Destructor Documentation

template<class TSample>
itk::Statistics::KdTree< TSample >::KdTree  )  [protected]
 

Constructor

template<class TSample>
virtual itk::Statistics::KdTree< TSample >::~KdTree  )  [protected, virtual]
 

Destructor: deletes the root node and the empty terminal node.


Member Function Documentation

template<class TSample>
bool itk::Statistics::KdTree< TSample >::BallWithinBounds MeasurementVectorType query,
MeasurementVectorType lowerBound,
MeasurementVectorType upperBound,
double  radius
 

Returns true if the intermediate k-nearest neighbors exist within the the bounding box defined by the lowerBound and the upperBound. Otherwise returns false. Returns false if the ball defined by the distance between the query point and the farthest neighbor touch the surface of the bounding box.

template<class TSample>
Iterator itk::Statistics::KdTree< TSample >::Begin void   )  [inline]
 

Definition at line 525 of file itkKdTree.h.

template<class TSample>
bool itk::Statistics::KdTree< TSample >::BoundsOverlapBall MeasurementVectorType query,
MeasurementVectorType lowerBound,
MeasurementVectorType upperBound,
double  radius
 

Returns true if the ball defined by the distance between the query point and the farthest neighbor overlaps with the bounding box defined by the lower and the upper bounds.

template<class TSample>
void itk::Statistics::KdTree< TSample >::DeleteNode KdTreeNodeType node  ) 
 

Deletes the node recursively

template<class TSample>
Iterator itk::Statistics::KdTree< TSample >::End void   )  [inline]
 

Definition at line 531 of file itkKdTree.h.

References itk::Statistics::KdTree< TSample >::Iterator.

template<class TSample>
virtual const char* itk::Statistics::KdTree< TSample >::GetClassName  )  const [virtual]
 

Run-time type information (and related methods)

Reimplemented from itk::Object.

template<class TSample>
DistanceMetricType* itk::Statistics::KdTree< TSample >::GetDistanceMetric  )  [inline]
 

Get the pointer to the distance metric. Definition at line 480 of file itkKdTree.h.

References itk::Statistics::KdTree< TSample >::InstanceIdentifierVectorType, and itk::Statistics::KdTree< TSample >::MeasurementVectorType.

template<class TSample>
KdTreeNodeType* itk::Statistics::KdTree< TSample >::GetEmptyTerminalNode  )  [inline]
 

Returns the pointer to the empty terminal node. A KdTree object has a single empty terminal node in memory. when the split process has to create an empty terminal node, the single instance is reused for this case Definition at line 457 of file itkKdTree.h.

References itk::Statistics::KdTree< TSample >::KdTreeNodeType.

template<class TSample>
FrequencyType itk::Statistics::KdTree< TSample >::GetFrequency InstanceIdentifier  id  )  [inline]
 

Returns the frequency of the measurement vector identified by the instance identifier Definition at line 476 of file itkKdTree.h.

References itk::Statistics::KdTree< TSample >::DistanceMetricType.

template<class TSample>
MeasurementVectorType itk::Statistics::KdTree< TSample >::GetMeasurementVector InstanceIdentifier  id  )  [inline]
 

Returns the measurement vector identified by the instance identifier that is an identifier defiend for the input sample Definition at line 471 of file itkKdTree.h.

References itk::Statistics::KdTree< TSample >::FrequencyType, and itk::Statistics::KdTree< TSample >::InstanceIdentifier.

template<class TSample>
int itk::Statistics::KdTree< TSample >::GetNumberOfVisits  )  [inline]
 

Returns the number of measurement vectors that have been visited to find the k-nearest neighbors. Definition at line 495 of file itkKdTree.h.

References itk::Statistics::KdTree< TSample >::Iterator, itk::Statistics::KdTree< TSample >::KdTreeNodeType, and itk::Statistics::KdTree< TSample >::MeasurementVectorType.

template<class TSample>
KdTreeNodeType* itk::Statistics::KdTree< TSample >::GetRoot  )  [inline]
 

Returns the pointer to the root node. Definition at line 466 of file itkKdTree.h.

References itk::Statistics::KdTree< TSample >::InstanceIdentifier, and itk::Statistics::KdTree< TSample >::MeasurementVectorType.

template<class TSample>
TSample* itk::Statistics::KdTree< TSample >::GetSample  )  [inline]
 

Returns the pointer to the input sample Definition at line 447 of file itkKdTree.h.

template<class TSample>
itk::Statistics::KdTree< TSample >::itkStaticConstMacro MeasurementVectorSize  ,
unsigned  int,
TSample::MeasurementVectorSize 
 

Length of the measurement vector. k in the k-d tree

template<class TSample>
int itk::Statistics::KdTree< TSample >::NearestNeighborSearchLoop KdTreeNodeType node,
MeasurementVectorType query,
MeasurementVectorType lowerBound,
MeasurementVectorType upperBound
[protected]
 

search loop

template<class TSample>
Pointer itk::Statistics::KdTree< TSample >::New  )  [static]
 

Method for creation through the object factory.

Reimplemented from itk::Object.

template<class TSample>
void itk::Statistics::KdTree< TSample >::PrintSelf std::ostream &  os,
Indent  indent
const [protected, virtual]
 

Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from itk::Object.

template<class TSample>
void itk::Statistics::KdTree< TSample >::PrintTree KdTreeNodeType node,
int  level,
unsigned int  activeDimension
 

Prints out the tree information

template<class TSample>
void itk::Statistics::KdTree< TSample >::Search MeasurementVectorType query,
double  radius,
InstanceIdentifierVectorType result
 

Searches the neighbors fallen into a hypersphere

template<class TSample>
void itk::Statistics::KdTree< TSample >::Search MeasurementVectorType query,
unsigned int  k,
InstanceIdentifierVectorType result
 

Searches the k-nearest neighbors

template<class TSample>
int itk::Statistics::KdTree< TSample >::SearchLoop KdTreeNodeType node,
MeasurementVectorType query,
MeasurementVectorType lowerBound,
MeasurementVectorType upperBound
[protected]
 

search loop

template<class TSample>
void itk::Statistics::KdTree< TSample >::SetBucketSize unsigned int  size  ) 
 

Sets the number of measurement vectors that can be stored in a terminal node

template<class TSample>
void itk::Statistics::KdTree< TSample >::SetRoot KdTreeNodeType root  )  [inline]
 

Sets the root node of the KdTree that is a result of KdTreeGenerator or WeightedCentroidKdTreeGenerator. Definition at line 462 of file itkKdTree.h.

References itk::Statistics::KdTree< TSample >::KdTreeNodeType.

template<class TSample>
void itk::Statistics::KdTree< TSample >::SetSample TSample *  sample  ) 
 

Sets the input sample that provides the measurement vectors to the k-d tree

template<class TSample>
unsigned long itk::Statistics::KdTree< TSample >::Size void   )  [inline]
 

Definition at line 450 of file itkKdTree.h.

References itk::Statistics::KdTree< TSample >::KdTreeNodeType.


The documentation for this class was generated from the following file:
Generated at Sat Mar 31 03:13:34 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000