OTB  6.1.0
Orfeo Toolbox
otbWindowedSincInterpolateImageHammingFunction.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbWindowedSincInterpolateImageHammingFunction_h
22 #define otbWindowedSincInterpolateImageHammingFunction_h
23 
25 #include "vnl/vnl_math.h"
26 
27 namespace otb
28 {
29 
30 namespace Function
31 {
40 template<class TInput = double, class TOutput = double>
42 {
43 public:
44  void SetRadius(unsigned int radius)
45  {
46  m_Radius = radius;
47  m_Factor = CONST_PI / static_cast<double>(radius);
48  }
49  unsigned int GetRadius() const
50  {
51  return m_Radius;
52  }
53  double GetFactor()
54  {
55  return m_Factor;
56  }
58 
59  inline TOutput operator ()(const TInput& A) const
60  {
61  double x = static_cast<double>(A);
62  double px = CONST_PI * x;
63  double temp = 0.54 + 0.46 * vcl_cos(x * m_Factor);
64  return (x == 0.0) ? static_cast<TOutput>(temp) : static_cast<TOutput>(temp * vcl_sin(px) / px);
65  }
66 private:
67  // Equal to \f$ \frac{\pi}{m} \f$
68  double m_Factor;
69  unsigned int m_Radius;
70 };
71 
72 } //namespace Function
73 
89 template<class TInputImage, class TBoundaryCondition = itk::ConstantBoundaryCondition<TInputImage>, class TCoordRep =
90  double, class TInputInterpolator = double, class TOutputInterpolator = double>
93  typename Function::HammingWindowFunction<TInputInterpolator,
94  TOutputInterpolator>,
95  TBoundaryCondition,
96  TCoordRep>
97 {
98 public:
99 
102  typedef WindowedSincInterpolateImageFunctionBase<TInputImage,
103  typename Function::HammingWindowFunction<TInputInterpolator,
104  TOutputInterpolator>,
105  TBoundaryCondition,
106  TCoordRep>
110 
113 
115  itkNewMacro(Self);
116 
120 
122  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
123 
126  typedef typename Superclass::SizeType SizeType;
127  typedef typename Superclass::RealType RealType;
128  typedef typename Superclass::IteratorType IteratorType;
130 
131 protected:
134  void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE
135  {
136  Superclass::PrintSelf(os, indent);
137  }
138 
139 private:
140  WindowedSincInterpolateImageHammingFunction(const Self &); //purposely not implemented
141  void operator =(const Self&); //purposely not implemented
142 };
143 
144 } // end namespace otb
145 
146 #endif
const double CONST_PI
Definition: otbMath.h:48
itk::Size< Monteverdi_DIMENSION > SizeType
Definition: mvdTypes.h:146
Use the WindowedSincInterpolateImageFunctionBase with a Hamming Function.
void PrintSelf(std::ostream &os, itk::Indent indent) const ITK_OVERRIDE
WindowedSincInterpolateImageFunctionBase< TInputImage, typename Function::HammingWindowFunction< TInputInterpolator, TOutputInterpolator >, TBoundaryCondition, TCoordRep > Superclass
InputImageType::IndexType IndexType
Monteverdi_FLOATING_TYPE RealType
Definition: mvdTypes.h:93
TInputImage InputImageType