GDCM 2.2.1

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

gdcmRescaler.h
Go to the documentation of this file.
1 /*=========================================================================
2
3 Program: GDCM (Grassroots DICOM). A DICOM library
4
5 Copyright (c) 2006-2011 Mathieu Malaterre
6 All rights reserved.
7 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notice for more information.
12
13 =========================================================================*/
14 #ifndef GDCMRESCALER_H
15 #define GDCMRESCALER_H
16
17 #include "gdcmTypes.h"
18 #include "gdcmPixelFormat.h"
19
20 namespace gdcm
21 {
22
68 class GDCM_EXPORT Rescaler
69 {
70 public:
71 Rescaler():Intercept(0),Slope(1),PF(PixelFormat::UNKNOWN),TargetScalarType(PixelFormat::UNKNOWN), ScalarRangeMin(0), ScalarRangeMax(0), UseTargetPixelType(false) {}
72 ~Rescaler() {}
73
75 bool Rescale(char *out, const char *in, size_t n);
76
78 bool InverseRescale(char *out, const char *in, size_t n);
79
81 void SetIntercept(double i) { Intercept = i; }
82 double GetIntercept() const { return Intercept; }
83
85 void SetSlope(double s) { Slope = s; }
86 double GetSlope() const { return Slope; }
87
92 void SetTargetPixelType( PixelFormat const & targetst );
93
95 void SetUseTargetPixelType(bool b);
96
98 void SetPixelFormat(PixelFormat const & pf) { PF = pf; }
99
102 PixelFormat::ScalarType ComputeInterceptSlopePixelType();
103
106 void SetMinMaxForPixelType(double min, double max)
107 {
108 ScalarRangeMin = min;
109 ScalarRangeMax = max;
110 }
111
114 PixelFormat ComputePixelTypeFromMinMax();
115
116 protected:
117 template <typename TIn>
118 void RescaleFunctionIntoBestFit(char *out, const TIn *in, size_t n);
119 template <typename TIn>
120 void InverseRescaleFunctionIntoBestFit(char *out, const TIn *in, size_t n);
121
122 private:
123 double Intercept; // 0028,1052
124 double Slope; // 0028,1053
125 PixelFormat PF;
126 PixelFormat::ScalarType TargetScalarType;
127 double ScalarRangeMin;
128 double ScalarRangeMax;
129 bool UseTargetPixelType;
130 };
131
132 } // end namespace gdcm
133
134 #endif //GDCMRESCALER_H