STIRA  0.1
Public Member Functions | List of all members
stira::histogram::FloatHistogram Class Reference

Class for floating point valued histograms E.g. needed to represent an normalized histogram when performing histogram equalization WARNING: currently only works for default case when bin size is 1. More...

#include <FloatHistogram.h>

Inheritance diagram for stira::histogram::FloatHistogram:
stira::histogram::HistogramMaster< double >

Public Member Functions

 FloatHistogram (int nrOfBins, int nrBands)
 constructor for histogram object More...
 
 FloatHistogram (IntHistogram *pIntHistogram, bool requiresNormalization)
 constructor with initialization from IntHistogram More...
 
 FloatHistogram (const FloatHistogram &pFloatHistogram)
 Copy constructor. More...
 
FloatHistogramClone ()
 Creates a clone of this FloatHistogram This clone becomes the responsability of the caller to delete.
 
bool UpdateHistogram (IntHistogram *pIntHistogram, double alpha)
 
virtual ~FloatHistogram ()
 destructor for histogram object
 
void Normalize ()
 Normalizes each band in the current histogram to 1.
 
double GetBinValueHistogramData (int band, int bin)
 Gets the value that corresponds with the given band and bin. More...
 
void InitializeWithNormalizedHistogram (IntHistogram *pStandardHistogram)
 compute normalized histogram by dividing the histogram values by the total number of counts in the histogram More...
 
void InitializeWithNormalizedCumulativeHistogram (IntHistogram *pStandardHistogram, IntHistogram *pCumulativeHistogram)
 compute normalized cumulative histogram by dividing the cumulative histogram values by the standard histogram values More...
 
double ComputeStandardKullbackLeiblerDistance (FloatHistogram *pOtherHistogram)
 computes standard Kullback-Leibler divergence between this histogram and the histogram in the argument Reference http://en.wikipedia.org/wiki/Kullback–Leibler_divergence Zero entries: http://mathoverflow.net/questions/72668/how-to-compute-kl-divergence-when-pmf-contains-0s Warning: assumes that both histograms are normalized More...
 
double ComputeEntropy ()
 computes entropy of this histogram Reference: http://en.wikipedia.org/wiki/Entropy_(information_theory) Zero entries: http://mathoverflow.net/questions/72668/how-to-compute-kl-divergence-when-pmf-contains-0s Warning: assumes that this histogram is normalized
 
double ComputeSymmetricKullbackLeiblerDistance (FloatHistogram *pOtherHistogram)
 computes symmetric Kullback-Leibler divergence between this histogram and the histogram in the argument Reference http://en.wikipedia.org/wiki/Kullback–Leibler_divergence Warning: assumes that both histograms are normalized More...
 
double ComputeJensenShannonMetric (FloatHistogram *pOtherHistogram)
 computes the square root of the Jensen–Shannon divergence between the current histogram and the histogram passed as argument the Jensen–Shannon divergence is a popular method of measuring the similarity between two probability distributions. It is based on the Kullback–Leibler divergence, with the notable (and useful) difference that it is always a finite value. The square root of the Jensen–Shannon divergence is a metric. Reference: - http://en.wikipedia.org/wiki/Jensen–Shannon_divergence More...
 
double ComputeIDivergence (FloatHistogram *pOtherHistogram)
 computes Csiszar's I-divergence between this histogram and the histogram in the argument Reference Csiszar, I. (1991). "Why least squares and maximum entropy? an axiomatic approach to inference for linear inverse problems. Annals of Statistics, 19(4):2032–2066. See online access at http://www.jstor.org/ More...
 
virtual bool Write (std::string fileName)
 writes values from current histogram to a file More...
 
void SetEpsilonThreshold (double epsilonValue)
 Sets the threshold value to compare values in the histogram with each other or with zero. More...
 
double GetEpsilonThreshold ()
 Gets the threshold value to compare values in the histogram with each other or with zero.
 
- Public Member Functions inherited from stira::histogram::HistogramMaster< double >
void AddDataPoint (int valueToAdd, int bandNr=0)
 adds a value to the histogram This is a generalization of AddOneToBin, since here also bin sizes not equal to one can be used; the bin number will be calculated depending on the bin size and then one will be added to that bin. More...
 
void SetBinsToZero ()
 set all bins to zero
 
double GetBinValue (int bandNr, int binNr) const
 gets nr of counts in given bin nr for a given band nr if the macro USE_SAFE is defined, we use the version with boundary checking, else we use the fast (unsafe) call to get the data from the array More...
 
double GetBinValueSafe (int bandNr, int binNr) const
 gets nr of counts in given bin nr for a given band nr Specific safe call for above with extra boundary checking More...
 
int GetNrOfBins () const
 Gets nr of bins in the histogram For now, we assume bin size is 1, so the number of bins is the data range mRange.
 
