libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | List of all members
crn::Histogram Class Reference

Mother class for integer histograms. More...

#include <CRNHistogram.h>

+ Inheritance diagram for crn::Histogram:
+ Collaboration diagram for crn::Histogram:

Public Types

enum  DesignHeuristic {
  DesignHeuristic::CUSTOM, DesignHeuristic::SQUARE_ROOT, DesignHeuristic::STURGES, DesignHeuristic::SCOTT,
  DesignHeuristic::FREEDMAN
}
 

Public Member Functions

 Histogram ()
 Default constructor. More...
 
 Histogram (size_t s, unsigned int v=0)
 Constructor with size and value. More...
 
 Histogram (const Histogram &src, unsigned int c=1u)
 Copy constructor. More...
 
template<typename ITER >
 Histogram (ITER it_begin, ITER it_end, DesignHeuristic m=DesignHeuristic::STURGES, size_t nb_bins=(size_t) 1)
 
Histogramoperator= (const Histogram &)=delete
 
 Histogram (Histogram &&)=default
 
Histogramoperator= (Histogram &&)=default
 
 ~Histogram ()
 Destructor. More...
 
size_t Size () const noexcept
 Returns the number of bins. More...
 
unsigned int * GetBins ()
 Returns the internal pointer on the bins. More...
 
const unsigned int * GetBins () const
 Returns a reference to the internal pointer on the bins. More...
 
void SetBin (size_t k, unsigned int v)
 Modify a bin value. More...
 
void IncBin (size_t k, unsigned int i=1u)
 Increments a bin value. More...
 
unsigned int GetBin (size_t k) const
 Get a bin value. More...
 
unsigned int & operator[] (size_t k)
 Access a bin value (fast and unsafe) More...
 
const unsigned int & operator[] (size_t k) const
 Access a bin value (fast and unsafe) More...
 
unsigned int CumulateBins () const
 Cumulate all bins. More...
 
double Mean () const
 Mean value on class indexes. More...
 
double Variance (double m) const
 Variance on class indexes, having mean value. More...
 
double Deviation (double m) const
 Standard deviation on class indexes, having mean value. More...
 
double Variance () const
 Variance on class indexes. More...
 
double Deviation () const
 Standard deviation on class indexes. More...
 
unsigned int Max () const
 Maximal count value. More...
 
unsigned int Min () const
 Minimal count value. More...
 
size_t Argmax () const
 First class having a maximal count value. More...
 
size_t Argmin () const
 First class having a minimal count value. More...
 
void SetCeiling (unsigned int m)
 Set maximal count value to m. More...
 
void ScaleMaxTo (unsigned int m)
 Scale maximal count to m. More...
 
void AverageSmoothing (size_t d)
 Smoothing histogram. More...
 
void CircularAverageSmoothing (size_t d)
 Smoothing circular histogram. More...
 
std::vector< size_t > Modes () const
 Returns the modes. More...
 
std::vector< size_t > StableModes () const
 Returns the stable modes. More...
 
Histogram MakeIntersection (const Histogram &h) const
 Intersection between two histograms. More...
 
double IntersectionDivergence (const Histogram &h) const
 Intersection divergence between two histograms. More...
 
double Correlation (const Histogram &h) const
 Correlation between two histograms. More...
 
double Chi2 (const Histogram &h) const
 Correlation between two histograms. More...
 
double MinkowskiDistance (const Histogram &h, double r) const
 Minkowski distance between two histograms. More...
 
double JeffreyDivergence (const Histogram &h) const
 Jeffrey divergence between two histograms. More...
 
double MatchDistance (const Histogram &h) const
 Match distance between two histograms. More...
 
double KolmogorovSmirnovDistance (const Histogram &h) const
 Kolmogorov-Smirnov distance between two histograms. More...
 
double EMD (const Histogram &h) const
 Earth Mover's Distance. More...
 
double CEMD (const Histogram &h) const
 Circular Earth Mover's Distance. More...
 
void Append (const Histogram &h)
 Appends an histogram to the current. More...
 
