63template <
typename TSample>
147template <
typename TSample>
236 this->m_InstanceIdentifier = valueId;
240 unsigned int m_PartitionDimension{};
263template <
typename TSample>
296 return m_MeasurementVectorSize;
340 centroid = m_WeightedCentroid;
349 centroid = m_Centroid;
365 this->m_InstanceIdentifier = valueId;
370 unsigned int m_PartitionDimension{};
375 unsigned int m_Size{};
393template <
typename TSample>
449 return static_cast<unsigned int>(m_InstanceIdentifiers.size());
476 return m_InstanceIdentifiers[index];
485 m_InstanceIdentifiers.push_back(
id);
489 std::vector<InstanceIdentifier> m_InstanceIdentifiers{};
526template <
typename TSample>
530 ITK_DISALLOW_COPY_AND_MOVE(
KdTree);
587 : m_FarthestNeighborIndex(0)
588 , m_Distances(cache_vector)
600 m_Identifiers.clear();
604 m_FarthestNeighborIndex = 0;
612 return m_Distances[m_FarthestNeighborIndex];
620 m_Identifiers[m_FarthestNeighborIndex] = id;
621 m_Distances[m_FarthestNeighborIndex] = distance;
623 const auto size =
static_cast<unsigned int>(m_Distances.size());
624 for (
unsigned int i = 0; i < size; ++i)
626 if (m_Distances[i] > farthestDistance)
628 farthestDistance = m_Distances[i];
629 m_FarthestNeighborIndex = i;
639 return m_Identifiers;
647 return m_Identifiers[index];
683 return m_Sample->Size();
693 return m_EmptyTerminalNode;
703 this->DeleteNode(this->m_Root);
718 const MeasurementVectorType &
721 return m_Sample->GetMeasurementVector(
id);
726 AbsoluteFrequencyType
729 return m_Sample->GetFrequency(
id);
736 return m_DistanceMetric.GetPointer();
820 const TSample * m_Sample{};
840#ifndef ITK_MANUAL_INSTANTIATION
841# include "itkKdTree.hxx"
Control indentation during Print() invocation.
Light weight base class for most itk classes.
Define additional traits for native types such as int or float.
static constexpr T min(const T &)
Base class for most ITK classes.
Euclidean distance function.
data structure for storing k-nearest neighbor search result (k number of Neighbors)
std::vector< double > & m_Distances
InstanceIdentifier GetNeighbor(unsigned int index) const
InstanceIdentifierVectorType m_Identifiers
~NearestNeighbors()=default
NearestNeighbors(std::vector< double > &cache_vector)
double GetLargestDistance()
unsigned int m_FarthestNeighborIndex
NearestNeighbors()=delete
void resize(unsigned int k)
const InstanceIdentifierVectorType & GetNeighbors() const
void ReplaceFarthestNeighbor(InstanceIdentifier id, double distance)
This class provides methods for k-nearest neighbor search and related data structures for a k-d tree.
KdTreeNodeType * GetRoot()
void PlotTree(std::ostream &os) const
KdTreeNodeType * GetEmptyTerminalNode()
const TSample * GetSample() const
void SetBucketSize(unsigned int)
void SetRoot(KdTreeNodeType *root)
void Search(const MeasurementVectorType &, unsigned int, InstanceIdentifierVectorType &) const
typename TSample::InstanceIdentifier InstanceIdentifier
SizeValueType Size() const
bool BoundsOverlapBall(const MeasurementVectorType &, MeasurementVectorType &, MeasurementVectorType &, double) const
DistanceMetricType * GetDistanceMetric()
const MeasurementVectorType & GetMeasurementVector(InstanceIdentifier id) const
typename TSample::AbsoluteFrequencyType AbsoluteFrequencyType
std::pair< InstanceIdentifier, double > NeighborType
void PrintTree(KdTreeNodeType *, unsigned int, unsigned int, std::ostream &os=std::cout) const
std::vector< InstanceIdentifier > InstanceIdentifierVectorType
typename TSample::MeasurementType MeasurementType
void Search(const MeasurementVectorType &, unsigned int, InstanceIdentifierVectorType &, std::vector< double > &) const
void PrintSelf(std::ostream &os, Indent indent) const override
int SearchLoop(const KdTreeNodeType *, const MeasurementVectorType &, double, MeasurementVectorType &, MeasurementVectorType &, InstanceIdentifierVectorType &) const
unsigned int MeasurementVectorSizeType
typename TSample::Iterator Iterator
int NearestNeighborSearchLoop(const KdTreeNodeType *, const MeasurementVectorType &, MeasurementVectorType &, MeasurementVectorType &, NearestNeighbors &) const
bool BallWithinBounds(const MeasurementVectorType &, MeasurementVectorType &, MeasurementVectorType &, double) const
void SetSample(const TSample *)
void PlotTree(KdTreeNodeType *node, std::ostream &os=std::cout) const
AbsoluteFrequencyType GetFrequency(InstanceIdentifier id) const
typename TSample::ConstIterator ConstIterator
typename TSample::MeasurementVectorType MeasurementVectorType
void Search(const MeasurementVectorType &, double, InstanceIdentifierVectorType &) const
void PrintTree(std::ostream &) const
void DeleteNode(KdTreeNodeType *)
BinaryGeneratorImageFilter< TInputImage1, TInputImage2, TOutputImage > Superclass
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
This class defines the interface of its derived classes.
typename TSample::InstanceIdentifier InstanceIdentifier
virtual void GetParameters(unsigned int &, MeasurementType &) const =0
virtual InstanceIdentifier GetInstanceIdentifier(InstanceIdentifier) const =0
virtual bool IsTerminal() const =0
virtual void GetCentroid(CentroidType &)=0
typename TSample::MeasurementType MeasurementType
virtual void AddInstanceIdentifier(InstanceIdentifier)=0
virtual void GetWeightedCentroid(CentroidType &)=0
virtual unsigned int Size() const =0
virtual const Self * Left() const =0
virtual ~KdTreeNode()=default
virtual const Self * Right() const =0
This is a subclass of the KdTreeNode.
bool IsTerminal() const override
const Superclass * Right() const override
unsigned int Size() const override
const Superclass * Left() const override
void GetWeightedCentroid(CentroidType &) override
Superclass * Right() override
void GetParameters(unsigned int &, MeasurementType &) const override
InstanceIdentifier GetInstanceIdentifier(InstanceIdentifier) const override
void GetCentroid(CentroidType &) override
KdTreeNonterminalNode(unsigned int, MeasurementType, Superclass *, Superclass *)
~KdTreeNonterminalNode() override=default
Superclass * Left() override
void AddInstanceIdentifier(InstanceIdentifier valueId) override
This class is the node that doesn't have any child node. The IsTerminal method returns true for this ...
void GetParameters(unsigned int &, MeasurementType &) const override
~KdTreeTerminalNode() override
void GetCentroid(CentroidType &) override
bool IsTerminal() const override
void GetWeightedCentroid(CentroidType &) override
InstanceIdentifier GetInstanceIdentifier(InstanceIdentifier index) const override
const Superclass * Right() const override
KdTreeTerminalNode()=default
Superclass * Right() override
const Superclass * Left() const override
unsigned int Size() const override
void AddInstanceIdentifier(InstanceIdentifier id) override
Superclass * Left() override
This is a subclass of the KdTreeNode.
~KdTreeWeightedCentroidNonterminalNode() override=default
KdTreeWeightedCentroidNonterminalNode(unsigned int, MeasurementType, Superclass *, Superclass *, CentroidType &, unsigned int)
void GetWeightedCentroid(CentroidType ¢roid) override
void GetCentroid(CentroidType ¢roid) override
InstanceIdentifier GetInstanceIdentifier(InstanceIdentifier) const override
MeasurementVectorSizeType GetMeasurementVectorSize() const
const Superclass * Left() const override
unsigned int Size() const override
Superclass * Left() override
bool IsTerminal() const override
typename TSample::MeasurementVectorSizeType MeasurementVectorSizeType
Superclass * Right() override
const Superclass * Right() const override
void GetParameters(unsigned int &, MeasurementType &) const override
void AddInstanceIdentifier(InstanceIdentifier valueId) override