ITK  4.2.0
Insight Segmentation and Registration Toolkit
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
itk::Statistics::KdTree< TSample > Class Template Reference

#include <itkKdTree.h>

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

List of all members.

Classes

class  NearestNeighbors
 data structure for storing k-nearest neighbor search result (k number of Neighbors) More...

Public Types

typedef
TSample::AbsoluteFrequencyType 
AbsoluteFrequencyType
typedef TSample::ConstIterator ConstIterator
typedef SmartPointer< const SelfConstPointer
typedef
EuclideanDistanceMetric
< MeasurementVectorType
DistanceMetricType
typedef TSample::InstanceIdentifier InstanceIdentifier
typedef std::vector
< InstanceIdentifier
InstanceIdentifierVectorType
typedef TSample::Iterator Iterator
typedef KdTreeNode< TSample > KdTreeNodeType
typedef TSample::MeasurementType MeasurementType
typedef unsigned int MeasurementVectorSizeType
typedef
TSample::MeasurementVectorType 
MeasurementVectorType
typedef std::pair
< InstanceIdentifier, double > 
NeighborType
typedef SmartPointer< SelfPointer
typedef TSample SampleType
typedef KdTree Self
typedef Object Superclass
- Public Types inherited from itk::Object
- Public Types inherited from itk::LightObject

Public Member Functions

bool BallWithinBounds (const MeasurementVectorType &, MeasurementVectorType &, MeasurementVectorType &, double) const
bool BoundsOverlapBall (const MeasurementVectorType &, MeasurementVectorType &, MeasurementVectorType &, double) const
virtual ::itk::LightObject::Pointer CreateAnother (void) const
void DeleteNode (KdTreeNodeType *)
DistanceMetricTypeGetDistanceMetric ()
KdTreeNodeTypeGetEmptyTerminalNode ()
AbsoluteFrequencyType GetFrequency (InstanceIdentifier id) const
const MeasurementVectorTypeGetMeasurementVector (InstanceIdentifier id) const
virtual MeasurementVectorSizeType GetMeasurementVectorSize () const
virtual const char * GetNameOfClass () const
KdTreeNodeTypeGetRoot ()
const TSample * GetSample () const
void PlotTree (std::ostream &os) const
void PlotTree (KdTreeNodeType *node, std::ostream &os=std::cout) const
void PrintTree (std::ostream &) const
void PrintTree (KdTreeNodeType *, unsigned int, unsigned int, std::ostream &os=std::cout) const
void Search (const MeasurementVectorType &, unsigned int, InstanceIdentifierVectorType &) const
void Search (const MeasurementVectorType &, double, InstanceIdentifierVectorType &) const
void SetBucketSize (unsigned int)
void SetSample (const TSample *)
SizeValueType Size () const
void SetRoot (KdTreeNodeType *root)
- Public Member Functions inherited from itk::Object
unsigned long AddObserver (const EventObject &event, Command *)
unsigned long AddObserver (const EventObject &event, Command *) const
virtual void DebugOff () const
virtual void DebugOn () const
CommandGetCommand (unsigned long tag)
bool GetDebug () const
MetaDataDictionaryGetMetaDataDictionary (void)
const MetaDataDictionaryGetMetaDataDictionary (void) const
virtual unsigned long GetMTime () const
virtual const TimeStampGetTimeStamp () const
bool HasObserver (const EventObject &event) const
void InvokeEvent (const EventObject &)
void InvokeEvent (const EventObject &) const
virtual void Modified () const
virtual void Register () const
void RemoveAllObservers ()
void RemoveObserver (unsigned long tag)
void SetDebug (bool debugFlag) const
void SetMetaDataDictionary (const MetaDataDictionary &rhs)
virtual void SetReferenceCount (int)
virtual void UnRegister () const
- Public Member Functions inherited from itk::LightObject
virtual void Delete ()
virtual int GetReferenceCount () const
 itkCloneMacro (Self)
void Print (std::ostream &os, Indent indent=0) const

Static Public Member Functions

static Pointer New ()
- Static Public Member Functions inherited from itk::Object
static bool GetGlobalWarningDisplay ()
static void GlobalWarningDisplayOff ()
static void GlobalWarningDisplayOn ()
static void SetGlobalWarningDisplay (bool flag)
- Static Public Member Functions inherited from itk::LightObject
static void BreakOnError ()

