Public Types | Public Member Functions | Protected Attributes

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

Joint histogram of two distributions. More...

#include <cmtkJointHistogram.h>

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

List of all members.

Public Types

typedef JointHistogram< T > Self
 This class.
typedef SmartPointer< SelfSmartPtr
 Smart pointer.

Public Member Functions

 JointHistogram ()
 Default constructor.
 JointHistogram (const size_t numBinsX, const size_t numBinsY, const bool reset=true)
 Constructor.
SelfClone () const
 Make an identical copy of this object.
void Resize (const size_t numberOfBinsX, const size_t numberOfBinsY, const bool reset=true)
 Resize and allocate histogram bins.
size_t GetNumBinsX () const
 Return number of histogram bins in X direction.
size_t GetNumBinsY () const
 Return number of histogram bins in Y direction.
void SetRangeX (const Types::DataItemRange &range)
 Set value range of the X distribution.
void SetRangeY (const Types::DataItemRange &range)
 Set value range of the Y distribution.
void SetRangeCenteredX (const Types::DataItemRange &range)
 Set value range of the X distribution where upper and lower bound are centered in first and last histogram bins.
void SetRangeCenteredY (const Types::DataItemRange &range)
 Set value range of the Y distribution where upper and lower bound are centered in first and last histogram bins.
const Types::DataItemRange GetRangeX () const
 Get value range of the X distribution.
const Types::DataItemRange GetRangeY () const
 Get value range of the Y distribution.
void Reset ()
 Reset computation.
size_t ValueToBinX (const Types::DataItem value) const
 Return bin corresponding to a certain value of the X distribution.
size_t ValueToBinY (const Types::DataItem value) const
 Return bin corresponding to a certain value of the Y distribution.
Types::DataItem BinToValueX (const size_t bin) const
 Return center of values represented by a certain X distribution bin.
Types::DataItem BinToValueY (const size_t bin) const
 Return center of values represented by a certain Y distribution bin.
ProjectToX (const size_t indexX) const
 Return projection of 2D distribution to X.
ProjectToY (const size_t indexY) const
 Return projection of 2D distribution to Y.
Histogram< T > * GetMarginalX () const
 Get marginal X distribution as 1D histogram.
Histogram< T > * GetMarginalY () const
 Get marginal Y distribution as 1D histogram.
GetBin (const size_t indexX, const size_t indexY) const
 Return a bin value.
SampleCount () const
 Return total number of samples stored in the histogram.
GetMaximumBinValue () const
 Return maximum number of samples stored in any bin.
void GetMarginalEntropies (double &HX, double &HY) const
 Compute marginal entropies.
double GetJointEntropy () const
 Compute joint entropy.
void Increment (const size_t sampleX, const size_t sampleY)
 Increment the value of a histogram bin by 1.
void Increment (const size_t sampleX, const size_t sampleY, const T weight)
 Increment the value of a histogram bin by an arbitrary value.
void Decrement (const size_t sampleX, const size_t sampleY)
 Decrement the value of a histogram bin by 1.
void Decrement (const size_t sampleX, const size_t sampleY, const Types::DataItem weight)
void AddJointHistogram (const Self &other)
 Add values from another histogram.
void AddHistogramRow (const Histogram< T > &other, const size_t sampleY, const float weight=1)
 Add values from another 1D histogram in X-direction.
void AddHistogramColumn (const size_t sampleX, const Histogram< T > &other, const float weight=1)
 Add values from another 1D histogram in Y-direction.
void RemoveJointHistogram (const Self &other)
 Subtract bin values from another histogram.
void NormalizeOverX (const double normalizeTo=1.0)
 Normalize histogram values over X dimension.
void NormalizeOverY (const double normalizeTo=1.0)
 Normalize histogram values over Y dimension.
size_t GetMaximumBinIndexOverX (const size_t j) const
size_t GetMaximumBinIndexOverY (const size_t i) const
double GetMutualInformation (const bool normalized=false) const
 Compute the (normalized) mutual information of this histogram.
double GetCorrelationRatio () const
 Compute the Correlation Ratio corresponding to this histogram.

Protected Attributes

size_t NumBinsX
 Number of reference data bins.
Types::DataItem BinWidthX
 Width of reference data bins.
Types::DataItem BinOffsetX
 Lower value bound of reference data bins.
size_t NumBinsY
 Number of model data bins.
Types::DataItem BinWidthY
 Width of model data bins.
Types::DataItem BinOffsetY
 Lower value bound of model data bins.
std::vector< T > JointBins
 Array of cross-modality (joint) bins.
size_t m_TotalNumberOfBins
 Total number of bins, ie., NumBinsX*NumBinsY.

Detailed Description

template<class T>
class cmtk::JointHistogram< T >

Joint histogram of two distributions.