void Resize (size_t newsize)
 Resizes the histogram. More...
 
String ToString () const
 Dumps bins to a string. More...
 
ImageBW MakeImageBW (size_t height) const
 returns the histogram image More...
 
ImageBW MakeRadialImageBW (size_t radius) const
 returns the circular histogram image More...
 
void Cumulate ()
 Cumulates the values from 0 to end. More...
 
size_t Fisher () const
 Computes the Fisher threshold. More...
 
size_t EntropyThreshold () const
 Computes the entropy threshold. More...
 
double Entropy () const
 the entropy More...
 
size_t MedianValue () const
 Computes the median value. More...
 
Histogram MakePopulationHistogram () const
 Creates an histogram from population. More...
 
std::vector< unsigned int > Std ()&&
 
void Deserialize (xml::Element &el)
 Initializes the object from an XML element. Unsafe. More...
 
xml::Element Serialize (xml::Element &parent) const
 Dumps the object to an XML element. Unsafe. More...
 
- Public Member Functions inherited from crn::Object
virtual ~Object ()=default
 

Detailed Description

Mother class for integer histograms.

Histograms are represented as arrays. Classes are indexed from 0 to (array size)-1. k-th component in the array is the number of elements (integer value) in class k.

Author
Jean Duong
Date
25 August 2006
Version
0.1

Definition at line 44 of file CRNHistogram.h.

Member Enumeration Documentation

Enumerator
CUSTOM 
SQUARE_ROOT 
STURGES 
SCOTT 
FREEDMAN 

Definition at line 47 of file CRNHistogram.h.

Constructor & Destructor Documentation

crn::Histogram::Histogram ( )
inline

Default constructor.

Definition at line 50 of file CRNHistogram.h.

Histogram::Histogram ( size_t  s,
unsigned int  v = 0 
)

Constructor with size and value.

Constructor with size and value.

Parameters
[in]sSize for this histogram
[in]vValue to set up all the components for this histogram (default value = 0)
Author
Jean DUONG

Definition at line 42 of file CRNHistogram.cpp.

Histogram::Histogram ( const Histogram src,
unsigned int  c = 1u 
)

Copy constructor.

Constructor for this class

Parameters
[in]srcSource histogram
[in]ccompression ratio
Author
Jean DUONG

Definition at line 56 of file CRNHistogram.cpp.

template<typename ITER >
crn::Histogram::Histogram ( ITER  it_begin,
ITER  it_end,
DesignHeuristic  m = DesignHeuristic::STURGES,
size_t  nb_bins = (size_t)1 
)
inline

Constructor for this class

Parameters
[in]it_beginiterator pointing to first double-size_t pair of input data contener
[in]it_endending iterator
[in]mhistogram making heuristic
[in]nb_binsnumber of default bins
Author
Jean DUONG

Definition at line 67 of file CRNHistogram.h.

crn::Histogram::Histogram ( Histogram &&  )
default
Histogram::~Histogram ( )

Destructor.

Destructor

Author
Jean DUONG

Definition at line 981 of file CRNHistogram.cpp.

Member Function Documentation

void Histogram::Append ( const Histogram h)

Appends an histogram to the current.

Append an histogram

Parameters
[in]hthe histogram to append
Author
Yann LEYDIER

Definition at line 992 of file CRNHistogram.cpp.

size_t Histogram::Argmax ( ) const

First class having a maximal count value.

First class having maximal count value for this histogram

Returns
the index of the first class having the maximal count value
Author
Jean DUONG

Definition at line 324 of file CRNHistogram.cpp.

size_t Histogram::Argmin ( ) const

First class having a minimal count value.

First class having minimal count value for this histogram

Returns
the index of the first class having the minimal count value
Author
Jean DUONG

Definition at line 351 of file CRNHistogram.cpp.

void Histogram::AverageSmoothing ( size_t  d)

Smoothing histogram.

Smoothing : replace k-th count by average value computed in a sliding window centered on k-th class

Parameters
[in]dThe sliding window's half-width
Author
Jean DUONG

Definition at line 425 of file CRNHistogram.cpp.

