Public Types | Public Member Functions | Protected Member Functions | Private Attributes

cmtk::Histogram< T > Class Template Reference
[cmtkBase Library]

Histogram of a distribution with bins of arbitrary types. More...

#include <cmtkHistogram.h>

Inheritance diagram for cmtk::Histogram< T >:
Inheritance graph
[legend]
Collaboration diagram for cmtk::Histogram< T >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef Histogram< T > Self
 This class.
typedef HistogramBase Superclass
 Parent class.
typedef SmartPointer< SelfSmartPtr
 Smart pointer.
typedef T BinType
 Bin type.

Public Member Functions

 Histogram (const size_t numBins=0)
 Constructor.
virtual ~Histogram ()
 Destructor.
virtual void Resize (const size_t numberOfBins, const bool reset=true)
 Resize and allocate histogram bins.
Self::SmartPtr Clone () const
 Make an identical copy of this object.
virtual size_t GetNumBins () const
 Return number of histogram bins.
void Reset ()
 Reset computation.
const T operator[] (const size_t index) const
 Return number of values in a given bin using [] operator.
T & operator[] (const size_t index)
 Return reference to given bin.
SampleCount () const
 Return total number of samples stored in the histogram.
size_t GetMaximumBinIndex () const
 Return index of bin with highest value.
GetMaximumBinValue () const
 Return maximum number of samples stored in any bin.
double GetEntropy () const
 Compute entropy of distribution.
double GetKullbackLeiblerDivergence (const Self &other) const
 Get Kullback-Leibler divergence to other histogram.
void Increment (const size_t sample)
 Increment the value of a histogram bin by 1.
void AddWeightedSymmetricKernel (const size_t bin, const size_t kernelRadius, const T *kernel, const T factor=1)
 Add weighted symmetric kernel to histogram.
void AddWeightedSymmetricKernelFractional (const double bin, const size_t kernelRadius, const T *kernel, const T factor=1)
 Add weighted symmetric kernel to histogram, spreading contriubtions between adjacent bins.
void IncrementFractional (const double bin)
 Increment the value of a histogram bins by fractions of 1.
void Increment (const size_t sample, const double weight)
 Increment the value of a histogram bin by a given weight.
void Decrement (const size_t sample)
 Decrement the value of a histogram bin by 1.
void DecrementFractional (const double bin)
 Decrement the value of a histogram bins by fractions of 1.
void Decrement (const size_t sample, const double weight)
 Decrement the value of a histogram bin by given weight.
void AddHistogram (const Self &other)
 Add values from another histogram.
void RemoveHistogram (const Self &other)
 Subtract bin values from another histogram.
void ConvertToCumulative ()
 Convert this histogram to a cumulative histogram (in place).
void Normalize (const T normalizeTo=1)
 Normalize histogram values by their total sum.
void NormalizeMaximum (const T normalizeTo=1)
 Normalize histogram values by their maximum.
Types::DataItem GetPercentile (const Types::DataItem percentile) const
 Compute approximate percentile value from histogram.

Protected Member Functions

virtual SelfCloneVirtual () const
 Make an identical copy of this object including derived class objects.

Private Attributes

std::vector< T > m_Bins
 Array bins.

Detailed Description

template<class T>
class cmtk::Histogram< T >

Histogram of a distribution with bins of arbitrary types.

This template is the base class for one-dimensional histograms that can hold integer or real-valued bins, depending on the template parameter.

Parameters:
TTemplate parameter: the type of the histogram bins. Can be integral, or double in case of fractional bins.
FFTemplate parameter: boolean double flag. Instantiations need to make sure that this parameter is true whenever the instatiated class implements fractional bins, ie., when T is either double or double, and false otherwise.

Definition at line 64 of file cmtkHistogram.h.


Member Typedef Documentation

template<class T>
typedef T cmtk::Histogram< T >::BinType

Bin type.

Definition at line 79 of file cmtkHistogram.h.

template<class T>
typedef Histogram<T> cmtk::Histogram< T >::Self

This class.

Reimplemented from cmtk::HistogramBase.

Reimplemented in cmtk::LogHistogram< T >.

Definition at line 70 of file cmtkHistogram.h.

template<class T>
typedef SmartPointer<Self> cmtk::Histogram< T >::SmartPtr

Smart pointer.

Reimplemented in cmtk::LogHistogram< T >.

Definition at line 76 of file cmtkHistogram.h.

template<class T>
typedef HistogramBase cmtk::Histogram< T >::Superclass

Parent class.

Reimplemented in cmtk::LogHistogram< T >.

Definition at line 73 of file cmtkHistogram.h.


Constructor & Destructor Documentation

template<class T>
cmtk::Histogram< T >::Histogram ( const size_t  numBins = 0 ) [inline]

Constructor.

Definition at line 83 of file cmtkHistogram.h.

template<class T>
virtual cmtk::Histogram< T >::~Histogram (  ) [inline, virtual]

Destructor.

Definition at line 87 of file cmtkHistogram.h.


Member Function Documentation

template<class T>
Self::SmartPtr cmtk::Histogram< T >::Clone (  ) const [inline]

Make an identical copy of this object.

Reimplemented in cmtk::LogHistogram< T >.

Definition at line 99 of file cmtkHistogram.h.

Referenced by cmtk::TypedArrayFunctionHistogramMatching::TypedArrayFunctionHistogramMatching().

