Public Member Functions | Public Attributes | List of all members
ValueScaling Class Reference

Linear scaling and physical range for image intensities. More...

#include <ValueScaling.h>

Inheritance diagram for ValueScaling:
Inheritance graph
[legend]
Collaboration diagram for ValueScaling:
Collaboration graph
[legend]

Public Member Functions

 ValueScaling (double scale=1.0, double offset=0.0)
 
 ValueScaling (double scale, double offset, const drain::Range< double > &range)
 
 ValueScaling (const drain::ValueScaling &scaling)
 
 ValueScaling (const drain::UniTuple< double, 2 > &scaling)
 
 ValueScaling (const drain::ValueScaling &scalingIn, const drain::ValueScaling &scalingOut)
 
ValueScalingoperator= (const drain::ValueScaling &scaling)
 
virtual void setScaling (double scale, double offset)
 Set linear scaling.
 
virtual void setScaling (const ValueScaling &scaling)
 
virtual const ValueScalinggetScaling () const
 Get linear scaling.
 
virtual ValueScalinggetScaling ()
 Get linear scaling.
 
void setAbsoluteScale ()
 If the intensities of the image correspond to an absolute value (like count) then the scale should be reset to unity with this function.
 
void setNormalScale (const std::type_info &t)
 For "small integer" types, resets offset and scale such that maximum code value corresponds to 1.0 (100% intensity). More...
 
void setConversionScale (double scale, double offset=0.0, double scaleOut=1.0, double offsetOut=0.0)
 If the intensities of the image correspond to a physical value (like temperature), then the scaling coefficient should be set with this function.
 
void setConversionScale (const drain::ValueScaling &s1, const drain::ValueScaling &s2)
 Set scaling for which scaling.inv(x) = s2.inv(s1.fwd(x))
 
void setConversionScale (const Range< double > &r1, const Range< double > &r2)
 
void setOptimalScale (const std::type_info &t)
 If storage type is integer, adjust scale such that resolution is maximized.
 
void setPhysicalScale (const std::type_info &t, double min, double max)
 Sets physical range (min, max) and scales storage type accordingly.
 
void setPhysicalScale (const std::type_info &t, const drain::ValueScaling &scaling)
 Sets physical range (min, max) and scales storage type accordingly.
 
const Range< double > & getPhysicalRange () const
 Returns a typical or supported range for physical values.
 
Range< double > & getPhysicalRange ()
 Returns a typical or supported range for physical values. Modifying the range will not change scaling.
 
void setPhysicalMax (double max)
 In integer-valued images, set the physical values corresponding to [0, maxCodeValue].
 
template<class T >
void setPhysicalRange (const Range< T > &range)
 Sets the supported range for physical values. Does not change scaling or type.
 
void setPhysicalRange (double min, double max)
 Sets the supported range for physical values. Does not change scaling or type.
 
double getScale () const
 Returns the intensity scaling factor. See set setScale()
 
double getOffset () const
 Returns the intensity scaling offset, ie. b in a*x + b . See set setScale()
 
bool isScaled () const
 Returns true, if scaling has effect ie. scale!=1.0 or offset!=0.0. More...
 
double getMinPhys () const
 Returns the minimum physical value.
 
double getMaxPhys () const
 Returns the maximum physical value.
 
bool isPhysical () const
 Returns true, physical intensity range has been set.
 
void adoptScaling (const drain::ValueScaling &srcScaling, const std::type_info &srcType, const std::type_info &dstType=typeid(void))
 Sets scale and offset according to physical range and current type.
 
double fwd (double x) const
 Forward scaling: given encoded value x, returns corresponding value (possibly physically meaningful).
 
double inv (double y) const
 Inverse scaling: given physically meaningful value y, returns the corresponding code value.
 
void toStream (std::ostream &ostr) const
 
std::string str () const
 
- Public Member Functions inherited from UniTuple< double, 2 >
 UniTuple (const TT &... args)
 
 UniTuple (const UniTuple< double, N > &t)
 Copy constructor.
 
 UniTuple (std::initializer_list< S > l)
 
tuple_toperator= (const tuple_t &t)
 