double Histogram::CEMD ( const Histogram h) const

Circular Earth Mover's Distance.

Earth Mover's Distance for histograms of angles

Exceptions
ExceptionDimensionhistograms do not have the same size
Parameters
[in]hthe histogram to compare to
Returns
Circular Earth Mover's Distance
Author
Yann LEYDIER

Definition at line 925 of file CRNHistogram.cpp.

double Histogram::Chi2 ( const Histogram h) const

Correlation between two histograms.

Chi2 distance between two histograms The two histograms must have same size.

Exceptions
ExceptionDimensionhistograms do not have the same size
Parameters
[in]hHistogram
Returns
the correlation
Author
Jean DUONG

Definition at line 728 of file CRNHistogram.cpp.

void Histogram::CircularAverageSmoothing ( size_t  d)

Smoothing circular histogram.

Smoothing : replace k-th count by average value computed in a sliding window centered on k-th class

Parameters
[in]dThe sliding window's half-width
Author
Yann LEYDIER

Definition at line 457 of file CRNHistogram.cpp.

double Histogram::Correlation ( const Histogram h) const

Correlation between two histograms.

Correlation between two histograms The two histograms must have same size.

Exceptions
ExceptionDimensionhistograms do not have the same size
Parameters
[in]hHistogram
Returns
the correlation
Author
Jean DUONG

Definition at line 686 of file CRNHistogram.cpp.

void Histogram::Cumulate ( )

Cumulates the values from 0 to end.

Cumulates the values from 0 to end

Definition at line 1146 of file CRNHistogram.cpp.

unsigned int Histogram::CumulateBins ( ) const

Cumulate all bins.

Cumulate all bins form this histogram

Returns
the sum of all the bins
Author
Jean DUONG

Definition at line 185 of file CRNHistogram.cpp.

void Histogram::Deserialize ( xml::Element el)

Initializes the object from an XML element. Unsafe.

Unsafe load from XML node

Author
Yann LEYDIER
Exceptions
ExceptionInvalidArgumentnot an Histogram
ExceptionNotFoundcannot find CDATA
ExceptionDomaincannot find CDATA
ExceptionRuntimecannot convert CDATA
Parameters
[in]elthe element to load

Definition at line 1059 of file CRNHistogram.cpp.

double crn::Histogram::Deviation ( double  m) const
inline

Standard deviation on class indexes, having mean value.

Definition at line 186 of file CRNHistogram.h.

double crn::Histogram::Deviation ( ) const
inline

Standard deviation on class indexes.

Definition at line 191 of file CRNHistogram.h.

double Histogram::EMD ( const Histogram h) const

Earth Mover's Distance.

Exceptions
ExceptionDimensionhistograms do not have the same size
Parameters
[in]hthe histogram to compare to
Returns
Earth Mover's Distance
Author
Yann LEYDIER

Definition at line 901 of file CRNHistogram.cpp.

double Histogram::Entropy ( ) const

the entropy

Compute the entropy

Author
Jean DUONG
Returns
the entropy

Definition at line 1308 of file CRNHistogram.cpp.

size_t Histogram::EntropyThreshold ( ) const

Computes the entropy threshold.

Computes the entropy threshold for bimodal histogram

Author
Frank LeBOURGEOIS
Returns
the threshold

Definition at line 1259 of file CRNHistogram.cpp.

size_t Histogram::Fisher ( ) const

Computes the Fisher threshold.

Computes the Fisher threshold

Author
Yann LEYDIER
Returns
The index of the cut

Definition at line 1198 of file CRNHistogram.cpp.

unsigned int Histogram::GetBin ( size_t  k) const

Get a bin value.

Gets k-th bin from this histogram

Exceptions
ExceptionDomainindex out of bounds
Parameters
[in]kthe index of the bin to retrieve
Returns
content of the bin
Author
Jean DUONG

Definition at line 165 of file CRNHistogram.cpp.

unsigned int* crn::Histogram::GetBins ( )
inline

Returns the internal pointer on the bins.

Definition at line 159 of file CRNHistogram.h.