Protected Member Functions

 KdTree ()
int NearestNeighborSearchLoop (const KdTreeNodeType *, const MeasurementVectorType &, MeasurementVectorType &, MeasurementVectorType &, NearestNeighbors &) const
void PrintSelf (std::ostream &os, Indent indent) const
int SearchLoop (const KdTreeNodeType *, const MeasurementVectorType &, double, MeasurementVectorType &, MeasurementVectorType &, InstanceIdentifierVectorType &) const
virtual ~KdTree ()
- Protected Member Functions inherited from itk::Object
 Object ()
bool PrintObservers (std::ostream &os, Indent indent) const
virtual void SetTimeStamp (const TimeStamp &time)
virtual ~Object ()
- Protected Member Functions inherited from itk::LightObject
virtual LightObject::Pointer InternalClone () const
 LightObject ()
virtual void PrintHeader (std::ostream &os, Indent indent) const
virtual void PrintTrailer (std::ostream &os, Indent indent) const
virtual ~LightObject ()

Private Member Functions

 KdTree (const Self &)
void operator= (const Self &)

Private Attributes

int m_BucketSize
DistanceMetricType::Pointer m_DistanceMetric
KdTreeNodeTypem_EmptyTerminalNode
MeasurementVectorSizeType m_MeasurementVectorSize
KdTreeNodeTypem_Root
const TSample * m_Sample

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.

Recent API changes: The static const macro to get the length of a measurement vector, 'MeasurementVectorSize' has been removed to allow the length of a measurement vector to be specified at run time. Please use the function GetMeasurementVectorSize() instead.

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

Definition at line 482 of file itkKdTree.h.


Member Typedef Documentation

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

Definition at line 502 of file itkKdTree.h.

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

Definition at line 717 of file itkKdTree.h.

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

Reimplemented from itk::Object.

Definition at line 489 of file itkKdTree.h.

DistanceMetric type for the distance calculation and comparison

Definition at line 508 of file itkKdTree.h.

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

Definition at line 501 of file itkKdTree.h.

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

Definition at line 521 of file itkKdTree.h.

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

Definition at line 716 of file itkKdTree.h.

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

Node type of the KdTree

Definition at line 514 of file itkKdTree.h.

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

Definition at line 500 of file itkKdTree.h.

template<class TSample >
typedef unsigned int itk::Statistics::KdTree< TSample >::MeasurementVectorSizeType

Definition at line 504 of file itkKdTree.h.

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

Definition at line 499 of file itkKdTree.h.

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 519 of file itkKdTree.h.

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

Reimplemented from itk::Object.

Definition at line 488 of file itkKdTree.h.

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

typedef alias for the source data container

Definition at line 495 of file itkKdTree.h.

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

Standard class typedefs

Reimplemented from itk::Object.

Definition at line 486 of file itkKdTree.h.

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

Reimplemented from itk::Object.

Definition at line 487 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 ( )
protectedvirtual

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

template<class TSample >
itk::Statistics::KdTree< TSample >::KdTree ( const Self )
private

Member Function Documentation

template<class TSample >
bool itk::Statistics::KdTree< TSample >::BallWithinBounds ( const MeasurementVectorType ,
MeasurementVectorType ,
MeasurementVectorType ,
double   
) const

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 >
bool itk::Statistics::KdTree< TSample >::BoundsOverlapBall ( const MeasurementVectorType ,
MeasurementVectorType ,
MeasurementVectorType ,
double   
) const

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 >
virtual::itk::LightObject::Pointer itk::Statistics::KdTree< TSample >::CreateAnother ( void  ) const
virtual

Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.

Reimplemented from itk::Object.

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

Deletes the node recursively

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

Get the pointer to the distance metric.

Definition at line 672 of file itkKdTree.h.

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 633 of file itkKdTree.h.

template<class TSample >
AbsoluteFrequencyType itk::Statistics::KdTree< TSample >::GetFrequency ( InstanceIdentifier  id) const
inline

Returns the frequency of the measurement vector identified by the instance identifier

Definition at line 666 of file itkKdTree.h.

template<class TSample >
const MeasurementVectorType& itk::Statistics::KdTree< TSample >::GetMeasurementVector ( InstanceIdentifier  id) const
inline

