LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::quickMedian< T > Class Template Reference
[Basic Statistics]

This class is used to extract the median of the elements of a given vector or matrix. More...

#include <ltiQuickMedian.h>

Inheritance diagram for lti::quickMedian< T >:
Inheritance graph
[legend]
Collaboration diagram for lti::quickMedian< T >:
Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 The parameters for the class quickMedian. More...

Public Member Functions

 quickMedian ()
 quickMedian (const typename parameters::eEvenCase evenCase)
 quickMedian (const quickMedian< T > &other)
virtual ~quickMedian ()
virtual const char * getTypeName () const
apply (matrix< T > &srcdest) const
T & apply (const matrix< T > &src, T &dest) const
apply (vector< T > &srcdest) const
T & apply (const vector< T > &src, T &dest) const
T & apply (const vector< T > &src, vector< T > &dest, T &median) const
apply (std::vector< T > &srcdest) const
T & apply (const std::vector< T > &src, T &dest) const
T & apply (const std::vector< T > &src, std::vector< T > &dest, T &median) const
quickMediancopy (const quickMedian &other)
virtual functorclone () const
const parametersgetParameters () const

Protected Member Functions

findMedian (vector< T > &vct, const int &begin, const int &end, const int &medianPos) const
int partition (vector< T > &vct, const int &begin, const int &end) const
findMedian (std::vector< T > &vct, const int &begin, const int &end, const int &medianPos) const
int partition (std::vector< T > &vct, const int &begin, const int &end) const

Detailed Description

template<class T>
class lti::quickMedian< T >

This class is used to extract the median of the elements of a given vector or matrix.

The median is defined as the element at the middle position of the sorted vector. The algorithm used is based on the quick sort. For vectors (or matrices) with an even number n of elements, the median will be the element at (n/2) or (n/2)-1 depending on the parameter settings.

The type of the vector elements (T) must accept the operators < and >.


Constructor & Destructor Documentation

template<class T>
lti::quickMedian< T >::quickMedian (  ) 

Default constructor.

template<class T>
lti::quickMedian< T >::quickMedian ( const typename parameters::eEvenCase  evenCase  ) 

Constructor with indicator what to do for even-sized vectors.

template<class T>
lti::quickMedian< T >::quickMedian ( const quickMedian< T > &  other  ) 

copy constructor

Parameters:
other the object to be copied
template<class T>
virtual lti::quickMedian< T >::~quickMedian (  )  [virtual]

destructor


Member Function Documentation

template<class T>
T& lti::quickMedian< T >::apply ( const std::vector< T > &  src,
std::vector< T > &  dest,
T &  median 
) const

operates on the given parameter.

Parameters:
src vector<T> with the source data.
dest the partially sorted vector. The elements at the first half of the vector are less or equal than the median and on the other half greater or equal.
median the median value
Returns:
a reference to the median variable.
template<class T>
T& lti::quickMedian< T >::apply ( const std::vector< T > &  src,
T &  dest 
) const

operates on the given parameter.

Parameters:
src vector<T> with the source data.
dest the median value
Returns:
a reference to the dest variable.
template<class T>
T lti::quickMedian< T >::apply ( std::vector< T > &  srcdest  )  const

operates on the given parameter.

The resulting vector contains the elements less or equal than the median for the indexes x such that x < size()/2, and higher or equal otherwise.

Parameters:
srcdest vector<T> with the source data. The result will be left here too.
Returns:
the median value.
template<class T>
T& lti::quickMedian< T >::apply ( const vector< T > &  src,
vector< T > &  dest,
T &  median 
) const

operates on the given parameter.

Parameters:
src vector<T> with the source data.
dest the partially sorted vector. The elements at the first half of the vector are less or equal than the median and on the other half greater or equal.
median the median value
Returns:
a reference to the median variable.
template<class T>
T& lti::quickMedian< T >::apply ( const vector< T > &  src,
T &  dest 
) const

operates on the given parameter.

Parameters:
src vector<T> with the source data.
dest the median value
Returns:
a reference to the dest variable.
template<class T>
T lti::quickMedian< T >::apply ( vector< T > &  srcdest  )  const

operates on the given parameter.

The resulting vector contains the elements less or equal than the median for the indexes x such that x < size()/2, and higher or equal otherwise.

Parameters:
srcdest vector<T> with the source data. The result will be left here too.
Returns:
a reference to the srcdest.
template<class T>
T& lti::quickMedian< T >::apply ( const matrix< T > &  src,
T &  dest 
) const

calculates the median of the given matrix, which is NOT modified.

The elements of the matrix will be considered as part of a vector with "columns()" times "rows()" elements.

Parameters:
src matrix<T> with the source data.
dest the median value of the given matrix.
Returns:
the median of the matrix (as reference to the dest parameter)
template<class T>
T lti::quickMedian< T >::apply ( matrix< T > &  srcdest  )  const

operates on the given matrix, which WILL BE modified.

The resulting matrix contain the elements less or equal than the median for the indexes (x,y) such that (x+y*rows() < rows()*columns()/2), and higher or equal otherwise.

Parameters:
srcdest matrix<T> with the source data. The result will be left here too.
Returns:
the median of the matrix

Referenced by lti::kdTree< T, D, U >::node::getMedianVal(), and lti::medianFilter::realMedian().

template<class T>
virtual functor* lti::quickMedian< T >::clone (  )  const [virtual]

returns a pointer to a clone of this functor.

Implements lti::functor.

Reimplemented in lti::quickMedian2< T, U >.

template<class T>
quickMedian& lti::quickMedian< T >::copy ( const quickMedian< T > &  other  ) 

copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::functor.

template<class T>
T lti::quickMedian< T >::findMedian ( std::vector< T > &  vct,
const int &  begin,
const int &  end,
const int &  medianPos 
) const [protected]

this method calculates the median in a recursively form

template<class T>
T lti::quickMedian< T >::findMedian ( vector< T > &  vct,
const int &  begin,
const int &  end,
const int &  medianPos 
) const [protected]

this method calculates the median in a recursively form

template<class T>
const parameters& lti::quickMedian< T >::getParameters (  )  const

returns used parameters

Reimplemented from lti::functor.

template<class T>
virtual const char* lti::quickMedian< T >::getTypeName (  )  const [virtual]

returns the name of this type ("quickMedian")

Reimplemented from lti::functor.

Reimplemented in lti::quickMedian2< T, U >.

template<class T>
int lti::quickMedian< T >::partition ( std::vector< T > &  vct,
const int &  begin,
const int &  end 
) const [protected]

this method chooses a pivot-value and ensures that lower values lie at the left and higher values at the right of its final position, which will be returned.

template<class T>
int lti::quickMedian< T >::partition ( vector< T > &  vct,
const int &  begin,
const int &  end 
) const [protected]

this method chooses a pivot-value and ensures that lower values lie at the left and higher values at the right of its final position, which will be returned.


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

Generated on Sat Apr 10 15:28:37 2010 for LTI-Lib by Doxygen 1.6.1