Parameters:
TTemplate parameter: the type of the histogram bins. Can be integral, or float in case of fractional bins.

Definition at line 62 of file cmtkJointHistogram.h.


Member Typedef Documentation

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

Constructor & Destructor Documentation

template<class T>
cmtk::JointHistogram< T >::JointHistogram (  ) [inline]

Default constructor.

Definition at line 100 of file cmtkJointHistogram.h.

template<class T>
cmtk::JointHistogram< T >::JointHistogram ( const size_t  numBinsX,
const size_t  numBinsY,
const bool  reset = true 
) [inline]

Constructor.

Definition at line 109 of file cmtkJointHistogram.h.


Member Function Documentation

template<class T>
void cmtk::JointHistogram< T >::AddHistogramColumn ( const size_t  sampleX,
const Histogram< T > &  other,
const float  weight = 1 
) [inline]

Add values from another 1D histogram in Y-direction.

Adding is done by corresponding bins. The caller has to make sure that both histograms actually have the same number and arrangement of bins. It is also a good idea to ensure that the data ranges of these bins are the same in both objects.

Parameters:
sampleXIndex of the histogram column to which the 1D histogram is to be added.
otherA pointer to the other histogram. Its bin values are added to this object's bins.
weightMultiplicative weight factor with which the other histogram is added to this one.

Definition at line 427 of file cmtkJointHistogram.h.

template<class T>
void cmtk::JointHistogram< T >::AddHistogramRow ( const Histogram< T > &  other,
const size_t  sampleY,
const float  weight = 1 
) [inline]

Add values from another 1D histogram in X-direction.

Adding is done by corresponding bins. The caller has to make sure that both histograms actually have the same number and arrangement of bins. It is also a good idea to ensure that the data ranges of these bins are the same in both objects.

Parameters:
otherA pointer to the other histogram. Its bin values are added to this object's bins.
sampleYIndex of the histogram row to which the 1D histogram is to be added.
weightMultiplicative weight factor with which the other histogram is added to this one.

Definition at line 407 of file cmtkJointHistogram.h.

template<class T>
void cmtk::JointHistogram< T >::AddJointHistogram ( const Self other ) [inline]

Add values from another histogram.

Adding is done by corresponding bins. The caller has to make sure that both histograms actually have the same number and arrangement of bins. It is also a good idea to ensure that the data ranges of these bins are the same in both objects. Both can be guaranteed if one histogram was created from the other by a call to Clone() for example.

Parameters:
otherA pointer to the other histogram. Its bin values are added to this object's bins.

Definition at line 390 of file cmtkJointHistogram.h.

template<class T>
Types::DataItem cmtk::JointHistogram< T >::BinToValueX ( const size_t  bin ) const [inline]

Return center of values represented by a certain X distribution bin.

Parameters:
binIndex of a bin from the X distribution.
Returns:
Average of upper and lower margin values of the given bin.

Definition at line 231 of file cmtkJointHistogram.h.

template<class T>
Types::DataItem cmtk::JointHistogram< T >::BinToValueY ( const size_t  bin ) const [inline]

Return center of values represented by a certain Y distribution bin.

Parameters:
binIndex of a bin from the Y distribution.
Returns:
Average of upper and lower margin values of the given bin.

Definition at line 240 of file cmtkJointHistogram.h.

template<class T>
Self* cmtk::JointHistogram< T >::Clone (  ) const [inline]

Make an identical copy of this object.

Returns:
The newly created copy of this object.

Definition at line 120 of file cmtkJointHistogram.h.

