gdcmRescaler.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program: GDCM (Grassroots DICOM). A DICOM library
00004   Module:  $URL$
00005 
00006   Copyright (c) 2006-2010 Mathieu Malaterre
00007   All rights reserved.
00008   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
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; // 0028,1052
00115   double Slope;     // 0028,1053
00116   PixelFormat PF;
00117   PixelFormat::ScalarType TargetScalarType;
00118   double ScalarRangeMin;
00119   double ScalarRangeMax;
00120   bool UseTargetPixelType;
00121 };
00122 
00123 } // end namespace gdcm
00124 
00125 #endif //GDCMRESCALER_H

Generated on Sat Dec 4 2010 08:58:46 for GDCM by doxygen 1.7.2
SourceForge.net Logo