Returns the measurement vector identified by the instance identifier that is an identifier defiend for the input sample

Definition at line 658 of file itkKdTree.h.

template<class TSample >
virtual MeasurementVectorSizeType itk::Statistics::KdTree< TSample >::GetMeasurementVectorSize ( ) const
virtual

Get Macro to get the length of a measurement vector in the KdTree. The length is obtained from the input sample.

template<class TSample >
virtual const char* itk::Statistics::KdTree< TSample >::GetNameOfClass ( ) const
virtual

Run-time type information (and related methods)

Reimplemented from itk::Object.

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

Returns the pointer to the root node.

Definition at line 651 of file itkKdTree.h.

template<class TSample >
const TSample* itk::Statistics::KdTree< TSample >::GetSample ( ) const
inline

Returns the pointer to the input sample

Definition at line 619 of file itkKdTree.h.

template<class TSample >
int itk::Statistics::KdTree< TSample >::NearestNeighborSearchLoop ( const KdTreeNodeType ,
const MeasurementVectorType ,
MeasurementVectorType ,
MeasurementVectorType ,
NearestNeighbors  
) const
protected

search loop

template<class TSample >
static 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 >::operator= ( const Self )
private

Mutex lock to protect modification to the reference count

Reimplemented from itk::Object.

template<class TSample >
void itk::Statistics::KdTree< TSample >::PlotTree ( std::ostream &  os) const

Draw out the tree information to a ostream using the format of the Graphviz dot tool.

template<class TSample >
void itk::Statistics::KdTree< TSample >::PlotTree ( KdTreeNodeType node,
std::ostream &  os = std::cout 
) const

Prints out the tree information

template<class TSample >
void itk::Statistics::KdTree< TSample >::PrintSelf ( std::ostream &  os,
Indent  indent 
) const
protectedvirtual

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 ( std::ostream &  ) const

Prints out the tree information

template<class TSample >
void itk::Statistics::KdTree< TSample >::PrintTree ( KdTreeNodeType ,
unsigned  int,
unsigned  int,
std::ostream &  os = std::cout 
) const

Prints out the tree information

template<class TSample >
void itk::Statistics::KdTree< TSample >::Search ( const MeasurementVectorType ,
unsigned  int,
InstanceIdentifierVectorType  
) const

Searches the k-nearest neighbors

template<class TSample >
void itk::Statistics::KdTree< TSample >::Search ( const MeasurementVectorType ,
double  ,
InstanceIdentifierVectorType  
) const

Searches the neighbors fallen into a hypersphere

template<class TSample >
int itk::Statistics::KdTree< TSample >::SearchLoop ( const KdTreeNodeType ,
const MeasurementVectorType ,
double  ,
MeasurementVectorType ,
MeasurementVectorType ,
InstanceIdentifierVectorType  
) const
protected

search loop

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

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 640 of file itkKdTree.h.

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

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

template<class TSample >
SizeValueType itk::Statistics::KdTree< TSample >::Size ( void  ) const
inline

Definition at line 624 of file itkKdTree.h.


Member Data Documentation

template<class TSample >
int itk::Statistics::KdTree< TSample >::m_BucketSize
private

Number of measurement vectors can be stored in a terminal node.

Definition at line 746 of file itkKdTree.h.

template<class TSample >
DistanceMetricType::Pointer itk::Statistics::KdTree< TSample >::m_DistanceMetric
private

Distance metric smart pointer

Definition at line 755 of file itkKdTree.h.

template<class TSample >
KdTreeNodeType* itk::Statistics::KdTree< TSample >::m_EmptyTerminalNode
private

Pointer to the empty terminal node

Definition at line 752 of file itkKdTree.h.

template<class TSample >
MeasurementVectorSizeType itk::Statistics::KdTree< TSample >::m_MeasurementVectorSize
private

Measurement vector size

Definition at line 758 of file itkKdTree.h.

template<class TSample >
KdTreeNodeType* itk::Statistics::KdTree< TSample >::m_Root
private

Pointer to the root node

Definition at line 749 of file itkKdTree.h.

template<class TSample >
const TSample* itk::Statistics::KdTree< TSample >::m_Sample
private

Pointer to the input sample

Definition at line 743 of file itkKdTree.h.


The documentation for this class was generated from the following file: