GDCM
2.2.0
|
00001 /*========================================================================= 00002 00003 Program: GDCM (Grassroots DICOM). A DICOM library 00004 00005 Copyright (c) 2006-2011 Mathieu Malaterre 00006 All rights reserved. 00007 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details. 00008 00009 This software is distributed WITHOUT ANY WARRANTY; without even 00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00011 PURPOSE. See the above copyright notice for more information. 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; // 0028,1052 00124 double Slope; // 0028,1053 00125 PixelFormat PF; 00126 PixelFormat::ScalarType TargetScalarType; 00127 double ScalarRangeMin; 00128 double ScalarRangeMax; 00129 bool UseTargetPixelType; 00130 }; 00131 00132 } // end namespace gdcm 00133 00134 #endif //GDCMRESCALER_H