OTB  9.0.0
Orfeo Toolbox
otbWindowedSincInterpolateImageLanczosFunction.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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:
47  {
48  } // default factor is 1 at construction
49  void SetRadius(unsigned int radius)
50  {
51  m_Radius = radius;
52  m_Factor = CONST_PI / static_cast<double>(radius);
53  }
54  unsigned int GetRadius() const
55  {
56  return m_Radius;
57  }
58  double GetFactor()
59  {
60  return m_Factor;
61  }
63 
64  inline TOutput operator()(const TInput& A) const
65  {
66  double x = static_cast<double>(A);
67  double px = CONST_PI * x;
68  double temp;
69  if (x == 0.0)
70  {
71  temp = 1.0;
72  }
73  else
74  {
75  double z = m_Factor * x;
76  temp = std::sin(z) / z;
77  }
78  return (x == 0.0) ? static_cast<TOutput>(temp) : static_cast<TOutput>(temp * std::sin(px) / px);
79  }
80 
81 private:
82  unsigned int m_Radius;
83  // Equal to \f$ \frac{\pi}{m} \f$
84  double m_Factor;
85 };
86 } // namespace Function
87 
103 template <class TInputImage, class TBoundaryCondition = itk::ConstantBoundaryCondition<TInputImage>, class TCoordRep = double,
104  class TInputInterpolator = double, class TOutputInterpolator = double>
106  : public WindowedSincInterpolateImageFunctionBase<TInputImage, typename Function::LanczosWindowFunction<TInputInterpolator, TOutputInterpolator>,
107  TBoundaryCondition, TCoordRep>
108 {
109 public:
110 
114  TBoundaryCondition, TCoordRep>
116  typedef itk::SmartPointer<Self> Pointer;
117  typedef itk::SmartPointer<const Self> ConstPointer;
118 
121 
123  itkNewMacro(Self);
124 
128 
130  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
131 
134  typedef typename Superclass::SizeType SizeType;
135  typedef typename Superclass::RealType RealType;
138 
139 protected:
142  {
143  }
144  void PrintSelf(std::ostream& os, itk::Indent indent) const override
145  {
146  Superclass::PrintSelf(os, indent);
147  }
148 
149 private:
150  WindowedSincInterpolateImageLanczosFunction(const Self&) = delete;
151  void operator=(const Self&) = delete;
152 };
153 
154 } // end namespace otb
155 
156 #endif
otb::WindowedSincInterpolateImageLanczosFunction::~WindowedSincInterpolateImageLanczosFunction
~WindowedSincInterpolateImageLanczosFunction() override
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:141
otb::WindowedSincInterpolateImageFunctionBase::InputImageType
Superclass::InputImageType InputImageType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:154
otb::CONST_PI
constexpr double CONST_PI
Definition: otbMath.h:49
otb::WindowedSincInterpolateImageFunctionBase::IndexType
Superclass::IndexType IndexType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:164
otb::WindowedSincInterpolateImageLanczosFunction::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:144
otb::WindowedSincInterpolateImageFunctionBase::SizeType
Superclass::SizeType SizeType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:165
otb::WindowedSincInterpolateImageFunctionBase::RealType
Superclass::RealType RealType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:166
otb::Function::LanczosWindowFunction::m_Factor
double m_Factor
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:84
otb::WindowedSincInterpolateImageLanczosFunction::IteratorType
Superclass::IteratorType IteratorType
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:136
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Function::LanczosWindowFunction::operator()
TOutput operator()(const TInput &A) const
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:64
otb::WindowedSincInterpolateImageLanczosFunction::SizeType
Superclass::SizeType SizeType
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:134
otb::WindowedSincInterpolateImageLanczosFunction::RealType
Superclass::RealType RealType
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:135
otb::WindowedSincInterpolateImageLanczosFunction::InputImageType
Superclass::InputImageType InputImageType
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:123
otb::WindowedSincInterpolateImageFunctionBase::OutputType
Superclass::OutputType OutputType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:158
otb::WindowedSincInterpolateImageFunctionBase::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:168
otb::WindowedSincInterpolateImageLanczosFunction
Use the WindowedSincInterpolateImageFunctionBase with a Lanczos Function.
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:105
otb::WindowedSincInterpolateImageLanczosFunction::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:116
otb::WindowedSincInterpolateImageFunctionBase::IteratorType
Superclass::IteratorType IteratorType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:167
otb::WindowedSincInterpolateImageLanczosFunction::IndexType
Superclass::IndexType IndexType
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:133
otb::WindowedSincInterpolateImageLanczosFunction::Superclass
WindowedSincInterpolateImageFunctionBase< TInputImage, typename Function::LanczosWindowFunction< TInputInterpolator, TOutputInterpolator >, TBoundaryCondition, TCoordRep > Superclass
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:115
otb::Function::LanczosWindowFunction::GetFactor
double GetFactor()
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:58
otb::Function::LanczosWindowFunction::LanczosWindowFunction
LanczosWindowFunction()
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:46
otb::Function::LanczosWindowFunction
Window function for sinc interpolation.
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:43
otb::Function::LanczosWindowFunction::GetRadius
unsigned int GetRadius() const
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:54
otb::WindowedSincInterpolateImageLanczosFunction::OutputType
Superclass::OutputType OutputType
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:127
otb::WindowedSincInterpolateImageLanczosFunction::WindowedSincInterpolateImageLanczosFunction
WindowedSincInterpolateImageLanczosFunction()
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:140
otb::Function::LanczosWindowFunction::m_Radius
unsigned int m_Radius
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:82
otb::WindowedSincInterpolateImageLanczosFunction::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:137
otb::Function::LanczosWindowFunction::SetRadius
void SetRadius(unsigned int radius)
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:49
otb::WindowedSincInterpolateImageLanczosFunction::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:117
otb::WindowedSincInterpolateImageLanczosFunction::Self
WindowedSincInterpolateImageLanczosFunction Self
Definition: otbWindowedSincInterpolateImageLanczosFunction.h:112
otbWindowedSincInterpolateImageFunctionBase.h
otb::WindowedSincInterpolateImageFunctionBase
Use the windowed sinc function to interpolate.
Definition: otbWindowedSincInterpolateImageFunctionBase.h:140