31#ifndef IMAGE_SCALING2_H_
32#define IMAGE_SCALING2_H_ "ImageScaling 0.1, 2017/09 Markus.Peura@fmi.fi"
34#include <drain/TypeUtils.h>
35#include <drain/UniTuple.h>
126 if (&scaling !=
this){
173 if (Type::call<drain::typeIsSmallInt>(t))
174 set(1.0/drain::Type::call<drain::typeMax,double>(t), 0.0);
182 set(
scale/scaleOut, (
offset - offsetOut)/scaleOut);
194 set(r2.width()/r1.width(), r2.min - r2.width()/r1.width()*r1.min);
294 double fwd(
double x)
const {
300 double inv(
double y)
const {
305 void toStream(std::ostream & ostr)
const override {
312 std::string str()
const{
313 std::stringstream sstr;
tuplebase_t & assignSequence(T &sequence, bool LENIENT=false)
Proposed for tuples only; derived classes should not shadow this.
Definition TupleBase.h:287
Tuple of N elements of type T.
Definition UniTuple.h:65
Linear scaling and physical range for image intensities.
Definition ValueScaling.h:63
double & scale
Multiplicative coefficient \i a in: y = ax + b.
Definition ValueScaling.h:67
void setPhysicalRange(double min, double max)
Sets the supported range for physical values. Does not change scaling or type.
Definition ValueScaling.h:245
const Range< double > & getPhysicalRange() const
Returns a typical or supported range for physical values.
Definition ValueScaling.h:220
double getMinPhys() const
Returns the minimum physical value.
Definition ValueScaling.h:268
drain::Range< double > physRange
Minimum and maximum physical value of the imaged quantity (not limited to corresponding to minCodeVal...
Definition ValueScaling.h:73
virtual ValueScaling & getScaling()
Get linear scaling.
Definition ValueScaling.h:152
bool isPhysical() const
Returns true, physical intensity range has been set.
Definition ValueScaling.h:280
bool isScaled() const
Returns true, if scaling has effect ie. scale!=1.0 or offset!=0.0.
Definition ValueScaling.h:262
void setAbsoluteScale()
If the intensities of the image correspond to an absolute value (like count) then the scale should be...
Definition ValueScaling.h:160
double fwd(double x) const
Forward scaling: given encoded value x, returns corresponding value (possibly physically meaningful).
Definition ValueScaling.h:294
double & offset
Additive coefficient \i b in: y = ax + b.
Definition ValueScaling.h:70
void setPhysicalRange(const Range< T > &range)
Sets the supported range for physical values. Does not change scaling or type.
Definition ValueScaling.h:239
double getOffset() const
Returns the intensity scaling offset, ie. b in a*x + b . See set setScale()
Definition ValueScaling.h:255
Range< double > & getPhysicalRange()
Returns a typical or supported range for physical values. Modifying the range will not change scaling...
Definition ValueScaling.h:226
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:181
void setPhysicalMax(double max)
In integer-valued images, set the physical values corresponding to [0, maxCodeValue].
Definition ValueScaling.h:232
double getMaxPhys() const
Returns the maximum physical value.
Definition ValueScaling.h:274
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:172
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:187
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:135
void setPhysicalScale(const std::type_info &t, const drain::ValueScaling &scaling)
Sets physical range (min, max) and scales storage type accordingly.
Definition ValueScaling.h:213
double inv(double y) const
Inverse scaling: given physically meaningful value y, returns the corresponding code value.
Definition ValueScaling.h:300
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:203
virtual const ValueScaling & getScaling() const
Get linear scaling.
Definition ValueScaling.h:146
double getScale() const
Returns the intensity scaling factor. See set setScale()
Definition ValueScaling.h:251
Definition DataSelector.cpp:1277