const unsigned int* crn::Histogram::GetBins ( ) const
inline

Returns a reference to the internal pointer on the bins.

Definition at line 161 of file CRNHistogram.h.

void Histogram::IncBin ( size_t  k,
unsigned int  i = 1u 
)

Increments a bin value.

Increments k-th bin of i for this histogram

Exceptions
ExceptionDomainindex out of bounds
Parameters
[in]kThe index of the component to be modified
[in]iThe increment (default value = 1)
Author
Yann LEYDIER

Definition at line 142 of file CRNHistogram.cpp.

double Histogram::IntersectionDivergence ( const Histogram h) const

Intersection divergence between two histograms.

Intersection distance between two histograms The two histograms must have same size.

Exceptions
ExceptionDimensionhistograms do not have the same size
Parameters
[in]hHistogram
Returns
the intersection distance
Author
Jean DUONG

Definition at line 657 of file CRNHistogram.cpp.

double Histogram::JeffreyDivergence ( const Histogram h) const

Jeffrey divergence between two histograms.

Jeffrey divergence between two histograms. The two histograms must have same size.

Exceptions
ExceptionDimensionhistograms do not have the same size
Parameters
[in]hHistogram
Returns
Jeffrey's divergence
Author
Jean DUONG

Definition at line 798 of file CRNHistogram.cpp.

double Histogram::KolmogorovSmirnovDistance ( const Histogram h) const

Kolmogorov-Smirnov distance between two histograms.

Kolmogorov-Smirnov distance between two histograms. The two histograms must have same size.

Exceptions
ExceptionDimensionhistograms do not have the same size
Parameters
[in]hHistogram
Returns
Kolmogorov-Smirnov distance
Author
Jean DUONG

Definition at line 866 of file CRNHistogram.cpp.

ImageBW Histogram::MakeImageBW ( size_t  height) const

returns the histogram image

histogram image

Author
Asma OUJI
Parameters
[in]heightthe histogram image height
Returns
The newly created image.

Definition at line 1128 of file CRNHistogram.cpp.

Histogram Histogram::MakeIntersection ( const Histogram h) const

Intersection between two histograms.

Intersection between two histograms The two histograms must have same size.

Exceptions
ExceptionDimensionhistograms do not have the same size
Parameters
[in]hHistogram
Returns
the intersection of the two histograms
Author
Jean DUONG

Definition at line 629 of file CRNHistogram.cpp.

Histogram Histogram::MakePopulationHistogram ( ) const

Creates an histogram from population.

Creates an histogram from population

Author
Yann LEYDIER
Returns
a new histogram

Definition at line 1360 of file CRNHistogram.cpp.

ImageBW Histogram::MakeRadialImageBW ( size_t  radius) const

returns the circular histogram image

Creates a radial histogram image

Author
Yann LEYDIER
Parameters
[in]radiusthe histogram image radius
Returns
The newly created image.

Definition at line 1166 of file CRNHistogram.cpp.

double Histogram::MatchDistance ( const Histogram h) const

Match distance between two histograms.

Match distance between two histograms. The two histograms must have same size.

Exceptions
ExceptionDimensionhistograms do not have the same size
Parameters
[in]hHistogram
Returns
the match distance
Author
Jean DUONG

Definition at line 832 of file CRNHistogram.cpp.

unsigned int Histogram::Max ( ) const

Maximal count value.

Maximal count value for this histogram

Returns
the maximal count value
Author
Jean DUONG

Definition at line 284 of file CRNHistogram.cpp.

double Histogram::Mean ( ) const

Mean value on class indexes.

Mean value of the bin indexes in this histogram

Returns
the mean value of the bin indexes
Author
Jean DUONG

Definition at line 205 of file CRNHistogram.cpp.

size_t Histogram::MedianValue ( ) const

Computes the median value.

Computes the median value

Author
Yann LEYDIER
Returns
The median value

Definition at line 1337 of file CRNHistogram.cpp.

unsigned int Histogram::Min ( ) const

Minimal count value.

Minimal count value for this histogram

Returns
the minimal count value
Author
Jean DUONG

