OTB  5.0.0
Orfeo Toolbox
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 "vnl/vnl_math.h"
23 
24 namespace otb
25 {
26 
27 namespace Function
28 {
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  }
55 
56  inline TOutput operator ()(const TInput& A) const
57  {
58  double x = static_cast<double>(A);
59  double px = CONST_PI * x;
60  double temp = 0.54 + 0.46 * vcl_cos(x * m_Factor);
61  return (x == 0.0) ? static_cast<TOutput>(temp) : static_cast<TOutput>(temp * vcl_sin(px) / px);
62  }
63 private:
64  // Equal to \f$ \frac{\pi}{m} \f$
65  double m_Factor;
66  unsigned int m_Radius;
67 };
68 
69 } //namespace Function
70 
86 template<class TInputImage, class TBoundaryCondition = itk::ConstantBoundaryCondition<TInputImage>, class TCoordRep =
87  double, class TInputInterpolator = double, class TOutputInterpolator = double>
90  typename Function::HammingWindowFunction<TInputInterpolator,
91  TOutputInterpolator>,
92  TBoundaryCondition,
93  TCoordRep>
94 {
95 public:
96 
99  typedef WindowedSincInterpolateImageFunctionBase<TInputImage,
100  typename Function::HammingWindowFunction<TInputInterpolator,
101  TOutputInterpolator>,
102  TBoundaryCondition,
103  TCoordRep>
107 
110 
112  itkNewMacro(Self);
113 
117 
119  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
120 
123  typedef typename Superclass::SizeType SizeType;
124  typedef typename Superclass::RealType RealType;
125  typedef typename Superclass::IteratorType IteratorType;
127 
128 protected:
131  void PrintSelf(std::ostream& os, itk::Indent indent) const
132  {
133  Superclass::PrintSelf(os, indent);
134  }
135 
136 private:
137  WindowedSincInterpolateImageHammingFunction(const Self &); //purposely not implemented
138  void operator =(const Self&); //purposely not implemented
139 };
140 
141 } // end namespace otb
142 
143 #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
InputImageType::IndexType IndexType
TInputImage InputImageType