int GetNrOfBands () const
 Gets nr of bands in the histogram.
 
int GetNrOfCounts () const
 Gets total nr of counts in the histogram This number is the number of pixels in the image that were counted. We don't count the same pixel over and over again for different bands in the image; we just assume that the ROI for which the histogram was computed is the same for all bands in an image.
 
double GetBinSize () const
 Gets the width of a histogram bin.
 
double GetDataMinimum () const
 Gets the minimum of the data range.
 
double GetDataMaximum () const
 Gets the maximum of the data range.
 
void SetBinValue (int bandNr, int binNr, doublevalue)
 sets nr of counts in given bin nr for a given band nr if the macro USE_SAFE is defined, we use the version with boundary checking, else we use the fast (unsafe) call to get the data from the array More...
 

Additional Inherited Members

- Protected Member Functions inherited from stira::histogram::HistogramMaster< double >
void AddOneToBin (int bandNr, int binNr)
 adds one count in given bin nr for a given band nr if the macro USE_SAFE is defined, we use the version with boundary checking, else we use the fast (unsafe) call to get the data from the array More...
 
void AddOneToBin (int binNr)
 adds one count in given bin nr in case there is just a single band if the macro USE_SAFE is defined, we use the version with boundary checking, else we use the fast (unsafe) call to get the data from the array More...
 
void AddOneToBinSafe (int bandNr, int binNr)
 adds one count in given bin nr for a given band nr Specific safe call for above with extra boundary checking More...
 
void AddOneToBinSafe (int binNr)
 adds one count in given bin nr in case there is just a single band Specific safe call for above with extra boundary checking More...
 
 HistogramMaster ()
 constructor only to be called from child classes
 
 HistogramMaster (const HistogramMaster &pHistogram)
 Copy constructor. More...
 
virtual ~HistogramMaster ()
 destructor only to be called from child classes
 
void Initialize (doublebinSize, int nrOfBands, doubleminValue, doublemaxValue)
 Initializes member variables and creates and initializes histogram data structure Creation and initialization of the histogram data structure is done by calling CreateInitializedDataStructure, which does not initialize the other member variables. More...
 
void CreateInitializedDataStructure ()
 Just creates and initializes histogram data structure does not initialize the other member variables.
 
void SetBinValueSafe (int bandNr, int binNr, doublevalue)
 sets nr of counts in given bin nr for a given band nr Specific safe call for above with extra boundary checking More...
 
- Protected Attributes inherited from stira::histogram::HistogramMaster< double >
double ** mpHistogram
 the actual histogram (we count nr of intensities per colour band)
 
double mBinSize
 size of histogram bin
 
int mNrOfBands
 nr of bands in image
 
int mNrOfBins
 nr of bins in histogram
 
int mNrOfCounts
 nr of pixels in image = nr of counts in histogram per band
 
double mMin
 min intensity in histogram
 
double mMax
 max intensity in histogram
 

Detailed Description

Class for floating point valued histograms E.g. needed to represent an normalized histogram when performing histogram equalization WARNING: currently only works for default case when bin size is 1.

Constructor & Destructor Documentation

stira::histogram::FloatHistogram::FloatHistogram ( int  nrOfBins,
int  nrBands 
)

constructor for histogram object

Parameters
nrOfBinsnumber of bins in the histogram
nrBandsnumber of bands in the histogram (on per colour chanel)
stira::histogram::FloatHistogram::FloatHistogram ( IntHistogram pIntHistogram,
bool  requiresNormalization 
)

constructor with initialization from IntHistogram

Parameters
pIntHistogramhistogram to initialize this histogram from
requiresNormalizationflag whether the values need to be normalized

References stira::histogram::HistogramMaster< T >::GetBinValue(), stira::histogram::HistogramMaster< T >::GetNrOfBands(), and stira::histogram::HistogramMaster< T >::GetNrOfBins().

stira::histogram::FloatHistogram::FloatHistogram ( const FloatHistogram pFloatHistogram)
inline

Member Function Documentation

double stira::histogram::FloatHistogram::ComputeIDivergence ( FloatHistogram pOtherHistogram)

computes Csiszar's I-divergence between this histogram and the histogram in the argument Reference Csiszar, I. (1991). "Why least squares and maximum entropy? an axiomatic approach to inference for linear inverse problems. Annals of Statistics, 19(4):2032–2066. See online access at http://www.jstor.org/

Parameters
pOtherHistogramhistogram to compute distance with

References stira::histogram::HistogramMaster< T >::GetBinValue(), stira::histogram::HistogramMaster< T >::GetNrOfBands(), and stira::histogram::HistogramMaster< T >::GetNrOfBins().

Referenced by FloatHistogram().

