ITK  6.0.0
Insight Toolkit
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
itk::Statistics::KdTreeGenerator< TSample > Class Template Reference

#include <itkKdTreeGenerator.h>

Detailed Description

template<typename TSample>
class itk::Statistics::KdTreeGenerator< TSample >

This class generates a KdTree object without centroid information.

The KdTree object stores measurement vectors in a k-d tree structure that is a binary tree. The partition value is the median value of one of the k dimension (partition dimension). The partition dimension is determined by the spread of measurement values in each dimension. The partition dimension is the dimension has the widest spread. Our implementation of k-d tree doesn't have any construction or insertion logic. Users should use this class or the WeightedCentroidKdTreeGenerator class.

The number of the measurement vectors in a terminal node is set by the SetBucketSize method. If we use too small number for this, it might cause computational overhead to calculate bound conditions. However, too large number will cause more distance calculation between the measurement vectors in a terminal node and the query point.

To run this generator, users should provides the bucket size (SetBucketSize method) and the input sample (SetSample method). The Update method will run this generator. To get the resulting KdTree object, call the GetOutput method.

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. It is now obtained from the sample set as input. You may query this length using the function GetMeasurementVectorSize().

See also
KdTree, KdTreeNode, KdTreeNonterminalNode, KdTreeTerminalNode, WeightedCentroidKdTreeGenerator
ITK Sphinx Examples:
Examples
Examples/Statistics/KdTree.cxx, and SphinxExamples/src/Numerics/Statistics/SpatialSearch/Code.cxx.

Definition at line 71 of file itkKdTreeGenerator.h.

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

Public Types

using ConstPointer = SmartPointer< const Self >
 
using KdTreeNodeType = typename KdTreeType::KdTreeNodeType
 
using KdTreeType = KdTree< TSample >
 
using MeasurementType = typename TSample::MeasurementType
 
using MeasurementVectorSizeType = unsigned int
 
using MeasurementVectorType = typename TSample::MeasurementVectorType
 
using OutputPointer = typename KdTreeType::Pointer
 
using OutputType = KdTreeType
 
using Pointer = SmartPointer< Self >
 
using Self = KdTreeGenerator
 
using SubsamplePointer = typename SubsampleType::Pointer
 
using SubsampleType = Subsample< TSample >
 
using Superclass = Object
 
- Public Types inherited from itk::Object
using ConstPointer = SmartPointer< const Self >
 
using Pointer = SmartPointer< Self >
 
using Self = Object
 
using Superclass = LightObject
 
- Public Types inherited from itk::LightObject
using ConstPointer = SmartPointer< const Self >
 
using Pointer = SmartPointer< Self >
 
using Self = LightObject
 

Public Member Functions

void GenerateData ()
 
virtual unsigned int GetMeasurementVectorSize () const
 
const char * GetNameOfClass () const override
 
OutputPointer GetOutput ()
 
void Update ()
 
void SetSample (TSample *sample)
 
virtual TSample * GetSourceSample () const
 
void SetBucketSize (unsigned int size)
 
virtual unsigned int GetBucketSize () const
 
- Public Member Functions inherited from itk::Object
unsigned long AddObserver (const EventObject &event, Command *cmd) const
 
unsigned long AddObserver (const EventObject &event, std::function< void(const EventObject &)> function) const
 
LightObject::Pointer CreateAnother () const override
 
virtual void DebugOff () const
 
virtual void DebugOn () const
 
CommandGetCommand (unsigned long tag)
 
bool GetDebug () const
 
MetaDataDictionaryGetMetaDataDictionary ()
 
const MetaDataDictionaryGetMetaDataDictionary () const
 
virtual ModifiedTimeType 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
 
void Register () const override
 
void RemoveAllObservers ()
 
void RemoveObserver (unsigned long tag) const
 
void SetDebug (bool debugFlag) const
 
void SetReferenceCount (int) override
 
void UnRegister () const noexcept override
 
void SetMetaDataDictionary (const MetaDataDictionary &rhs)
 
void SetMetaDataDictionary (MetaDataDictionary &&rrhs)
 
virtual void SetObjectName (std::string _arg)
 
virtual const std::string & GetObjectName () const
 
- Public Member Functions inherited from itk::LightObject
Pointer Clone () const
 
virtual void Delete ()
 
virtual int GetReferenceCount () const
 
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 Pointer New ()
 
static void SetGlobalWarningDisplay (bool val)
 
- Static Public Member Functions inherited from itk::LightObject
static void BreakOnError ()
 
static Pointer New ()
 

Protected Member Functions

virtual KdTreeNodeTypeGenerateNonterminalNode (unsigned int beginIndex, unsigned int endIndex, MeasurementVectorType &lowerBound, MeasurementVectorType &upperBound, unsigned int level)
 
KdTreeNodeTypeGenerateTreeLoop (unsigned int beginIndex, unsigned int endIndex, MeasurementVectorType &lowerBound, MeasurementVectorType &upperBound, unsigned int level)
 
SubsamplePointer GetSubsample ()
 
 KdTreeGenerator ()
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
 ~KdTreeGenerator () override=default
 
