# 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-2009 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
    00043 class GDCM_EXPORT Rescaler
    00044 {
    00045 public:
    00046   Rescaler():Intercept(0),Slope(1),PF(PixelFormat::UNKNOWN) {}
    00047   ~Rescaler() {}
    00048
    00050   bool Rescale(char *out, const char *in, size_t n);
    00051
    00053   bool InverseRescale(char *out, const char *in, size_t n);
    00054
    00056   void SetIntercept(double i) { Intercept = i; }
    00057
    00059   void SetSlope(double s) { Slope = s; }
    00060
    00062   void SetPixelFormat(PixelFormat const & pf) { PF = pf; }
    00063
    00066   PixelFormat::ScalarType ComputeInterceptSlopePixelType();
    00067
    00070   void SetMinMaxForPixelType(double min, double max)
    00071     {
    00072     ScalarRangeMin = min;
    00073     ScalarRangeMax = max;
    00074     }
    00075
    00078   PixelFormat ComputePixelTypeFromMinMax();
    00079
    00080 protected:
    00081   template <typename TIn>
    00082     void RescaleFunctionIntoBestFit(char *out, const TIn *in, size_t n);
    00083   template <typename TIn>
    00084     void InverseRescaleFunctionIntoBestFit(char *out, const TIn *in, size_t n);
    00085
    00086 private:
    00087   double Intercept; // 0028,1052
    00088   double Slope;     // 0028,1053
    00089   PixelFormat PF;
    00090   double ScalarRangeMin;
    00091   double ScalarRangeMax;
    00092 };
    00093
    00094 } // end namespace gdcm
    00095
    00096 #endif //__gdcmRescaler_h