tuple_toperator= (const value_type &value)
 
tuple_toperator= (std::initializer_list< S > l)
 
virtual const_iterator begin () const override final
 
virtual iterator begin () override final
 
virtual const_iterator end () const override final
 
virtual iterator end () override final
 
tuple_ttuple ()
 
const tuple_ttuple () const
 
void debug (std::ostream &ostr) const
 
- Public Member Functions inherited from TupleBase< S, N >
const S & at (size_t i) const
 Return const reference to element i. More...
 
const S & operator[] (size_t i) const
 
S & at (size_t i)
 Return reference to element i. More...
 
S & operator[] (size_t i)
 
bool operator== (const tuplebase_t &t) const
 Equality operator.
 
bool operator!= (const tuplebase_t &t) const
 Inequality operator.
 
template<class T >
T & toSequence (T &sequence) const
 Copy elements to a Sequence, like stl::list, stl::set or stl::vector.
 
void set (const tuplebase_t &t)
 
template<class T2 , size_t N2 = 2>
void set (const TupleBase< T2, N2 > &t)
 Assign tuple of different type and/or size.
 
void set (const S &arg)
 
template<typename ... SS>
void set (const S &arg, const SS &... rest)
 Set element(s).
 
template<typename T >
void set (std::initializer_list< T > l)
 
template<class T >
tuplebase_tassignSequence (T &sequence, bool LENIENT=false)
 Proposed for tuples only; derived classes should not shadow this. More...
 
void fill (S i)
 Set all the elements to i.
 
void clear ()
 
virtual std::ostream & toStream (std::ostream &ostr, char separator=',') const
 
std::string toStr (char separator=',') const
 
virtual void updateTuple ()
 

Public Attributes

double & scale
 Multiplicative coefficient \i a in: y = ax + b.
 
double & offset
 Additive coefficient \i b in: y = ax + b.
 
drain::Range< double > physRange
 Minimum and maximum physical value of the imaged quantity (not limited to corresponding to minCodeValue?).
 

Additional Inherited Members

- Public Types inherited from UniTuple< double, 2 >
typedef double value_type
 
typedef UniTuple< double, N > tuple_t
 
typedef double * iterator
 
typedef const double * const_iterator
 
- Public Types inherited from TupleBase< S, N >
typedef TupleBase< S, N > tuplebase_t
 
typedef S value_type
 
typedef S * iterator
 
typedef S const * const_iterator
 
- Static Public Member Functions inherited from TupleBase< S, N >
static size_t size ()
 Return the number of elements. More...
 
- Static Public Attributes inherited from UniTuple< double, 2 >
static const size_t tuple_size
 
- Static Public Attributes inherited from TupleBase< S, N >
static const size_t storageTypeSize = sizeof(S)
 
- Protected Member Functions inherited from UniTuple< double, 2 >
 UniTuple (UniTuple< double, N2 > &tuple, size_t i)
 
double & next ()
 
- Protected Member Functions inherited from TupleBase< S, N >
void setIndexed (size_t i)
 Argument stack endpoint function; final step of variadic argument set(arg, ...) .
 
template<typename T2 , typename ... TT>
void setIndexed (size_t i, T2 arg, const TT &... rest)
 Worker called by set(T2 arg, T2 arg2, ...)
 
- Protected Attributes inherited from UniTuple< double, 2 >
const iterator start
 

Detailed Description

Linear scaling and physical range for image intensities.

Internally,drain::ValueScaling holds variables

drain::ValueScaling does not store information of storage type (no either on minimum and maximum values supported by storage types).

See also
drain::typeLimits

Member Function Documentation

◆ isScaled()

bool isScaled ( ) const
inline

Returns true, if scaling has effect ie. scale!=1.0 or offset!=0.0.

Note: returns true if scale==0. Maybe false would be better.

◆ setNormalScale()

void setNormalScale ( const std::type_info &  t)
inline

For "small integer" types, resets offset and scale such that maximum code value corresponds to 1.0 (100% intensity).

Applies to:

  • char
  • unsigned char
  • short int
  • unsigned short int

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