📄 itkhistogram.h
字号:
bool SetFrequency(const IndexType &index,
const FrequencyType value) ;
/** Set the frequency of a measurement. Returns false if the bin is
* out of bounds. */
bool SetFrequency(const MeasurementVectorType &measurement,
const FrequencyType value) ;
/** Increase the frequency of an instance identifier.
* Frequency is increased by the specified value. Returns false if
* the bin is out of bounds. */
bool IncreaseFrequency(const InstanceIdentifier &id,
const FrequencyType value)
{ return m_FrequencyContainer->IncreaseFrequency(id, value) ; }
/** Increase the frequency of an index. Frequency is
* increased by the specified value. Returns false if the bin is out
* of bounds. */
bool IncreaseFrequency(const IndexType &index,
const FrequencyType value) ;
/** Increase the frequency of a measurement. Frequency is
* increased by the specified value. Returns false if the
* measurement is outside the bounds of the histogram. */
bool IncreaseFrequency(const MeasurementVectorType &measurement,
const FrequencyType value) ;
/** Get the measurement of an instance identifier. This is the
* centroid of the bin.
*/
const MeasurementVectorType & GetMeasurementVector(const InstanceIdentifier &id) const;
/** Get the measurement of an index. This is the centroid of the bin. */
const MeasurementVectorType & GetMeasurementVector(const IndexType &index) const;
/** Get the measurement a bin along a specified dimension. This is
* the midpoint of the bin along that dimension. */
MeasurementType GetMeasurement(const unsigned long n,
const unsigned int dimension) const ;
/** Get the total frequency in the histogram*/
TotalFrequencyType GetTotalFrequency() const ;
/** Get the frequency of a dimension's nth element. */
FrequencyType GetFrequency(const unsigned long n,
const unsigned int dimension) const ;
/** Get the pth percentile value for a dimension.
*
* Let assume n = the index of the bin where the p-th percentile value is,
* min = min value of the dimension of the bin,
* max = max value of the dimension of the bin,
* interval = max - min ,
* pp = cumlated proportion until n-1 bin ;
* and pb = frequency of the bin / total frequency of the dimension.
*
* If p is less than 0.5,
* the percentile value =
* min + ((p - pp ) / pb) * interval
* If p is greater than or equal to 0.5
* the percentile value =
* max - ((pp - p) / pb) * interval */
double Quantile(const unsigned int dimension, const double &p) const;
protected:
void PrintSelf(std::ostream& os, Indent indent) const;
public:
/** iterator support */
class Iterator
{
public:
Iterator(){};
Iterator(Self * histogram)
{
m_Id = 0 ;
m_Histogram = histogram;
}
Iterator(InstanceIdentifier id, Self * histogram)
: m_Id(id), m_Histogram(histogram)
{}
FrequencyType GetFrequency() const
{
return m_Histogram->GetFrequency(m_Id) ;
}
bool SetFrequency(const FrequencyType value)
{
return m_Histogram->SetFrequency(m_Id, value);
}
InstanceIdentifier GetInstanceIdentifier() const
{ return m_Id ; }
const MeasurementVectorType & GetMeasurementVector() const
{
return m_Histogram->GetMeasurementVector(m_Id) ;
}
Iterator& operator++()
{
++m_Id;
return *this;
}
bool operator!=(const Iterator& it)
{ return (m_Id != it.m_Id); }
bool operator==(const Iterator& it)
{ return (m_Id == it.m_Id); }
Iterator& operator=(const Iterator& it)
{
m_Id = it.m_Id;
m_Histogram = it.m_Histogram ;
return *this ;
}
Iterator(const Iterator& it)
{
m_Id = it.m_Id;
m_Histogram = it.m_Histogram ;
}
private:
// Iterator pointing DenseFrequencyContainer
InstanceIdentifier m_Id;
// Pointer of DenseFrequencyContainer
Self* m_Histogram ;
} ; // end of iterator class
// Const Iterator
class ConstIterator
{
public:
ConstIterator(){};
ConstIterator(const Self * histogram)
{
m_Id = 0 ;
m_Histogram = histogram;
}
ConstIterator(InstanceIdentifier id, const Self * histogram)
: m_Id(id), m_Histogram(histogram)
{}
FrequencyType GetFrequency() const
{
return m_Histogram->GetFrequency(m_Id) ;
}
InstanceIdentifier GetInstanceIdentifier() const
{ return m_Id ; }
const MeasurementVectorType & GetMeasurementVector() const
{
return m_Histogram->GetMeasurementVector(m_Id) ;
}
ConstIterator& operator++()
{
++m_Id;
return *this;
}
bool operator!=(const ConstIterator& it)
{ return (m_Id != it.m_Id); }
bool operator==(const ConstIterator& it)
{ return (m_Id == it.m_Id); }
ConstIterator& operator=(const ConstIterator& it)
{
m_Id = it.m_Id;
m_Histogram = it.m_Histogram ;
return *this ;
}
ConstIterator(const ConstIterator & it)
{
m_Id = it.m_Id;
m_Histogram = it.m_Histogram ;
}
private:
// ConstIterator pointing DenseFrequencyContainer
InstanceIdentifier m_Id;
// Pointer of DenseFrequencyContainer
const Self* m_Histogram ;
} ; // end of iterator class
Iterator Begin()
{
Iterator iter(0, this) ;
return iter ;
}
Iterator End()
{
return Iterator(m_OffsetTable[VMeasurementVectorSize], this) ;
}
ConstIterator Begin() const
{
ConstIterator iter(0, this) ;
return iter ;
}
ConstIterator End() const
{
return ConstIterator(m_OffsetTable[VMeasurementVectorSize], this) ;
}
virtual void SetMeasurementVectorSize( const MeasurementVectorSizeType s )
{
if( s!= VMeasurementVectorSize )
{
itkExceptionMacro( << "This Histogram class is meant to be used only for "
<< "fixed length vectors of length " << VMeasurementVectorSize <<
". Cannot set this to " << s);
}
}
MeasurementVectorSizeType GetMeasurementVectorSize() const
{
return VMeasurementVectorSize;
}
protected:
Histogram() ;
virtual ~Histogram() {}
// The number of bins for each dimension
SizeType m_Size ;
private:
Histogram(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
InstanceIdentifier m_OffsetTable[VMeasurementVectorSize + 1] ;
FrequencyContainerPointer m_FrequencyContainer ;
unsigned int m_NumberOfInstances ;
// lower bound of each bin
std::vector< std::vector<MeasurementType> > m_Min ;
// upper bound of each bin
std::vector< std::vector<MeasurementType> > m_Max ;
mutable MeasurementVectorType m_TempMeasurementVector ;
mutable IndexType m_TempIndex ;
bool m_ClipBinsAtEnds;
} ;
} // end of namespace Statistics
} // end of namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkHistogram.txx"
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -