Orfeo Toolbox  3.16
otbImageWidgetTransferFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbImageWidgetTransferFunction_h
19 #define __otbImageWidgetTransferFunction_h
20 
21 #include "vcl_deprecated_header.h"
22 
23 #include "itkProcessObject.h"
24 #include "itkMacro.h"
25 #include "otbMath.h"
26 
27 namespace otb
28 {
36 template <class TPixel>
38  : public itk::Object
39 {
40 public:
46 
48  itkTypeMacro(ImageWidgetTransferFunction, Object);
49 
51  typedef TPixel PixelType;
52 
54  itkSetMacro(LowerBound, PixelType);
55  itkGetMacro(LowerBound, PixelType);
56  itkSetMacro(UpperBound, PixelType);
57  itkGetMacro(UpperBound, PixelType);
58 
65  virtual unsigned char Map(PixelType)
66  {
67  return 0;
68  }
69 
70 protected:
73  {
74  m_LowerBound = 0;
75  m_UpperBound = 255;
76  }
80  virtual void PrintSelf(std::ostream& os, itk::Indent indent) const
81  {
82  Superclass::PrintSelf(os, indent);
83  os << indent << "Lower bound: " << m_LowerBound << std::endl;
84  os << indent << "Upper bound: " << m_UpperBound << std::endl;
85  }
86 
87 private:
88  ImageWidgetTransferFunction(const Self &); //purposely not implemented
89  void operator =(const Self&); //purposely not implemented
90 
95 };
96 
100 template <class TPixel>
102  : public ImageWidgetTransferFunction<TPixel>
103 {
104 public:
110 
112  itkNewMacro(Self);
113 
116 
118  typedef TPixel PixelType;
119 
120  virtual unsigned char Map(PixelType value)
121  {
122  if (value < this->GetLowerBound())
123  {
124  return 0;
125  }
126  else if (value > this->GetUpperBound())
127  {
128  return 255;
129  }
130  else
131  {
132  return static_cast<unsigned char>(vcl_floor(255. *
133  (value -
134  this->GetLowerBound()) /
135  (this->GetUpperBound() - this->GetLowerBound()) + 0.5));
136  }
137 
138  }
139 protected:
143 private:
144  ImageWidgetAffineTransferFunction(const Self &); //purposely not implemented
145  void operator =(const Self&); //purposely not implemented
146 };
147 
151 template <class TPixel>
153  : public ImageWidgetTransferFunction<TPixel>
154 {
155 public:
161 
163  itkNewMacro(Self);
164 
167 
169  typedef TPixel PixelType;
170 
171  virtual unsigned char Map(PixelType value)
172  {
173  if (value < this->GetLowerBound())
174  {
175  return 0;
176  }
177  else if (value > this->GetUpperBound())
178  {
179  return 255;
180  }
181  else
182  {
183  double b = vcl_sqrt(static_cast<double>(this->GetLowerBound()));
184  double a = 255. / (vcl_sqrt(static_cast<double>(this->GetUpperBound())) - b);
185  return static_cast<unsigned char>(vcl_floor(a * (vcl_sqrt(static_cast<double>(value)) - b) + 0.5));
186  }
187 
188  }
189 protected:
193 private:
194  ImageWidgetSquareRootTransferFunction(const Self &); //purposely not implemented
195  void operator =(const Self&); //purposely not implemented
196 };
197 
201 template <class TPixel>
203  : public ImageWidgetTransferFunction<TPixel>
204 {
205 public:
211 
213  itkNewMacro(Self);
214 
217 
219  typedef TPixel PixelType;
220 
221  virtual unsigned char Map(PixelType value)
222  {
223  if (value < this->GetLowerBound())
224  {
225  return 0;
226  }
227  else if (value > this->GetUpperBound())
228  {
229  return 255;
230  }
231  else
232  {
233  double b = vcl_log(1. + static_cast<double>(this->GetLowerBound()));
234  double a = 255. / (vcl_log(1. + static_cast<double>(this->GetUpperBound())) - b);
235  return static_cast<unsigned char>(vcl_floor(a * (vcl_log(1. + static_cast<double>(value)) - b) + 0.5));
236  }
237 
238  }
239 protected:
243 private:
244  ImageWidgetLogTransferFunction(const Self &); //purposely not implemented
245  void operator =(const Self&); //purposely not implemented
246 };
247 
251 template <class TPixel>
253  : public ImageWidgetTransferFunction<TPixel>
254 {
255 public:
261 
263  itkNewMacro(Self);
264 
267 
269  typedef TPixel PixelType;
270 
271  virtual unsigned char Map(PixelType value)
272  {
273  if (value < this->GetLowerBound())
274  {
275  return 0;
276  }
277  else if (value > this->GetUpperBound())
278  {
279  return 255;
280  }
281  else
282  {
283  double b = vcl_pow(static_cast<double>(this->GetLowerBound()), 2);
284  double a = 255. / (vcl_pow(static_cast<double>(this->GetUpperBound()), 2) - b);
285  return static_cast<unsigned char>(vcl_floor(a * (vcl_pow(static_cast<double>(value), 2) - b) + 0.5));
286  }
287 
288  }
289 protected:
293 private:
294  ImageWidgetSquareTransferFunction(const Self &); //purposely not implemented
295  void operator =(const Self&); //purposely not implemented
296 };
297 } // End namespace otb
298 
299 #endif

Generated at Sun Feb 3 2013 00:31:30 for Orfeo Toolbox with doxygen 1.8.1.1