latest version v1.9 - last update 10 Apr 2010 |
This class is used to extract the median of the elements of a given vector or matrix. More...
#include <ltiQuickMedian.h>
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 |
T | apply (matrix< T > &srcdest) const |
T & | apply (const matrix< T > &src, T &dest) const |
T | 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 |
T | 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 |
quickMedian & | copy (const quickMedian &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
Protected Member Functions | |
T | 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 |
T | 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 |
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 >.
lti::quickMedian< T >::quickMedian | ( | ) |
Default constructor.
lti::quickMedian< T >::quickMedian | ( | const typename parameters::eEvenCase | evenCase | ) |
Constructor with indicator what to do for even-sized vectors.
lti::quickMedian< T >::quickMedian | ( | const quickMedian< T > & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::quickMedian< T >::~quickMedian | ( | ) | [virtual] |
destructor
T& lti::quickMedian< T >::apply | ( | const std::vector< T > & | src, | |
std::vector< T > & | dest, | |||
T & | median | |||
) | const |
operates on the given parameter.
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 |
median
variable. T& lti::quickMedian< T >::apply | ( | const std::vector< T > & | src, | |
T & | dest | |||
) | const |
operates on the given parameter.
src | vector<T> with the source data. | |
dest | the median value |
dest
variable. 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.
srcdest | vector<T> with the source data. The result will be left here too. |
T& lti::quickMedian< T >::apply | ( | const vector< T > & | src, | |
vector< T > & | dest, | |||
T & | median | |||
) | const |
operates on the given parameter.
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 |
median
variable. T& lti::quickMedian< T >::apply | ( | const vector< T > & | src, | |
T & | dest | |||
) | const |
operates on the given parameter.
src | vector<T> with the source data. | |
dest | the median value |
dest
variable. 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.
srcdest | vector<T> with the source data. The result will be left here too. |
srcdest
. 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.
src | matrix<T> with the source data. | |
dest | the median value of the given matrix. |
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.
srcdest | matrix<T> with the source data. The result will be left here too. |
Referenced by lti::kdTree< T, D, U >::node::getMedianVal(), and lti::medianFilter::realMedian().
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 >.
quickMedian& lti::quickMedian< T >::copy | ( | const quickMedian< T > & | other | ) |
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::functor.
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
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
const parameters& lti::quickMedian< T >::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::functor.
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 >.
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.
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.