DGtal 1.4.0
|
Aim: This class can be used to represent a profile (PX, PY) defined from an input set of samples (Xi, Yi). For all sample (Xk, Yk) having the same value Xk, the associated value PY is computed (by default) by the mean of the values Yk. Note that other definitions can be used (MAX, MIN or MEDIAN). Internally each sample abscissa is an instance of DGtal::Statistic. More...
#include <DGtal/math/Profile.h>
Public Types | |
enum | ProfileType { MEAN , MAX , MIN , MEDIAN } |
typedef TValueFunctor | Functor |
typedef TValue | Value |
Public Member Functions | |
BOOST_CONCEPT_ASSERT ((concepts::CUnaryFunctor< Functor, Value, Value >)) | |
~Profile () | |
Profile () | |
Profile (ProfileType type) | |
Profile (const Profile &other) | |
Profile & | operator= (const Profile &other) |
void | clear () |
template<typename Iterator > | |
void | init (Iterator beginXvalues, Iterator endXvalues, const bool storeValsInStats=false) |
void | init (const unsigned int nb, const bool storeValsInStats=false) |
void | addValue (const unsigned int indexX, const TValue value) |
void | addStatistic (const unsigned int indexX, const Statistic< Value > &stat) |
void | stopStatsSaving () |
void | setType (const ProfileType type) |
void | getProfile (std::vector< Value > &x, std::vector< Value > &y) const |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
Private Attributes | |
Functor | myFunctor |
std::vector< Value > * | myXsamples |
std::vector< Statistic< Value > > * | myStats |
ProfileType | myProfileDef |
bool | myStoreValInStats |
Aim: This class can be used to represent a profile (PX, PY) defined from an input set of samples (Xi, Yi). For all sample (Xk, Yk) having the same value Xk, the associated value PY is computed (by default) by the mean of the values Yk. Note that other definitions can be used (MAX, MIN or MEDIAN). Internally each sample abscissa is an instance of DGtal::Statistic.
Description of class 'Profile'
This class is templated by the type of the functor TValueFunctor which is applied on the two coordinate values of the resulting profile (PX, PY). This functor is by default set to the identity functor. The default type (double) of the values added to the profile can also be changed by using the template parameter TValue.
For instance to construct a Profile defined from a data sample having its Xi integer values from 1 to 10, you can construct and initialize a Profile as follows:
Alternatively you can customize the Xi initialisation by using an iterator:
Then, you can add the samples (Xk, Yk):
To obtain a profile given in log space, you just have to define the following basic log functor:
And then you can construct a profile as previously:
TValueFunctor | the type of the functor applied in the resulting Profile (any model of CUnaryFunctor) |
TValue | the type value stored in the profile. |
The proposed implementation is mainly a backport from ImaGene with some various refactoring.
typedef TValueFunctor DGtal::Profile< TValueFunctor, TValue >::Functor |
typedef TValue DGtal::Profile< TValueFunctor, TValue >::Value |
enum DGtal::Profile::ProfileType |
Used to specify the method to compute the profile values (used in getProfile())
Enumerator | |
---|---|
MEAN | |
MAX | |
MIN | |
MEDIAN |
Definition at line 146 of file Profile.h.
DGtal::Profile< TValueFunctor, TValue >::~Profile | ( | ) |
Destructor.
DGtal::Profile< TValueFunctor, TValue >::Profile | ( | ) |
Constructor. The object is not valid.
DGtal::Profile< TValueFunctor, TValue >::Profile | ( | ProfileType | type | ) |
Constructor. The object is not valid.
[in] | type | allows to specify the used to computes the profile points from the added samples. |
DGtal::Profile< TValueFunctor, TValue >::Profile | ( | const Profile< TValueFunctor, TValue > & | other | ) |
Copy constructor.
[in] | other | the object to clone. |
void DGtal::Profile< TValueFunctor, TValue >::addStatistic | ( | const unsigned int | indexX, |
const Statistic< Value > & | stat ) |
Adds some statistic at the given X value.
[in] | indexX | some valid index (according to init). |
[in] | stat | any statistic (which is added to the current statistic object). |
void DGtal::Profile< TValueFunctor, TValue >::addValue | ( | const unsigned int | indexX, |
const TValue | value ) |
Adds some sample value at the given X value.
[in] | indexX | some valid index (according to init). |
[in] | value | any value. |
Referenced by TEST_CASE(), and TEST_CASE().
DGtal::Profile< TValueFunctor, TValue >::BOOST_CONCEPT_ASSERT | ( | (concepts::CUnaryFunctor< Functor, Value, Value >) | ) |
void DGtal::Profile< TValueFunctor, TValue >::clear | ( | ) |
Clears the object as if it has been just created.
void DGtal::Profile< TValueFunctor, TValue >::getProfile | ( | std::vector< Value > & | x, |
std::vector< Value > & | y ) const |
[out] | x | (modified) adds the x-value of the profile to the back of the vector. |
[out] | y | (modified) adds the y-value of the profile (log(Exp(samples))) to the back of the vector. |
Referenced by TEST_CASE().
void DGtal::Profile< TValueFunctor, TValue >::init | ( | const unsigned int | nb, |
const bool | storeValsInStats = false ) |
Initializer. Must be called before adding datas. Specifies the X values of the profile as the sequence (1,2,3,4,...,nb).
[in] | nb | an integer number strictly positive. |
[in] | storeValsInStats | flag to store values in statistics (so that the median value is accessible (default false)). |
void DGtal::Profile< TValueFunctor, TValue >::init | ( | Iterator | beginXvalues, |
Iterator | endXvalues, | ||
const bool | storeValsInStats = false ) |
Initializer. Must be called before adding datas. Specifies the X values of the profile (generally an iterator on a sequence (1,2,3,4,...N)).
[in] | beginXvalues | an iterator pointing on the first X value. |
[in] | endXvalues | an iterator pointing after the last X value. |
[in] | storeValsInStats | flag to store values in statistics (so that the median value is accessible (default false)). |
Referenced by TEST_CASE(), and TEST_CASE().
bool DGtal::Profile< TValueFunctor, TValue >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
Profile & DGtal::Profile< TValueFunctor, TValue >::operator= | ( | const Profile< TValueFunctor, TValue > & | other | ) |
Assignment.
[in] | other | the object to copy. |
void DGtal::Profile< TValueFunctor, TValue >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
[out] | out | the output stream where the object is written. |
void DGtal::Profile< TValueFunctor, TValue >::setType | ( | const ProfileType | type | ) |
Used to define the method to determine the profile values from the samples of X statistics.
[in] | type | the method applied to the statistics samples: MEAN, MAX, MIN. |
Referenced by TEST_CASE().
void DGtal::Profile< TValueFunctor, TValue >::stopStatsSaving | ( | ) |
It stops and Erase the stats saved values. It must be called to avoid to store all statistics values when we have to access to the median value. Typically if you nedd to access to the median value of the profile, you need to follow this example:
|
private |
|
private |
|
private |
|
private |
|
private |