- Protected Member Functions inherited from itk::Object
 Object ()
 
bool PrintObservers (std::ostream &os, Indent indent) const
 
virtual void SetTimeStamp (const TimeStamp &timeStamp)
 
 ~Object () override
 
- 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 Attributes

unsigned int m_BucketSize {}
 
MeasurementVectorSizeType m_MeasurementVectorSize {}
 
TSample * m_SourceSample {}
 
SubsamplePointer m_Subsample {}
 
MeasurementVectorType m_TempLowerBound {}
 
MeasurementVectorType m_TempMean {}
 
MeasurementVectorType m_TempUpperBound {}
 
OutputPointer m_Tree {}
 

Additional Inherited Members

- Protected Attributes inherited from itk::LightObject
std::atomic< int > m_ReferenceCount {}
 

Member Typedef Documentation

◆ ConstPointer

template<typename TSample >
using itk::Statistics::KdTreeGenerator< TSample >::ConstPointer = SmartPointer<const Self>

Definition at line 80 of file itkKdTreeGenerator.h.

◆ KdTreeNodeType

template<typename TSample >
using itk::Statistics::KdTreeGenerator< TSample >::KdTreeNodeType = typename KdTreeType::KdTreeNodeType

Typedef for the k-d tree node type

Definition at line 105 of file itkKdTreeGenerator.h.

◆ KdTreeType

template<typename TSample >
using itk::Statistics::KdTreeGenerator< TSample >::KdTreeType = KdTree<TSample>

Typedef for the k-d tree

Definition at line 96 of file itkKdTreeGenerator.h.

◆ MeasurementType

template<typename TSample >
using itk::Statistics::KdTreeGenerator< TSample >::MeasurementType = typename TSample::MeasurementType

Definition at line 90 of file itkKdTreeGenerator.h.

◆ MeasurementVectorSizeType

template<typename TSample >
using itk::Statistics::KdTreeGenerator< TSample >::MeasurementVectorSizeType = unsigned int

Typedef for the length of each measurement vector

Definition at line 93 of file itkKdTreeGenerator.h.

◆ MeasurementVectorType

template<typename TSample >
using itk::Statistics::KdTreeGenerator< TSample >::MeasurementVectorType = typename TSample::MeasurementVectorType

type alias alias for the source data container

Definition at line 89 of file itkKdTreeGenerator.h.

◆ OutputPointer

template<typename TSample >
using itk::Statistics::KdTreeGenerator< TSample >::OutputPointer = typename KdTreeType::Pointer

Typedef for the smart pointer to the k-d tree

Definition at line 102 of file itkKdTreeGenerator.h.

◆ OutputType

template<typename TSample >
using itk::Statistics::KdTreeGenerator< TSample >::OutputType = KdTreeType

Type alias for the k-d tree type

Definition at line 99 of file itkKdTreeGenerator.h.

◆ Pointer

template<typename TSample >
using itk::Statistics::KdTreeGenerator< TSample >::Pointer = SmartPointer<Self>

Definition at line 79 of file itkKdTreeGenerator.h.

◆ Self

template<typename TSample >
using itk::Statistics::KdTreeGenerator< TSample >::Self = KdTreeGenerator

Standard class type aliases

Definition at line 77 of file itkKdTreeGenerator.h.

◆ SubsamplePointer

template<typename TSample >
using itk::Statistics::KdTreeGenerator< TSample >::SubsamplePointer = typename SubsampleType::Pointer

Typedef for the smart pointer to the Subsample

Definition at line 111 of file itkKdTreeGenerator.h.

◆ SubsampleType

template<typename TSample >
using itk::Statistics::KdTreeGenerator< TSample >::SubsampleType = Subsample<TSample>

Typedef for the internal Subsample

Definition at line 108 of file itkKdTreeGenerator.h.

◆ Superclass

template<typename TSample >
using itk::Statistics::KdTreeGenerator< TSample >::Superclass = Object

Definition at line 78 of file itkKdTreeGenerator.h.

Constructor & Destructor Documentation

◆ KdTreeGenerator()

template<typename TSample >
itk::Statistics::KdTreeGenerator< TSample >::KdTreeGenerator ( )
protected

Constructor

◆ ~KdTreeGenerator()

template<typename TSample >
itk::Statistics::KdTreeGenerator< TSample >::~KdTreeGenerator ( )
overrideprotecteddefault

Destructor

Member Function Documentation

◆ GenerateData()

template<typename TSample >
void itk::Statistics::KdTreeGenerator< TSample >::GenerateData ( )

Runs this k-d tree construction algorithm.

◆ GenerateNonterminalNode()

template<typename TSample >
virtual KdTreeNodeType* itk::Statistics::KdTreeGenerator< TSample >::GenerateNonterminalNode ( unsigned int  beginIndex,
unsigned int  endIndex,
MeasurementVectorType lowerBound,
MeasurementVectorType upperBound,
unsigned int  level 
)
protectedvirtual

Nonterminal node generation routine

Reimplemented in itk::Statistics::WeightedCentroidKdTreeGenerator< TSample >.

