A class for managing min/max range information. More...
#include <Image/Range.H>
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. | |
T | 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. |
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.
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().
const T& Range< T >::max | ( | ) | const [inline] |
Get the current max value.
Definition at line 77 of file Range.H.
Referenced by buildPyrRetinexLog(), HttpEncoder::close(), FfmpegEncoder::close(), doOneNormalize(), PlotBuffer::draw(), Range< T >::merge(), normalizeFloat(), and Range< T >::Range().
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().
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().
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().
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().
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().
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:
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().
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().
void Range< T >::setMax | ( | const T & | ma | ) | [inline] |
void Range< T >::setMin | ( | const T & | mi | ) | [inline] |