31 #ifndef IMAGE_SCALING2_H_
32 #define IMAGE_SCALING2_H_ "ImageScaling 0.1, 2017/09 Markus.Peura@fmi.fi"
34 #include <drain/Type.h>
35 #include <drain/TypeUtils.h>
36 #include <drain/UniTuple.h>
127 if (&scaling !=
this){
174 if (Type::call<drain::typeIsSmallInt>(t))
175 set(1.0/drain::Type::call<drain::typeMax,double>(t), 0.0);
183 set(
scale/scaleOut, (
offset - offsetOut)/scaleOut);
195 set(r2.width()/r1.width(), r2.min - r2.width()/r1.width()*r1.min);
295 double fwd(
double x)
const {
301 double inv(
double y)
const {
308 void toStream(std::ostream & ostr)
const {
315 std::string str()
const{
316 std::stringstream sstr;
tuplebase_t & assignSequence(T &sequence, bool LENIENT=false)
Proposed for tuples only; derived classes should not shadow this.
Definition: TupleBase.h:244
Tuple of N elements of type T.
Definition: UniTuple.h:65
Linear scaling and physical range for image intensities.
Definition: ValueScaling.h:64
double & scale
Multiplicative coefficient \i a in: y = ax + b.
Definition: ValueScaling.h:68
void setPhysicalRange(double min, double max)
Sets the supported range for physical values. Does not change scaling or type.
Definition: ValueScaling.h:246
double getMinPhys() const
Returns the minimum physical value.
Definition: ValueScaling.h:269
drain::Range< double > physRange
Minimum and maximum physical value of the imaged quantity (not limited to corresponding to minCodeVal...
Definition: ValueScaling.h:74
bool isPhysical() const
Returns true, physical intensity range has been set.
Definition: ValueScaling.h:281
Range< double > & getPhysicalRange()
Returns a typical or supported range for physical values. Modifying the range will not change scaling...
Definition: ValueScaling.h:227
bool isScaled() const
Returns true, if scaling has effect ie. scale!=1.0 or offset!=0.0.
Definition: ValueScaling.h:263
void setAbsoluteScale()
If the intensities of the image correspond to an absolute value (like count) then the scale should be...
Definition: ValueScaling.h:161
double fwd(double x) const
Forward scaling: given encoded value x, returns corresponding value (possibly physically meaningful).
Definition: ValueScaling.h:295
virtual ValueScaling & getScaling()
Get linear scaling.
Definition: ValueScaling.h:153
virtual const ValueScaling & getScaling() const
Get linear scaling.
Definition: ValueScaling.h:147
double & offset
Additive coefficient \i b in: y = ax + b.
Definition: ValueScaling.h:71
void setPhysicalRange(const Range< T > &range)
Sets the supported range for physical values. Does not change scaling or type.
Definition: ValueScaling.h:240
double getOffset() const
Returns the intensity scaling offset, ie. b in a*x + b . See set setScale()
Definition: ValueScaling.h:256
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),...
Definition: ValueScaling.h:182
void setPhysicalMax(double max)
In integer-valued images, set the physical values corresponding to [0, maxCodeValue].
Definition: ValueScaling.h:233
double getMaxPhys() const
Returns the maximum physical value.
Definition: ValueScaling.h:275
void setNormalScale(const std::type_info &t)
For "small integer" types, resets offset and scale such that maximum code value corresponds to 1....
Definition: ValueScaling.h:173
void setConversionScale(const drain::ValueScaling &s1, const drain::ValueScaling &s2)
Set scaling for which scaling.inv(x) = s2.inv(s1.fwd(x))
Definition: ValueScaling.h:188
const Range< double > & getPhysicalRange() const
Returns a typical or supported range for physical values.
Definition: ValueScaling.h:221
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.
Definition: ValueScaling.cpp:73
virtual void setScaling(double scale, double offset)
Set linear scaling.
Definition: ValueScaling.h:136
void setPhysicalScale(const std::type_info &t, const drain::ValueScaling &scaling)
Sets physical range (min, max) and scales storage type accordingly.
Definition: ValueScaling.h:214
double inv(double y) const
Inverse scaling: given physically meaningful value y, returns the corresponding code value.
Definition: ValueScaling.h:301
void setOptimalScale(const std::type_info &t)
If storage type is integer, adjust scale such that resolution is maximized.
Definition: ValueScaling.cpp:36
void setPhysicalScale(const std::type_info &t, double min, double max)
Sets physical range (min, max) and scales storage type accordingly.
Definition: ValueScaling.h:204
double getScale() const
Returns the intensity scaling factor. See set setScale()
Definition: ValueScaling.h:252
Definition: DataSelector.cpp:1277