Definition at line 304 of file CRNHistogram.cpp.

double Histogram::MinkowskiDistance ( const Histogram h,
double  r 
) const

Minkowski distance between two histograms.

Minkowski distance between two histograms. The two histograms must have same size.

Exceptions
ExceptionDimensionhistograms do not have the same size
Parameters
[in]hthe other histogram
[in]rpower of the norm
Returns
the Minkowski distance
Author
Jean DUONG

Definition at line 766 of file CRNHistogram.cpp.

std::vector< size_t > Histogram::Modes ( ) const

Returns the modes.

Search modes for this histogram

Author
Yann LEYDIER
Returns
a vector containing the index of the classes that are modes

Definition at line 497 of file CRNHistogram.cpp.

Histogram& crn::Histogram::operator= ( const Histogram )
delete
Histogram& crn::Histogram::operator= ( Histogram &&  )
default
unsigned int& crn::Histogram::operator[] ( size_t  k)
inline

Access a bin value (fast and unsafe)

Definition at line 173 of file CRNHistogram.h.

const unsigned int& crn::Histogram::operator[] ( size_t  k) const
inline

Access a bin value (fast and unsafe)

Definition at line 175 of file CRNHistogram.h.

void Histogram::Resize ( size_t  newsize)

Resizes the histogram.

Resize the histogram

Exceptions
ExceptionDomainnull new size
Parameters
[in]newsizethe new size
Author
Yann LEYDIER
Todo:

take care of float comparison.

using int calculation ? (better for android port)

Definition at line 1009 of file CRNHistogram.cpp.

void Histogram::ScaleMaxTo ( unsigned int  m)

Scale maximal count to m.

Scale to make maximal count reach a given value

Parameters
[in]mThe desired maximal value
Author
Jean DUONG

Definition at line 395 of file CRNHistogram.cpp.

xml::Element Histogram::Serialize ( xml::Element parent) const

Dumps the object to an XML element. Unsafe.

Unsafe save

Author
Yann LEYDIER
Parameters
[in]parentthe parent element to which we will add the new element
Returns
The newly created element

Definition at line 1093 of file CRNHistogram.cpp.

void Histogram::SetBin ( size_t  k,
unsigned int  v 
)

Modify a bin value.

Set k-th bin to value v for this histogram

Exceptions
ExceptionDomainindex out of bounds
Parameters
[in]kThe index of the component to be modified
[in]vThe new value for k-th component
Author
Jean DUONG

Definition at line 120 of file CRNHistogram.cpp.

void Histogram::SetCeiling ( unsigned int  m)

Set maximal count value to m.

Set maximal value for counts

Parameters
[in]mThe maximal value
Author
Jean DUONG

Definition at line 378 of file CRNHistogram.cpp.

size_t crn::Histogram::Size ( ) const
inlinenoexcept

Returns the number of bins.

Definition at line 157 of file CRNHistogram.h.

std::vector< size_t > Histogram::StableModes ( ) const

Returns the stable modes.

Returns the stable modes through iterative smoothing

Warning
May be very slow on histograms containing huge values
Author
Yann LEYDIER
Returns
a vector containing the index of the classes that are stable modes

Definition at line 560 of file CRNHistogram.cpp.

std::vector<unsigned int> crn::Histogram::Std ( )
inline

Definition at line 284 of file CRNHistogram.h.

String Histogram::ToString ( ) const

Dumps bins to a string.

Dumps the bins to a string

Returns
a string containing the bins

Definition at line 1107 of file CRNHistogram.cpp.

double Histogram::Variance ( double  m) const

Variance on class indexes, having mean value.

Variance of the bin indexes in this histogram

Parameters
[in]mThe mean value previously computer
Returns
the variance of the bins indexes
Author
Jean DUONG

Definition at line 231 of file CRNHistogram.cpp.

double Histogram::Variance ( ) const

Variance on class indexes.

Variance of the bin indexes in this histogram

Returns
the variance of the bin indexes
Author
Jean DUONG

Definition at line 257 of file CRNHistogram.cpp.


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