Range< T > Class Template Reference

A class for managing min/max range information. More...

#include <Image/Range.H>

Collaboration diagram for Range< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Range ()
 Default constructor.
 Range (const T &mi, const T &ma)
 Construct with given min and max values.
const T & min () const
 Get the current min value.
const T & max () const
 Get the current max value.
range () const
 Get the range (i.e. the difference of max minus min).
void setMin (const T &mi)
 Set the range's min value.
void setMax (const T &ma)
 Set the range's max value.
void mergeMin (const T &v)
 Update our min value if val is less than the current max.
void mergeMax (const T &val)
 Update our max value if val is greater than the current max.
void merge (const T &val)
 Update our min or max value if val falls outside of the current range.
void operator() (const T &v)
 This operator() allows straightforward use in generic algorithms.
void merge (const Range< T > &other)
 Merge other's min and max values into ours.
bool operator== (const Range &x) const throw ()
 See if two Range are the same.
bool operator!= (const Range &x) const throw ()
 See if two Range are different.

Detailed Description

template<class T>
class Range< T >

A class for managing min/max range information.

This class is primarily intended to work with algorithms that manipulate the dynamic range of Image<T>'s. For example, it can help to specify how an image should have its current dynamic range remapped to a new range (see remapRange() in Image_MathOps.H). In addition, the Range<T> class provides an operator() that allows it to be used as a functor in generic algorithms for accumulating the min/max over a sequence of elements (as in rangeOf() in Image_MathOps.H).

Definition at line 53 of file Range.H.


Constructor & Destructor Documentation

template<class T >
Range< T >::Range (  )  [inline]

Default constructor.

We initialize the object's min element with type T's max value, and we initialize the object's max element with type T's min value. This seeming paradoxical situation is in fact "The Right Thing" if we want to accumulate the min/max over a range of elements. The starting condition of the Range object should make the weakest possible assumption about the values that will be observed; and this weakest assumption is precisely to start with the min being as large as possible, and the max being as small as possible.

Definition at line 132 of file Range.H.

References Range< T >::max().

template<class T>
Range< T >::Range ( const T &  mi,
const T &  ma 
) [inline]

Construct with given min and max values.

Definition at line 141 of file Range.H.


Member Function Documentation

template<class T>
const T& Range< T >::max (  )  const [inline]
template<class T>
void Range< T >::merge ( const Range< T > &  other  )  [inline]

Merge other's min and max values into ours.

Definition at line 170 of file Range.H.

References Range< T >::max(), Range< T >::mergeMax(), Range< T >::mergeMin(), and Range< T >::min().

template<class T>
void Range< T >::merge ( const T &  val  )  [inline]

Update our min or max value if val falls outside of the current range.

Definition at line 155 of file Range.H.

References Range< T >::mergeMax(), and Range< T >::mergeMin().

Referenced by HttpEncoder::close(), FfmpegEncoder::close(), Range< T >::operator()(), and rangeOf().

template<class T>
void Range< T >::mergeMax ( const T &  val  )  [inline]

Update our max value if val is greater than the current max.

Definition at line 151 of file Range.H.

Referenced by Range< T >::merge().

template<class T>
void Range< T >::mergeMin ( const T &  v  )  [inline]

Update our min value if val is less than the current max.

Definition at line 147 of file Range.H.

Referenced by Range< T >::merge().

template<class T>
const T& Range< T >::min (  )  const [inline]

Get the current min value.

Definition at line 74 of file Range.H.

Referenced by HttpEncoder::close(), FfmpegEncoder::close(), PlotBuffer::draw(), Range< T >::merge(), normalizeFloat(), and remapRange().

template<class T >
bool Range< T >::operator!= ( const Range< T > &  x  )  const throw () [inline]

See if two Range are different.

Definition at line 185 of file Range.H.

References operator==().

template<class T>
void Range< T >::operator() ( const T &  v  )  [inline]

This operator() allows straightforward use in generic algorithms.

In particular, this is useful for accumulating the min/max over a range of elements. For example, rangeOf() could be implemented like this:

      Image<T> img;
      Range<T> rng = std::for_each(img.begin(), img.end(), Range<T>());

We construct a default Range<T> object, which is copied and passed to for_each(), which in turn calls operator() on that range object for each element in the iterator sequence that is visited.

Definition at line 163 of file Range.H.

References Range< T >::merge().

template<class T >
bool Range< T >::operator== ( const Range< T > &  x  )  const throw () [inline]

See if two Range are the same.

Definition at line 178 of file Range.H.

References max(), and min().

template<class T>
T Range< T >::range (  )  const [inline]

Get the range (i.e. the difference of max minus min).

Definition at line 80 of file Range.H.

Referenced by remapRange().

template<class T>
void Range< T >::setMax ( const T &  ma  )  [inline]

Set the range's max value.

Definition at line 86 of file Range.H.

template<class T>
void Range< T >::setMin ( const T &  mi  )  [inline]

Set the range's min value.

Definition at line 83 of file Range.H.


The documentation for this class was generated from the following file:
Generated on Sun May 8 08:43:46 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3