◆ GenerateTreeLoop()

template<typename TSample >
KdTreeNodeType* itk::Statistics::KdTreeGenerator< TSample >::GenerateTreeLoop ( unsigned int  beginIndex,
unsigned int  endIndex,
MeasurementVectorType lowerBound,
MeasurementVectorType upperBound,
unsigned int  level 
)
protected

Tree generation loop

◆ GetBucketSize()

template<typename TSample >
virtual unsigned int itk::Statistics::KdTreeGenerator< TSample >::GetBucketSize ( ) const
virtual

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

◆ GetMeasurementVectorSize()

template<typename TSample >
virtual unsigned int itk::Statistics::KdTreeGenerator< TSample >::GetMeasurementVectorSize ( ) const
virtual

Get macro to get the length of the measurement vectors that are being held in the 'sample' that is passed to this class

◆ GetNameOfClass()

template<typename TSample >
const char* itk::Statistics::KdTreeGenerator< TSample >::GetNameOfClass ( ) const
overridevirtual

◆ GetOutput()

template<typename TSample >
OutputPointer itk::Statistics::KdTreeGenerator< TSample >::GetOutput ( )
inline

Returns the pointer to the generated k-d tree.

Definition at line 128 of file itkKdTreeGenerator.h.

◆ GetSourceSample()

template<typename TSample >
virtual TSample* itk::Statistics::KdTreeGenerator< TSample >::GetSourceSample ( ) const
virtual

Set/Get the input sample that provides the measurement vectors.

◆ GetSubsample()

template<typename TSample >
SubsamplePointer itk::Statistics::KdTreeGenerator< TSample >::GetSubsample ( )
inlineprotected

Returns the smart pointer to the internal Subsample object.

Definition at line 160 of file itkKdTreeGenerator.h.

◆ New()

template<typename TSample >
static Pointer itk::Statistics::KdTreeGenerator< TSample >::New ( )
static

Method for creation through the object factory.

◆ PrintSelf()

template<typename TSample >
void itk::Statistics::KdTreeGenerator< TSample >::PrintSelf ( std::ostream &  os,
Indent  indent 
) const
overrideprotectedvirtual

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.

Reimplemented in itk::Statistics::WeightedCentroidKdTreeGenerator< TSample >.

◆ SetBucketSize()

template<typename TSample >
void itk::Statistics::KdTreeGenerator< TSample >::SetBucketSize ( unsigned int  size)

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

◆ SetSample()

template<typename TSample >
void itk::Statistics::KdTreeGenerator< TSample >::SetSample ( TSample *  sample)

Set/Get the input sample that provides the measurement vectors.

◆ Update()

template<typename TSample >
void itk::Statistics::KdTreeGenerator< TSample >::Update ( )
inline

Runs this k-d tree construction algorithm.

Definition at line 135 of file itkKdTreeGenerator.h.

Member Data Documentation

◆ m_BucketSize

template<typename TSample >
unsigned int itk::Statistics::KdTreeGenerator< TSample >::m_BucketSize {}
private

The number of measurement vectors that can be stored in a terminal node.

Definition at line 192 of file itkKdTreeGenerator.h.

◆ m_MeasurementVectorSize

template<typename TSample >
MeasurementVectorSizeType itk::Statistics::KdTreeGenerator< TSample >::m_MeasurementVectorSize {}
private

Length of a measurement vector

Definition at line 207 of file itkKdTreeGenerator.h.

◆ m_SourceSample

template<typename TSample >
TSample* itk::Statistics::KdTreeGenerator< TSample >::m_SourceSample {}
private

Pointer to the input (source) sample

Definition at line 183 of file itkKdTreeGenerator.h.

◆ m_Subsample

template<typename TSample >
SubsamplePointer itk::Statistics::KdTreeGenerator< TSample >::m_Subsample {}
private

Smart pointer to the internal Subsample object. This class needs a Subsample object because the partitioning process involves sorting and selection.

Definition at line 188 of file itkKdTreeGenerator.h.

◆ m_TempLowerBound

template<typename TSample >
MeasurementVectorType itk::Statistics::KdTreeGenerator< TSample >::m_TempLowerBound {}
private

Temporary lower bound for the TreeGenerationLoop

Definition at line 198 of file itkKdTreeGenerator.h.

◆ m_TempMean

template<typename TSample >
MeasurementVectorType itk::Statistics::KdTreeGenerator< TSample >::m_TempMean {}
private

Temporary mean for the TreeGenerationLoop

Definition at line 204 of file itkKdTreeGenerator.h.

◆ m_TempUpperBound

template<typename TSample >
MeasurementVectorType itk::Statistics::KdTreeGenerator< TSample >::m_TempUpperBound {}
private

Temporary upper bound for the TreeGenerationLoop

Definition at line 201 of file itkKdTreeGenerator.h.

◆ m_Tree

template<typename TSample >
OutputPointer itk::Statistics::KdTreeGenerator< TSample >::m_Tree {}
private

Pointer to the resulting k-d tree.

Definition at line 195 of file itkKdTreeGenerator.h.


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