62 template<
typename TSample>
81 virtual bool IsTerminal()
const = 0;
88 virtual void GetParameters(
unsigned int &,
MeasurementType & )
const = 0;
91 virtual Self * Left() = 0;
94 virtual const Self * Left()
const = 0;
97 virtual Self * Right() = 0;
100 virtual const Self * Right()
const = 0;
106 virtual unsigned int Size()
const = 0;
136 template<
typename TSample>
155 void GetParameters(
unsigned int &, MeasurementType & )
const override;
185 unsigned int Size()
const override
209 return this->m_InstanceIdentifier;
217 this->m_InstanceIdentifier = valueId;
244 template<
typename TSample>
265 void GetParameters(
unsigned int &, MeasurementType & )
const override;
270 return m_MeasurementVectorSize;
298 unsigned int Size()
const override
308 centroid = m_WeightedCentroid;
316 centroid = m_Centroid;
326 return this->m_InstanceIdentifier;
334 this->m_InstanceIdentifier = valueId;
361 template<
typename TSample>
373 this->m_InstanceIdentifiers.clear();
410 unsigned int Size()
const override
412 return static_cast< unsigned int >( m_InstanceIdentifiers.size() );
434 return m_InstanceIdentifiers[index];
442 m_InstanceIdentifiers.push_back(
id );
482 template<
typename TSample>
486 ITK_DISALLOW_COPY_AND_ASSIGN(
KdTree);
540 NearestNeighbors( std::vector<double> & cache_vector) : m_FarthestNeighborIndex(0), m_Distances(cache_vector) {}
549 m_Identifiers.clear();
553 m_FarthestNeighborIndex = 0;
560 return m_Distances[m_FarthestNeighborIndex];
567 m_Identifiers[m_FarthestNeighborIndex] = id;
568 m_Distances[m_FarthestNeighborIndex] = distance;
570 const auto size =
static_cast< unsigned int >( m_Distances.size() );
571 for (
unsigned int i = 0; i < size; i++ )
573 if ( m_Distances[i] > farthestDistance )
575 farthestDistance = m_Distances[i];
576 m_FarthestNeighborIndex = i;
585 return m_Identifiers;
592 return m_Identifiers[index];
611 void SetBucketSize(
unsigned int );
615 void SetSample(
const TSample * );
625 return m_Sample->Size();
634 return m_EmptyTerminalNode;
643 this->DeleteNode( this->m_Root );
660 return m_Sample->GetMeasurementVector(
id );
667 return m_Sample->GetFrequency(
id );
673 return m_DistanceMetric.GetPointer();
677 void Search(
const MeasurementVectorType &,
unsigned int,
678 InstanceIdentifierVectorType & )
const;
683 void Search(
const MeasurementVectorType &,
unsigned int,
684 InstanceIdentifierVectorType &, std::vector<double> & )
const;
687 void Search(
const MeasurementVectorType &,
double,
688 InstanceIdentifierVectorType & )
const;
695 bool BallWithinBounds(
const MeasurementVectorType &,
696 MeasurementVectorType &, MeasurementVectorType &,
double )
const;
701 bool BoundsOverlapBall(
const MeasurementVectorType &,
702 MeasurementVectorType &, MeasurementVectorType &,
double)
const;
705 void DeleteNode( KdTreeNodeType * );
708 void PrintTree( std::ostream & )
const;
711 void PrintTree( KdTreeNodeType *,
unsigned int,
unsigned int,
712 std::ostream & os = std::cout )
const;
716 void PlotTree( std::ostream & os )
const;
719 void PlotTree( KdTreeNodeType *node, std::ostream & os = std::cout )
const;
731 void PrintSelf( std::ostream & os,
Indent indent )
const override;
765 #ifndef ITK_MANUAL_INSTANTIATION
766 #include "itkKdTree.hxx"
const MeasurementVectorType & GetMeasurementVector(InstanceIdentifier id) const
Superclass * Left() override
unsigned int m_FarthestNeighborIndex
Light weight base class for most itk classes.
KdTreeNodeType * GetEmptyTerminalNode()
typename TSample::MeasurementType MeasurementType
typename TSample::MeasurementType MeasurementType
KdTreeNodeType * GetRoot()
This class defines the interface of its derived classes.
This is a subclass of the KdTreeNode.
Define numeric traits for std::vector.
unsigned long SizeValueType
Superclass * Right() override
void ReplaceFarthestNeighbor(InstanceIdentifier id, double distance)
void GetWeightedCentroid(CentroidType ¢roid) override
std::pair< InstanceIdentifier, double > NeighborType
unsigned int Size() const override
void GetCentroid(CentroidType ¢roid) override
Superclass * Left() override
MeasurementType m_PartitionValue
~KdTreeTerminalNode() override
typename TSample::MeasurementVectorType MeasurementVectorType
SizeValueType Size() const
Euclidean distance function.
const Superclass * Right() const override
const Superclass * Left() const override
std::vector< InstanceIdentifier > InstanceIdentifierVectorType
InstanceIdentifier m_InstanceIdentifier
data structure for storing k-nearest neighbor search result (k number of Neighbors) ...
This class is the node that doesn't have any child node. The IsTerminal method returns true for this ...
unsigned int Size() const override
bool IsTerminal() const override
void GetCentroid(CentroidType &) override
MeasurementType m_PartitionValue
InstanceIdentifier m_InstanceIdentifier
const InstanceIdentifierVectorType & GetNeighbors() const
DistanceMetricType * GetDistanceMetric()
void GetWeightedCentroid(CentroidType &) override
void SetRoot(KdTreeNodeType *root)
typename TSample::AbsoluteFrequencyType AbsoluteFrequencyType
const Superclass * Left() const override
Superclass * Right() override
This is a subclass of the KdTreeNode.
InstanceIdentifier GetInstanceIdentifier(InstanceIdentifier) const override
bool IsTerminal() const override
KdTreeNodeType * m_EmptyTerminalNode
Represent a n-dimensional size (bounds) of a n-dimensional image.
Superclass * Right() override
const Superclass * Left() const override
MeasurementVectorSizeType GetMeasurementVectorSize() const
AbsoluteFrequencyType GetFrequency(InstanceIdentifier id) const
double GetLargestDistance()
unsigned int MeasurementVectorSizeType
const Superclass * Right() const override
typename TSample::InstanceIdentifier InstanceIdentifier
DistanceMetricType::Pointer m_DistanceMetric
void GetCentroid(CentroidType &) override
InstanceIdentifier GetNeighbor(unsigned int index) const
std::vector< double > & m_Distances
std::vector< InstanceIdentifier > m_InstanceIdentifiers
MeasurementVectorSizeType m_MeasurementVectorSize
void AddInstanceIdentifier(InstanceIdentifier valueId) override
void AddInstanceIdentifier(InstanceIdentifier valueId) override
void resize(unsigned int k)
InstanceIdentifier GetInstanceIdentifier(InstanceIdentifier index) const override
unsigned int Size() const override
void AddInstanceIdentifier(InstanceIdentifier id) override
const Superclass * Right() const override
void GetParameters(unsigned int &, MeasurementType &) const override
Control indentation during Print() invocation.
typename TSample::InstanceIdentifier InstanceIdentifier
bool IsTerminal() const override
unsigned int m_PartitionDimension
typename TSample::Iterator Iterator
InstanceIdentifierVectorType m_Identifiers
MeasurementVectorSizeType m_MeasurementVectorSize
const TSample * GetSample() const
Base class for most ITK classes.
Superclass * Left() override
NearestNeighbors(std::vector< double > &cache_vector)
This class provides methods for k-nearest neighbor search and related data structures for a k-d tree...
unsigned int m_PartitionDimension
typename TSample::ConstIterator ConstIterator
typename TSample::MeasurementVectorSizeType MeasurementVectorSizeType
void GetWeightedCentroid(CentroidType &) override
InstanceIdentifier GetInstanceIdentifier(InstanceIdentifier) const override
CentroidType m_WeightedCentroid