Histogram of a distribution with bins of arbitrary types. More...
#include <cmtkHistogram.h>
Public Types | |
typedef Histogram< T > | Self |
This class. | |
typedef HistogramBase | Superclass |
Parent class. | |
typedef SmartPointer< Self > | SmartPtr |
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. | |
T | SampleCount () const |
Return total number of samples stored in the histogram. | |
size_t | GetMaximumBinIndex () const |
Return index of bin with highest value. | |
T | 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 Self * | CloneVirtual () const |
Make an identical copy of this object including derived class objects. | |
Private Attributes | |
std::vector< T > | m_Bins |
Array bins. |
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.
T | Template parameter: the type of the histogram bins. Can be integral, or double in case of fractional bins. |
FF | Template 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.
typedef T cmtk::Histogram< T >::BinType |
Bin type.
Definition at line 79 of file cmtkHistogram.h.
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.
typedef SmartPointer<Self> cmtk::Histogram< T >::SmartPtr |
Smart pointer.
Reimplemented in cmtk::LogHistogram< T >.
Definition at line 76 of file cmtkHistogram.h.
typedef HistogramBase cmtk::Histogram< T >::Superclass |
Parent class.
Reimplemented in cmtk::LogHistogram< T >.
Definition at line 73 of file cmtkHistogram.h.
cmtk::Histogram< T >::Histogram | ( | const size_t | numBins = 0 ) |
[inline] |
Constructor.
Definition at line 83 of file cmtkHistogram.h.
virtual cmtk::Histogram< T >::~Histogram | ( | ) | [inline, virtual] |
Destructor.
Definition at line 87 of file cmtkHistogram.h.
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().
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.
void cmtk::Histogram< T >::ConvertToCumulative | ( | ) | [inline] |
Convert this histogram to a cumulative histogram (in place).
Definition at line 288 of file cmtkHistogram.h.
Referenced by cmtk::TypedArrayFunctionHistogramEqualization::TypedArrayFunctionHistogramEqualization(), and cmtk::TypedArrayFunctionHistogramMatching::TypedArrayFunctionHistogramMatching().
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.
sample | Index of histogram field in direction. |
weight | Weight of the current value, i.e., real value that the given bin is decremented by. |
Definition at line 258 of file cmtkHistogram.h.
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.
sample | Index of histogram field in direction. |
Definition at line 226 of file cmtkHistogram.h.
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.
bin | Fractional index of histogram bin. |
Definition at line 241 of file cmtkHistogram.h.
T cmtk::Histogram< T >::GetMaximumBinValue | ( | ) | const [inline] |
Return maximum number of samples stored in any bin.
Definition at line 153 of file cmtkHistogram.h.
virtual size_t cmtk::Histogram< T >::GetNumBins | ( | ) | const [inline, virtual] |
Return number of histogram bins.
Implements cmtk::HistogramBase.
Definition at line 105 of file cmtkHistogram.h.
Referenced by cmtk::Histogram< T >::AddHistogram(), cmtk::TypedArrayNoiseEstimatorBrummer::EstimateNumBinsToUse(), cmtk::Histogram< T >::GetKullbackLeiblerDivergence(), cmtk::Histogram< T >::RemoveHistogram(), and cmtk::TypedArrayNoiseEstimatorBrummer::SijbersBiasHat().
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.
sample | Index of histogram field. |
weight | Weight of the current value, i.e., real value that the given bin is incremented by. |
Definition at line 214 of file cmtkHistogram.h.
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.
sample | Index 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().
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.
bin | Fractional index of histogram bin. |
Definition at line 199 of file cmtkHistogram.h.
Referenced by cmtk::TemplateArray< T >::GetEntropy().
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.
T& cmtk::Histogram< T >::operator[] | ( | const size_t | index ) | [inline] |
Return reference to given bin.
Definition at line 129 of file cmtkHistogram.h.
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().
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().
T cmtk::Histogram< T >::SampleCount | ( | ) | const [inline] |
Return total number of samples stored in the histogram.
Definition at line 137 of file cmtkHistogram.h.
Referenced by cmtk::TypedArraySimilarity::GetCorrelationRatio(), cmtk::Histogram< T >::GetKullbackLeiblerDivergence(), and cmtk::TypedArrayNoiseEstimatorBrummer::TypedArrayNoiseEstimatorBrummer().
std::vector<T> cmtk::Histogram< T >::m_Bins [private] |
Array bins.
Definition at line 320 of file cmtkHistogram.h.
Referenced by cmtk::Histogram< T >::AddHistogram(), cmtk::Histogram< T >::GetKullbackLeiblerDivergence(), and cmtk::Histogram< T >::RemoveHistogram().