template<class T>
void cmtk::JointHistogram< T >::Decrement ( const size_t  sampleX,
const size_t  sampleY 
) [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:
sampleXIndex of histogram field in x-direction.
sampleYIndex of histogram field in y-direction.

Definition at line 370 of file cmtkJointHistogram.h.

template<class T>
void cmtk::JointHistogram< T >::Decrement ( const size_t  sampleX,
const size_t  sampleY,
const Types::DataItem  weight 
) [inline]

Definition at line 376 of file cmtkJointHistogram.h.

template<class T>
T cmtk::JointHistogram< T >::GetBin ( const size_t  indexX,
const size_t  indexY 
) const [inline]

Return a bin value.

Definition at line 286 of file cmtkJointHistogram.h.

Referenced by cmtk::FilterVolume::StudholmeFilter().

template<class T>
double cmtk::JointHistogram< T >::GetCorrelationRatio (  ) const [inline]

Compute the Correlation Ratio corresponding to this histogram.

Definition at line 556 of file cmtkJointHistogram.h.

template<class T>
size_t cmtk::JointHistogram< T >::GetMaximumBinIndexOverX ( const size_t  j ) const [inline]

Definition at line 493 of file cmtkJointHistogram.h.

template<class T>
size_t cmtk::JointHistogram< T >::GetMaximumBinIndexOverY ( const size_t  i ) const [inline]

Definition at line 516 of file cmtkJointHistogram.h.

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

Return maximum number of samples stored in any bin.

Definition at line 307 of file cmtkJointHistogram.h.

template<class T>
double cmtk::JointHistogram< T >::GetMutualInformation ( const bool  normalized = false ) const [inline]

Compute the (normalized) mutual information of this histogram.

Parameters:
normalizedIf this parameter is true, then the "normalized" version of Mutual Information as introduced by Studholme et al. [Pattern Analysis 1999] is computed. If this flag is false, the original formula of Viola [IEEE Trans Med Imaging 1997] and Maes is used instead.

Definition at line 541 of file cmtkJointHistogram.h.

Referenced by cmtk::TypedArraySimilarity::GetMutualInformation(), and cmtk::TypedArraySimilarity::GetNormalizedMutualInformation().

template<class T>
size_t cmtk::JointHistogram< T >::GetNumBinsX (  ) const [inline]

Return number of histogram bins in X direction.

Definition at line 139 of file cmtkJointHistogram.h.

template<class T>
size_t cmtk::JointHistogram< T >::GetNumBinsY (  ) const [inline]

Return number of histogram bins in Y direction.

Definition at line 145 of file cmtkJointHistogram.h.

template<class T>
const Types::DataItemRange cmtk::JointHistogram< T >::GetRangeX (  ) const [inline]

Get value range of the X distribution.

Definition at line 184 of file cmtkJointHistogram.h.

template<class T>
const Types::DataItemRange cmtk::JointHistogram< T >::GetRangeY (  ) const [inline]

Get value range of the Y distribution.

Definition at line 191 of file cmtkJointHistogram.h.

template<class T>
void cmtk::JointHistogram< T >::Increment ( const size_t  sampleX,
const size_t  sampleY 
) [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:
sampleXIndex of histogram field in x-direction.
sampleYIndex of histogram field in y-direction.

Definition at line 344 of file cmtkJointHistogram.h.

Referenced by cmtk::TypedArraySimilarity::GetMutualInformation(), cmtk::TypedArraySimilarity::GetNormalizedMutualInformation(), and cmtk::FilterVolume::StudholmeFilter().

template<class T>
void cmtk::JointHistogram< T >::Increment ( const size_t  sampleX,
const size_t  sampleY,
const T  weight 
) [inline]

Increment the value of a histogram bin by an arbitrary value.

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

Parameters:
sampleXIndex of histogram field in x-direction.
sampleYIndex of histogram field in y-direction.
weightValue to increment the given histogram bin by.

Definition at line 357 of file cmtkJointHistogram.h.

template<class T>
void cmtk::JointHistogram< T >::NormalizeOverX ( const double  normalizeTo = 1.0 ) [inline]

Normalize histogram values over X dimension.

Parameters:
normalizeToAll histogram bins in every row of the histogram are scaled by a common factor so that their sum matches the value of this parameter.

Definition at line 456 of file cmtkJointHistogram.h.

template<class T>
void cmtk::JointHistogram< T >::NormalizeOverY ( const double  normalizeTo = 1.0 ) [inline]

Normalize histogram values over Y dimension.

Parameters:
normalizeToAll histogram bins in every column of the histogram are scaled by a common factor so that their sum matches the value of this parameter.

Definition at line 475 of file cmtkJointHistogram.h.

template<class T>
T cmtk::JointHistogram< T >::ProjectToX ( const size_t  indexX ) const [inline]

Return projection of 2D distribution to X.

This function can be used to reconstruct the marginal distribution X from the 2D histogram without explicitly stored 1D distributions.

Parameters:
indexXA bin index for the X distribution.
Returns:
Projection of 2D histogram onto X distribution. This is the sum of all bins in Y direction for the given index in X direction.

Definition at line 252 of file cmtkJointHistogram.h.

Referenced by cmtk::FilterVolume::StudholmeFilter().

template<class T>
T cmtk::JointHistogram< T >::ProjectToY ( const size_t  indexY ) const [inline]

Return projection of 2D distribution to Y.

This function can be used to reconstruct the marginal distribution Y from the 2D histogram without explicitly stored 1D distributions.

Parameters:
indexYA bin index for the Y distribution.
Returns:
Projection of 2D histogram onto X distribution. This is the sum of all bins in X direction for the given index in X direction.

Definition at line 268 of file cmtkJointHistogram.h.

template<class T>
void cmtk::JointHistogram< T >::RemoveJointHistogram ( const Self other ) [inline]

Subtract bin values from another histogram.

Subtraction is done by corresponding bins. The caller has to make sure that both histograms actually have the same number and arrangement of bins. It is also a good idea to ensure that the data ranges of these bins are the same in both objects. Both can be guaranteed if one histogram was created from the other by a call to Clone() for example.

Parameters:
otherA pointer to the other histogram. Its bin values are subtracted this object's bins.

Definition at line 443 of file cmtkJointHistogram.h.

template<class T>
void cmtk::JointHistogram< 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 202 of file cmtkJointHistogram.h.

Referenced by cmtk::FilterVolume::StudholmeFilter().

template<class T>
void cmtk::JointHistogram< T >::Resize ( const size_t  numberOfBinsX,
const size_t  numberOfBinsY,
const bool  reset = true 
) [inline]

Resize and allocate histogram bins.

Definition at line 126 of file cmtkJointHistogram.h.

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

Return total number of samples stored in the histogram.

Definition at line 293 of file cmtkJointHistogram.h.

template<class T>
void cmtk::JointHistogram< T >::SetRangeCenteredX ( const Types::DataItemRange range ) [inline]

Set value range of the X distribution where upper and lower bound are centered in first and last histogram bins.

Definition at line 168 of file cmtkJointHistogram.h.

template<class T>
void cmtk::JointHistogram< T >::SetRangeCenteredY ( const Types::DataItemRange range ) [inline]

Set value range of the Y distribution where upper and lower bound are centered in first and last histogram bins.

Definition at line 176 of file cmtkJointHistogram.h.

template<class T>
void cmtk::JointHistogram< T >::SetRangeX ( const Types::DataItemRange range ) [inline]

Set value range of the X distribution.

Definition at line 152 of file cmtkJointHistogram.h.

Referenced by cmtk::TypedArraySimilarityMemory::CreateHistogram(), and cmtk::FilterVolume::StudholmeFilter().

template<class T>
void cmtk::JointHistogram< T >::SetRangeY ( const Types::DataItemRange range ) [inline]

Set value range of the Y distribution.

Definition at line 160 of file cmtkJointHistogram.h.

Referenced by cmtk::TypedArraySimilarityMemory::CreateHistogram(), and cmtk::FilterVolume::StudholmeFilter().

template<class T>
size_t cmtk::JointHistogram< T >::ValueToBinX ( const Types::DataItem  value ) const [inline]

Return bin corresponding to a certain value of the X distribution.

Parameters:
valueA value from the X distribution.
Returns:
The index of the X bin corresponding to the given value.

Definition at line 211 of file cmtkJointHistogram.h.

Referenced by cmtk::TypedArraySimilarity::GetMutualInformation(), cmtk::TypedArraySimilarity::GetNormalizedMutualInformation(), and cmtk::FilterVolume::StudholmeFilter().

template<class T>
size_t cmtk::JointHistogram< T >::ValueToBinY ( const Types::DataItem  value ) const [inline]

Return bin corresponding to a certain value of the Y distribution.

Parameters:
valueA value from the Y distribution.
Returns:
The index of the Y bin corresponding to the given value.

Definition at line 221 of file cmtkJointHistogram.h.

Referenced by cmtk::TypedArraySimilarity::GetMutualInformation(), cmtk::TypedArraySimilarity::GetNormalizedMutualInformation(), and cmtk::FilterVolume::StudholmeFilter().


Member Data Documentation

template<class T>
Types::DataItem cmtk::JointHistogram< T >::BinOffsetX [protected]

Lower value bound of reference data bins.

Definition at line 74 of file cmtkJointHistogram.h.

template<class T>
Types::DataItem cmtk::JointHistogram< T >::BinOffsetY [protected]

Lower value bound of model data bins.

Definition at line 83 of file cmtkJointHistogram.h.

template<class T>
Types::DataItem cmtk::JointHistogram< T >::BinWidthX [protected]

Width of reference data bins.

Definition at line 71 of file cmtkJointHistogram.h.

template<class T>
Types::DataItem cmtk::JointHistogram< T >::BinWidthY [protected]

Width of model data bins.

Definition at line 80 of file cmtkJointHistogram.h.

template<class T>
std::vector<T> cmtk::JointHistogram< T >::JointBins [protected]

Array of cross-modality (joint) bins.

Definition at line 86 of file cmtkJointHistogram.h.

template<class T>
size_t cmtk::JointHistogram< T >::m_TotalNumberOfBins [protected]

Total number of bins, ie., NumBinsX*NumBinsY.

Definition at line 89 of file cmtkJointHistogram.h.

template<class T>
size_t cmtk::JointHistogram< T >::NumBinsX [protected]

Number of reference data bins.

Definition at line 68 of file cmtkJointHistogram.h.

template<class T>
size_t cmtk::JointHistogram< T >::NumBinsY [protected]

Number of model data bins.

Definition at line 77 of file cmtkJointHistogram.h.


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