libcrn
3.9.5
A document image processing library
|
Mother class for integer histograms. More...
#include <CRNHistogram.h>
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) | |
Histogram & | operator= (const Histogram &)=delete |
Histogram (Histogram &&)=default | |
Histogram & | operator= (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... | |
![]() | |
virtual | ~Object ()=default |
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.
Definition at line 44 of file CRNHistogram.h.
|
strong |
Enumerator | |
---|---|
CUSTOM | |
SQUARE_ROOT | |
STURGES | |
SCOTT | |
FREEDMAN |
Definition at line 47 of file CRNHistogram.h.
|
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.
[in] | s | Size for this histogram |
[in] | v | Value to set up all the components for this histogram (default value = 0) |
Definition at line 42 of file CRNHistogram.cpp.
Histogram::Histogram | ( | const Histogram & | src, |
unsigned int | c = 1u |
||
) |
Copy constructor.
Constructor for this class
[in] | src | Source histogram |
[in] | c | compression ratio |
Definition at line 56 of file CRNHistogram.cpp.
|
inline |
Constructor for this class
[in] | it_begin | iterator pointing to first double-size_t pair of input data contener |
[in] | it_end | ending iterator |
[in] | m | histogram making heuristic |
[in] | nb_bins | number of default bins |
Definition at line 67 of file CRNHistogram.h.
|
default |
Histogram::~Histogram | ( | ) |
void Histogram::Append | ( | const Histogram & | h | ) |
Appends an histogram to the current.
Append an histogram
[in] | h | the histogram to append |
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
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
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
[in] | d | The sliding window's half-width |
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
ExceptionDimension | histograms do not have the same size |
[in] | h | the histogram to compare to |
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.
ExceptionDimension | histograms do not have the same size |
[in] | h | Histogram |
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
[in] | d | The sliding window's half-width |
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.
ExceptionDimension | histograms do not have the same size |
[in] | h | Histogram |
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
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
ExceptionInvalidArgument | not an Histogram |
ExceptionNotFound | cannot find CDATA |
ExceptionDomain | cannot find CDATA |
ExceptionRuntime | cannot convert CDATA |
[in] | el | the element to load |
Definition at line 1059 of file CRNHistogram.cpp.
|
inline |
Standard deviation on class indexes, having mean value.
Definition at line 186 of file CRNHistogram.h.
|
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.
ExceptionDimension | histograms do not have the same size |
[in] | h | the histogram to compare to |
Definition at line 901 of file CRNHistogram.cpp.
double Histogram::Entropy | ( | ) | const |
the entropy
Compute 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
Definition at line 1259 of file CRNHistogram.cpp.
size_t Histogram::Fisher | ( | ) | const |
Computes the Fisher threshold.
Computes the Fisher threshold
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
ExceptionDomain | index out of bounds |
[in] | k | the index of the bin to retrieve |
Definition at line 165 of file CRNHistogram.cpp.
|
inline |
Returns the internal pointer on the bins.
Definition at line 159 of file CRNHistogram.h.
|
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
ExceptionDomain | index out of bounds |
[in] | k | The index of the component to be modified |
[in] | i | The increment (default value = 1) |
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.
ExceptionDimension | histograms do not have the same size |
[in] | h | Histogram |
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.
ExceptionDimension | histograms do not have the same size |
[in] | h | Histogram |
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.
ExceptionDimension | histograms do not have the same size |
[in] | h | Histogram |
Definition at line 866 of file CRNHistogram.cpp.
ImageBW Histogram::MakeImageBW | ( | size_t | height | ) | const |
returns the histogram image
histogram image
[in] | height | the histogram image height |
Definition at line 1128 of file CRNHistogram.cpp.
Intersection between two histograms.
Intersection between two histograms The two histograms must have same size.
ExceptionDimension | histograms do not have the same size |
[in] | h | Histogram |
Definition at line 629 of file CRNHistogram.cpp.
Histogram Histogram::MakePopulationHistogram | ( | ) | const |
Creates an histogram from population.
Creates an histogram from population
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
[in] | radius | the histogram image radius |
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.
ExceptionDimension | histograms do not have the same size |
[in] | h | Histogram |
Definition at line 832 of file CRNHistogram.cpp.
unsigned int Histogram::Max | ( | ) | const |
Maximal count value.
Maximal count value for this histogram
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
Definition at line 205 of file CRNHistogram.cpp.
size_t Histogram::MedianValue | ( | ) | const |
Computes the median value.
Computes 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
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.
ExceptionDimension | histograms do not have the same size |
[in] | h | the other histogram |
[in] | r | power of the norm |
Definition at line 766 of file CRNHistogram.cpp.
std::vector< size_t > Histogram::Modes | ( | ) | const |
Returns the modes.
Search modes for this histogram
Definition at line 497 of file CRNHistogram.cpp.
|
inline |
Access a bin value (fast and unsafe)
Definition at line 173 of file CRNHistogram.h.
|
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
ExceptionDomain | null new size |
[in] | newsize | the new size |
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
[in] | m | The desired maximal value |
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
[in] | parent | the parent element to which we will add the new 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
ExceptionDomain | index out of bounds |
[in] | k | The index of the component to be modified |
[in] | v | The new value for k-th component |
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
[in] | m | The maximal value |
Definition at line 378 of file CRNHistogram.cpp.
|
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
Definition at line 560 of file CRNHistogram.cpp.
|
inline |
Definition at line 284 of file CRNHistogram.h.
String Histogram::ToString | ( | ) | const |
Dumps bins to a string.
Dumps the bins to a string
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
[in] | m | The mean value previously computer |
Definition at line 231 of file CRNHistogram.cpp.
double Histogram::Variance | ( | ) | const |
Variance on class indexes.
Variance of the bin indexes in this histogram
Definition at line 257 of file CRNHistogram.cpp.