#include <qgarlib/Histogram.H>
A histogram records frequencies of samples in a vector of cells. A sample is a value in the range [ lowerBnd, upperBnd ]. Bounds may be negative. A cell records the frequency of samples included in [ sample, sample + samplingRate [; the default sampling rate is 1. For example, the cell at the lower bound records the frequency of samples in [ lowerBnd, lowerBnd + samplingRate [.
Definition at line 87 of file Histogram.H.
Public Member Functions | |
Constructors | |
| Histogram () | |
| Default constructor. | |
| Histogram (const Histogram &aHistg) | |
| Copy constructor. | |
| Histogram (int aLowerBnd, int anUpperBnd, unsigned int aSampRate=1) throw (QgarErrorDomain) | |
| Construct from lower and upper bounds, and a sampling rate. | |
| Histogram (const GreyLevelImage &anImg, int aLowerBnd=0, int anUpperBnd=255, unsigned int aSampRate=1) throw (QgarErrorDomain) | |
| Construct from a grey-level image. | |
Destructor | |
| virtual | ~Histogram () |
| Virtual destructor. | |
Access | |
| int | lowerBnd () const |
| Get lower bound. | |
| int | upperBnd () const |
| Get upper bound. | |
| int | samplingRate () const |
| Get cell width. | |
Frequencies | |
| void | plus (int aSample, unsigned int anIncr=1) |
| Add a given value (default 1) to the frequency of a sample. | |
| void | minus (int aSample, unsigned int aDecr=1) |
| Subtract a given value (default 1) to the frequency of a sample. | |
| int | maxSample () |
| Get sample with maximum frequency. | |
| int | maxSample (int aBnd) |
| Get sample with maximum frequency in [aBnd, upperBnd]. | |
| int | minSample () |
| Get sample with minimum frequency. | |
| int | minSample (int aBnd) |
| Get sample with minimum frequency in [aBnd, upperBnd]. | |
Operators | |
| int & | operator[] (int aSample) throw (QgarErrorDomain) |
| Return the frequency of a sample. | |
| Histogram & | operator= (const Histogram &aHistg) |
| Assignment. | |
Histogram transformations | |
| void | partialSum () |
| Transform into an accumulated histogram. | |
| void | smooth (unsigned int aWidth) throw (QgarErrorDomain) |
| Smooth by computing a simple average on a window of given size. | |
Protected Attributes | |
Representation of a histogram | |
| int | _samplingRate |
| Sampling rate. | |
| int | _lowerBnd |
| Lower (non-sampled) bound. | |
| int | _upperBnd |
| Upper (non-sampled) bound. | |
| std::vector< int > | _cells |
| Vector of cells. | |
Private Member Functions | |
Access to the cell vector | |
| int | sampIdx (int aSample) const throw (QgarErrorDomain) |
| Index (in the cell vector) corresponding to a sample. | |
|
|
Default constructor. Sampling rate is set to 1, lower and upper bounds to 0, and the vector of cells is empty. Definition at line 63 of file Histogram.C. |
|
|
Copy constructor.
Definition at line 76 of file Histogram.C. |
|
||||||||||||||||
|
Construct from lower and upper bounds, and a sampling rate. All cells are set to 0.
Definition at line 90 of file Histogram.C. |
|
||||||||||||||||||||
|
Construct from a grey-level image.
Definition at line 132 of file Histogram.C. |
|
|
Virtual destructor.
Definition at line 192 of file Histogram.C. |
|
|
Get lower bound.
Definition at line 367 of file Histogram.H. References _lowerBnd. Referenced by qgar::MapleFile::MapleFile(). |
|
|
Get sample with maximum frequency in [aBnd, upperBnd]. If several samples have the same (maximum) frequency, return the first sample starting from aBnd.
Definition at line 218 of file Histogram.C. References _cells, _lowerBnd, and _samplingRate. |
|
|
Get sample with maximum frequency. If several samples have the same (maximum) frequency, return the first sample starting from the lower bound. Definition at line 208 of file Histogram.C. References _cells, _lowerBnd, and _samplingRate. |
|
|
Get sample with minimum frequency in [aBnd, upperBnd]. If several samples have the same (minimum) frequency, return the first sample starting from aBnd.
Definition at line 241 of file Histogram.C. References _cells, _lowerBnd, and _samplingRate. |
|
|
Get sample with minimum frequency. If several samples have the same (minimum) frequency, return the first sample starting from the lower bound. Definition at line 231 of file Histogram.C. References _cells, _lowerBnd, and _samplingRate. |
|
||||||||||||
|
Subtract a given value (default 1) to the frequency of a sample.
Definition at line 359 of file Histogram.C. |
|
|
Assignment.
Definition at line 261 of file Histogram.C. References _cells, _lowerBnd, _samplingRate, and _upperBnd. |
|
|
Return the frequency of a sample.
Definition at line 398 of file Histogram.H. |
|
|
Transform into an accumulated histogram.
Definition at line 415 of file Histogram.H. References _cells. |
|
||||||||||||
|
Add a given value (default 1) to the frequency of a sample.
Definition at line 350 of file Histogram.C. |
|
|
Index (in the cell vector) corresponding to a sample.
Definition at line 375 of file Histogram.C. |
|
|
Get cell width.
Definition at line 384 of file Histogram.H. References _samplingRate. Referenced by qgar::MapleFile::MapleFile(). |
|
|
Smooth by computing a simple average on a window of given size.
Definition at line 285 of file Histogram.C. |
|
|
Get upper bound.
Definition at line 376 of file Histogram.H. References _upperBnd. Referenced by qgar::MapleFile::MapleFile(). |
|
|
Vector of cells.
Definition at line 321 of file Histogram.H. Referenced by maxSample(), minSample(), minus(), operator=(), partialSum(), and plus(). |
|
|
Lower (non-sampled) bound.
Definition at line 311 of file Histogram.H. Referenced by lowerBnd(), maxSample(), minSample(), and operator=(). |
|
|
Sampling rate. It is the ``width'' of a cell of the cell vector. Definition at line 306 of file Histogram.H. Referenced by maxSample(), minSample(), operator=(), and samplingRate(). |
|
|
Upper (non-sampled) bound.
Definition at line 316 of file Histogram.H. Referenced by operator=(), and upperBnd(). |