Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef GDCMRESCALER_H
00016 #define GDCMRESCALER_H
00017
00018 #include "gdcmTypes.h"
00019 #include "gdcmPixelFormat.h"
00020
00021 namespace gdcm
00022 {
00023
00061 class GDCM_EXPORT Rescaler
00062 {
00063 public:
00064 Rescaler():Intercept(0),Slope(1),PF(PixelFormat::UNKNOWN),TargetScalarType(PixelFormat::UNKNOWN), ScalarRangeMin(0), ScalarRangeMax(0), UseTargetPixelType(false) {}
00065 ~Rescaler() {}
00066
00068 bool Rescale(char *out, const char *in, size_t n);
00069
00071 bool InverseRescale(char *out, const char *in, size_t n);
00072
00074 void SetIntercept(double i) { Intercept = i; }
00075
00077 void SetSlope(double s) { Slope = s; }
00078
00083 void SetTargetPixelType( PixelFormat const & targetst );
00084
00086 void SetUseTargetPixelType(bool b);
00087
00089 void SetPixelFormat(PixelFormat const & pf) { PF = pf; }
00090
00093 PixelFormat::ScalarType ComputeInterceptSlopePixelType();
00094
00097 void SetMinMaxForPixelType(double min, double max)
00098 {
00099 ScalarRangeMin = min;
00100 ScalarRangeMax = max;
00101 }
00102
00105 PixelFormat ComputePixelTypeFromMinMax();
00106
00107 protected:
00108 template <typename TIn>
00109 void RescaleFunctionIntoBestFit(char *out, const TIn *in, size_t n);
00110 template <typename TIn>
00111 void InverseRescaleFunctionIntoBestFit(char *out, const TIn *in, size_t n);
00112
00113 private:
00114 double Intercept;
00115 double Slope;
00116 PixelFormat PF;
00117 PixelFormat::ScalarType TargetScalarType;
00118 double ScalarRangeMin;
00119 double ScalarRangeMax;
00120 bool UseTargetPixelType;
00121 };
00122
00123 }
00124
00125 #endif //GDCMRESCALER_H