template<class T>
virtual Self* cmtk::Histogram< T >::CloneVirtual (  ) const [inline, protected, virtual]

Make an identical copy of this object including derived class objects.

Reimplemented in cmtk::LogHistogram< T >.

Definition at line 313 of file cmtkHistogram.h.

template<class T>
void cmtk::Histogram< T >::ConvertToCumulative (  ) [inline]
template<class T>
void cmtk::Histogram< T >::Decrement ( const size_t  sample,
const double  weight 
) [inline]

Decrement the value of a histogram bin by given weight.

The histogram field to decrement is identified directly by its index; no value-rescaling is done internally. Make sure that a value has actually been added to this bin before - otherwise, the next entropy computation my give some unexpected results.

Parameters:
sampleIndex of histogram field in direction.
weightWeight of the current value, i.e., real value that the given bin is decremented by.

Definition at line 258 of file cmtkHistogram.h.

template<class T>
void cmtk::Histogram< T >::Decrement ( const size_t  sample ) [inline]

Decrement the value of a histogram bin by 1.

The histogram field to decrement is identified directly by its index; no value-rescaling is done internally. Make sure that a value has actually been added to this bin before - otherwise, the next entropy computation my give some unexpected results.

Parameters:
sampleIndex of histogram field in direction.

Definition at line 226 of file cmtkHistogram.h.

template<class T>
void cmtk::Histogram< T >::DecrementFractional ( const double  bin ) [inline]

Decrement the value of a histogram bins by fractions of 1.

The histogram field to increment is identified directly by its index; no value-rescaling is done internally. The index for this function can be a fractional value, in which case the entry is linearly distributed among neighbouring bins.

Note:
If the bin type of this template object is an integer type, then only the lower of two candidate bins will be decremented by 1.
Parameters:
binFractional index of histogram bin.

Definition at line 241 of file cmtkHistogram.h.

template<class T>
T cmtk::Histogram< T >::GetMaximumBinValue (  ) const [inline]

Return maximum number of samples stored in any bin.

Definition at line 153 of file cmtkHistogram.h.

template<class T>
virtual size_t cmtk::Histogram< T >::GetNumBins (  ) const [inline, virtual]
template<class T>
void cmtk::Histogram< T >::Increment ( const size_t  sample,
const double  weight 
) [inline]

Increment the value of a histogram bin by a given weight.

The histogram field to increment is identified directly by its index; no value-rescaling is done internally.

Parameters:
sampleIndex of histogram field.
weightWeight of the current value, i.e., real value that the given bin is incremented by.

Definition at line 214 of file cmtkHistogram.h.

template<class T>
void cmtk::Histogram< T >::Increment ( const size_t  sample ) [inline]

Increment the value of a histogram bin by 1.

The histogram field to increment is identified directly by its index; no value-rescaling is done internally.

Parameters:
sampleIndex of histogram field.

Definition at line 177 of file cmtkHistogram.h.

Referenced by cmtk::TypedArraySimilarity::GetCorrelationRatio(), cmtk::TemplateArray< T >::GetEntropy(), cmtk::TemplateArray< T >::GetHistogram(), and cmtk::SplineWarpMultiChannelRegistrationFunctional< TMetricFunctional >::UpdateTransformationFixedControlPoints().

template<class T>
void cmtk::Histogram< T >::IncrementFractional ( const double  bin ) [inline]

Increment the value of a histogram bins by fractions of 1.

The histogram field to increment is identified directly by its index; no value-rescaling is done internally. The index for this function can be a fractional value, in which case the entry is linearly distributed among neighbouring bins.

Note:
If the bin type of this template object is an integer type, then only the lower of two candidate bins will be decremented by 1.
Parameters:
binFractional index of histogram bin.

Definition at line 199 of file cmtkHistogram.h.

Referenced by cmtk::TemplateArray< T >::GetEntropy().

template<class T>
const T cmtk::Histogram< T >::operator[] ( const size_t  index ) const [inline]

Return number of values in a given bin using [] operator.

Definition at line 122 of file cmtkHistogram.h.

template<class T>
T& cmtk::Histogram< T >::operator[] ( const size_t  index ) [inline]

Return reference to given bin.

Definition at line 129 of file cmtkHistogram.h.

template<class T>
void cmtk::Histogram< T >::Reset (  ) [inline]

Reset computation.

This function has to be called before any other computation made with an object of this class. All bin counters are reset to zero, therefore Reset() must also be called before any new computation performed using an already previously used object.

Definition at line 116 of file cmtkHistogram.h.

Referenced by cmtk::CongealingFunctional< TXform >::EvaluateProbabilisticThread(), cmtk::CongealingFunctional< TXform >::EvaluateThread(), cmtk::TemplateArray< T >::GetEntropy(), and cmtk::FilterVolume::RohlfingFilter().

template<class T>
virtual void cmtk::Histogram< T >::Resize ( const size_t  numberOfBins,
const bool  reset = true 
) [inline, virtual]

Resize and allocate histogram bins.

Reimplemented in cmtk::LogHistogram< T >.

Definition at line 90 of file cmtkHistogram.h.

Referenced by cmtk::CongealingFunctional< TXform >::EvaluateProbabilisticThread(), and cmtk::CongealingFunctional< TXform >::EvaluateThread().

template<class T>
T cmtk::Histogram< T >::SampleCount (  ) const [inline]

Member Data Documentation

template<class T>
std::vector<T> cmtk::Histogram< T >::m_Bins [private]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines