Orfeo ToolBox  4.2
Orfeo ToolBox is not a black box
otbWindowedSincInterpolateImageHammingFunction.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 __otbWindowedSincInterpolateImageHammingFunction_h
19 #define __otbWindowedSincInterpolateImageHammingFunction_h
20 
22 #include "itkSize.h"
23 #include "otbMath.h"
24 #include "vnl/vnl_math.h"
25 
26 namespace otb
27 {
28 
29 namespace Function
30 {
37 template<class TInput = double, class TOutput = double>
39 {
40 public:
41  void SetRadius(unsigned int radius)
42  {
43  m_Radius = radius;
44  m_Factor = CONST_PI / static_cast<double>(radius);
45  }
46  unsigned int GetRadius() const
47  {
48  return m_Radius;
49  }
50  double GetFactor()
51  {
52  return m_Factor;
53  }
54 
55  inline TOutput operator ()(const TInput& A) const
56  {
57  double x = static_cast<double>(A);
58  double px = CONST_PI * x;
59  double temp = 0.54 + 0.46 * vcl_cos(x * m_Factor);
60  return (x == 0.0) ? static_cast<TOutput>(temp) : static_cast<TOutput>(temp * vcl_sin(px) / px);
61  }
62 private:
63  // Equal to \f$ \frac{\pi}{m} \f$
64  double m_Factor;
65  unsigned int m_Radius;
66 };
67 
68 } //namespace Function
69 
83 template<class TInputImage, class TBoundaryCondition = itk::ConstantBoundaryCondition<TInputImage>, class TCoordRep =
84  double, class TInputInterpolator = double, class TOutputInterpolator = double>
87  typename Function::HammingWindowFunction<TInputInterpolator,
88  TOutputInterpolator>,
89  TBoundaryCondition,
90  TCoordRep>
91 {
92 public:
95  typedef WindowedSincInterpolateImageFunctionBase<TInputImage,
96  typename Function::HammingWindowFunction<TInputInterpolator,
97  TOutputInterpolator>,
98  TBoundaryCondition,
99  TCoordRep>
103 
106 
108  itkNewMacro(Self);
109 
113 
115  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
116 
119  typedef typename Superclass::SizeType SizeType;
120  typedef typename Superclass::RealType RealType;
123 
124 protected:
127  void PrintSelf(std::ostream& os, itk::Indent indent) const
128  {
129  Superclass::PrintSelf(os, indent);
130  }
131 
132 private:
133  WindowedSincInterpolateImageHammingFunction(const Self &); //purposely not implemented
134  void operator =(const Self&); //purposely not implemented
135 };
136 
137 } // end namespace otb
138 
139 #endif
const double CONST_PI
Definition: otbMath.h:45
Use the WindowedSincInterpolateImageFunctionBase with a Hamming Function.
WindowedSincInterpolateImageFunctionBase< TInputImage, typename Function::HammingWindowFunction< TInputInterpolator, TOutputInterpolator >, TBoundaryCondition, TCoordRep > Superclass