OTB  6.7.0
Orfeo Toolbox
otbWindowedSincInterpolateImageLanczosFunction.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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 otbWindowedSincInterpolateImageLanczosFunction_h
22 #define otbWindowedSincInterpolateImageLanczosFunction_h
23 
25 #include "vnl/vnl_math.h"
26 
27 namespace otb
28 {
29 
30 namespace Function
31 {
42 template<class TInput = double, class TOutput = double>
44 {
45 public:
46  LanczosWindowFunction(): m_Radius(1), m_Factor(CONST_PI) {} // default factor is 1 at construction
47  void SetRadius(unsigned int radius)
48  {
49  m_Radius = radius;
50  m_Factor = CONST_PI / static_cast<double>(radius);
51  }
52  unsigned int GetRadius() const
53  {
54  return m_Radius;
55  }
56  double GetFactor()
57  {
58  return m_Factor;
59  }
61 
62  inline TOutput operator ()(const TInput& A) const
63  {
64  double x = static_cast<double>(A);
65  double px = CONST_PI * x;
66  double temp;
67  if (x == 0.0)
68  {
69  temp = 1.0;
70  }
71  else
72  {
73  double z = m_Factor * x;
74  temp = std::sin(z) / z;
75  }
76  return (x == 0.0) ? static_cast<TOutput>(temp) : static_cast<TOutput>(temp * std::sin(px) / px);
77  }
78 private:
79  unsigned int m_Radius;
80  // Equal to \f$ \frac{\pi}{m} \f$
81  double m_Factor;
82 };
83 } //namespace Function
84 
100 template<class TInputImage, class TBoundaryCondition = itk::ConstantBoundaryCondition<TInputImage>, class TCoordRep =
101  double, class TInputInterpolator = double, class TOutputInterpolator = double>
103  public WindowedSincInterpolateImageFunctionBase<TInputImage,
104  typename Function::LanczosWindowFunction<TInputInterpolator,
105  TOutputInterpolator>,
106  TBoundaryCondition,
107  TCoordRep>
108 {
109 public:
110 
113  typedef WindowedSincInterpolateImageFunctionBase<TInputImage,
114  typename Function::LanczosWindowFunction<TInputInterpolator,
115  TOutputInterpolator>,
116  TBoundaryCondition,
117  TCoordRep>
121 
124 
126  itkNewMacro(Self);
127 
131 
133  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
134 
137  typedef typename Superclass::SizeType SizeType;
138  typedef typename Superclass::RealType RealType;
139  typedef typename Superclass::IteratorType IteratorType;
141 
142 protected:
145  void PrintSelf(std::ostream& os, itk::Indent indent) const override
146  {
147  Superclass::PrintSelf(os, indent);
148  }
149 
150 private:
151  WindowedSincInterpolateImageLanczosFunction(const Self &) = delete;
152  void operator =(const Self&) = delete;
153 };
154 
155 } // end namespace otb
156 
157 #endif
itk::Size< Monteverdi_DIMENSION > SizeType
Definition: mvdTypes.h:137
Use the WindowedSincInterpolateImageFunctionBase with a Lanczos Function.
constexpr double CONST_PI
Definition: otbMath.h:48
void PrintSelf(std::ostream &os, itk::Indent indent) const override
WindowedSincInterpolateImageFunctionBase< TInputImage, typename Function::LanczosWindowFunction< TInputInterpolator, TOutputInterpolator >, TBoundaryCondition, TCoordRep > Superclass
InputImageType::IndexType IndexType
Monteverdi_FLOATING_TYPE RealType
Definition: mvdTypes.h:84
TInputImage InputImageType
Window function for sinc interpolation. Note: Paper referenced in WindowedSincInterpolateImageFuncti...