Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef GDCMRESCALER_H
00015 #define GDCMRESCALER_H
00016
00017 #include "gdcmTypes.h"
00018 #include "gdcmPixelFormat.h"
00019
00020 namespace gdcm
00021 {
00022
00068 class GDCM_EXPORT Rescaler
00069 {
00070 public:
00071 Rescaler():Intercept(0),Slope(1),PF(PixelFormat::UNKNOWN),TargetScalarType(PixelFormat::UNKNOWN), ScalarRangeMin(0), ScalarRangeMax(0), UseTargetPixelType(false) {}
00072 ~Rescaler() {}
00073
00075 bool Rescale(char *out, const char *in, size_t n);
00076
00078 bool InverseRescale(char *out, const char *in, size_t n);
00079
00081 void SetIntercept(double i) { Intercept = i; }
00082 double GetIntercept() const { return Intercept; }
00083
00085 void SetSlope(double s) { Slope = s; }
00086 double GetSlope() const { return Slope; }
00087
00092 void SetTargetPixelType( PixelFormat const & targetst );
00093
00095 void SetUseTargetPixelType(bool b);
00096
00098 void SetPixelFormat(PixelFormat const & pf) { PF = pf; }
00099
00102 PixelFormat::ScalarType ComputeInterceptSlopePixelType();
00103
00106 void SetMinMaxForPixelType(double min, double max)
00107 {
00108 ScalarRangeMin = min;
00109 ScalarRangeMax = max;
00110 }
00111
00114 PixelFormat ComputePixelTypeFromMinMax();
00115
00116 protected:
00117 template <typename TIn>
00118 void RescaleFunctionIntoBestFit(char *out, const TIn *in, size_t n);
00119 template <typename TIn>
00120 void InverseRescaleFunctionIntoBestFit(char *out, const TIn *in, size_t n);
00121
00122 private:
00123 double Intercept;
00124 double Slope;
00125 PixelFormat PF;
00126 PixelFormat::ScalarType TargetScalarType;
00127 double ScalarRangeMin;
00128 double ScalarRangeMax;
00129 bool UseTargetPixelType;
00130 };
00131
00132 }
00133
00134 #endif //GDCMRESCALER_H