double stira::histogram::FloatHistogram::ComputeJensenShannonMetric ( FloatHistogram pOtherHistogram)

computes the square root of the Jensen–Shannon divergence between the current histogram and the histogram passed as argument the Jensen–Shannon divergence is a popular method of measuring the similarity between two probability distributions. It is based on the Kullback–Leibler divergence, with the notable (and useful) difference that it is always a finite value. The square root of the Jensen–Shannon divergence is a metric. Reference: - http://en.wikipedia.org/wiki/Jensen–Shannon_divergence

  • A New Metric for Probability Distributions, D. Endres & J. Schindelin, IEEE Trans. Information Theory, VOL. 49, NO. 7, JULY 2003, pp. 1858 – 1860
    Parameters
    pOtherHistogramhistogram to compute distance with

References ComputeStandardKullbackLeiblerDistance(), stira::histogram::HistogramMaster< T >::GetBinValue(), and stira::histogram::HistogramMaster< T >::SetBinValue().

Referenced by stira::filter::LocalBinaryPattern::ComputeJensenShannonDivergenceBetweenImagePatches(), and FloatHistogram().

double stira::histogram::FloatHistogram::ComputeStandardKullbackLeiblerDistance ( FloatHistogram pOtherHistogram)

computes standard Kullback-Leibler divergence between this histogram and the histogram in the argument Reference http://en.wikipedia.org/wiki/Kullback–Leibler_divergence Zero entries: http://mathoverflow.net/questions/72668/how-to-compute-kl-divergence-when-pmf-contains-0s Warning: assumes that both histograms are normalized

Parameters
pOtherHistogramhistogram to compute distance with

References stira::histogram::HistogramMaster< T >::GetBinValue(), stira::histogram::HistogramMaster< T >::GetNrOfBands(), and stira::histogram::HistogramMaster< T >::GetNrOfBins().

Referenced by ComputeJensenShannonMetric(), and FloatHistogram().

double stira::histogram::FloatHistogram::ComputeSymmetricKullbackLeiblerDistance ( FloatHistogram pOtherHistogram)

computes symmetric Kullback-Leibler divergence between this histogram and the histogram in the argument Reference http://en.wikipedia.org/wiki/Kullback–Leibler_divergence Warning: assumes that both histograms are normalized

Parameters
pOtherHistogramhistogram to compute distance with

References stira::histogram::HistogramMaster< T >::GetBinValue(), stira::histogram::HistogramMaster< T >::GetNrOfBands(), and stira::histogram::HistogramMaster< T >::GetNrOfBins().

Referenced by FloatHistogram().

double stira::histogram::FloatHistogram::GetBinValueHistogramData ( int  band,
int  bin 
)

Gets the value that corresponds with the given band and bin.

Parameters
bandthe image band for which to get the histogram value
binthe bin for which to get the histogram value
Returns
value that corresponds with band and bin

Referenced by FloatHistogram().

void stira::histogram::FloatHistogram::InitializeWithNormalizedCumulativeHistogram ( IntHistogram pStandardHistogram,
IntHistogram pCumulativeHistogram 
)

compute normalized cumulative histogram by dividing the cumulative histogram values by the standard histogram values

Parameters
pStandardHistogramstandard histogram, needed to normalize the cumulative histogram
pCumulativeHistogramhistogram to be normalized

References stira::histogram::HistogramMaster< T >::GetBinValue(), and stira::histogram::HistogramMaster< T >::GetNrOfCounts().

Referenced by FloatHistogram(), stira::contrastenhance::HistogramTools::HistogramEqualizeSingleBand(), and stira::contrastenhance::AdaptiveHistogramEqualizer::Run().

void stira::histogram::FloatHistogram::InitializeWithNormalizedHistogram ( IntHistogram pStandardHistogram)

compute normalized histogram by dividing the histogram values by the total number of counts in the histogram

Parameters
pStandardHistogramstandard histogram, needed to normalize the cumulative histogram

References stira::histogram::HistogramMaster< T >::GetBinValue(), and stira::histogram::HistogramMaster< T >::GetNrOfCounts().

Referenced by FloatHistogram().

void stira::histogram::FloatHistogram::SetEpsilonThreshold ( double  epsilonValue)

Sets the threshold value to compare values in the histogram with each other or with zero.

Parameters
epsilonValuethe epsilon threshold value

Referenced by FloatHistogram().

bool stira::histogram::FloatHistogram::Write ( std::string  fileName)
virtual

writes values from current histogram to a file

Parameters
fileNamename of file to write values in

Implements stira::histogram::HistogramMaster< double >.

Referenced by stira::filter::LocalBinaryPattern::ComputeJensenShannonDivergenceBetweenImagePatches(), and FloatHistogram().


The documentation for this class was generated from the following files: