OTB  9.0.0
Orfeo Toolbox
otbWindowedSincInterpolateImageHammingFunction.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 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:
45  {
46  } // default radius 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 = 0.54 + 0.46 * std::cos(x * m_Factor);
67  return (x == 0.0) ? static_cast<TOutput>(temp) : static_cast<TOutput>(temp * std::sin(px) / px);
68  }
69 
70 private:
71  unsigned int m_Radius;
72  // Equal to \f$ \frac{\pi}{m} \f$
73  double m_Factor;
74 };
75 
76 } // namespace Function
77 
93 template <class TInputImage, class TBoundaryCondition = itk::ConstantBoundaryCondition<TInputImage>, class TCoordRep = double,
94  class TInputInterpolator = double, class TOutputInterpolator = double>
96  : public WindowedSincInterpolateImageFunctionBase<TInputImage, typename Function::HammingWindowFunction<TInputInterpolator, TOutputInterpolator>,
97  TBoundaryCondition, TCoordRep>
98 {
99 public:
100 
104  TBoundaryCondition, TCoordRep>
106  typedef itk::SmartPointer<Self> Pointer;
107  typedef itk::SmartPointer<const Self> ConstPointer;
108 
111 
113  itkNewMacro(Self);
114 
118 
120  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
121 
124  typedef typename Superclass::SizeType SizeType;
125  typedef typename Superclass::RealType RealType;
128 
129 protected:
132  {
133  }
134  void PrintSelf(std::ostream& os, itk::Indent indent) const override
135  {
136  Superclass::PrintSelf(os, indent);
137  }
138 
139 private:
140  WindowedSincInterpolateImageHammingFunction(const Self&) = delete;
141  void operator=(const Self&) = delete;
142 };
143 
144 } // end namespace otb
145 
146 #endif
otb::Function::HammingWindowFunction::GetRadius
unsigned int GetRadius() const
Definition: otbWindowedSincInterpolateImageHammingFunction.h:52
otb::WindowedSincInterpolateImageHammingFunction::Self
WindowedSincInterpolateImageHammingFunction Self
Definition: otbWindowedSincInterpolateImageHammingFunction.h:102
otb::WindowedSincInterpolateImageFunctionBase::InputImageType
Superclass::InputImageType InputImageType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:154
otb::CONST_PI
constexpr double CONST_PI
Definition: otbMath.h:49
otb::WindowedSincInterpolateImageHammingFunction::InputImageType
Superclass::InputImageType InputImageType
Definition: otbWindowedSincInterpolateImageHammingFunction.h:113
otb::WindowedSincInterpolateImageFunctionBase::IndexType
Superclass::IndexType IndexType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:164
otb::WindowedSincInterpolateImageHammingFunction::Superclass
WindowedSincInterpolateImageFunctionBase< TInputImage, typename Function::HammingWindowFunction< TInputInterpolator, TOutputInterpolator >, TBoundaryCondition, TCoordRep > Superclass
Definition: otbWindowedSincInterpolateImageHammingFunction.h:105
otb::Function::HammingWindowFunction::operator()
TOutput operator()(const TInput &A) const
Definition: otbWindowedSincInterpolateImageHammingFunction.h:62
otb::WindowedSincInterpolateImageFunctionBase::SizeType
Superclass::SizeType SizeType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:165
otb::Function::HammingWindowFunction::SetRadius
void SetRadius(unsigned int radius)
Definition: otbWindowedSincInterpolateImageHammingFunction.h:47
otb::WindowedSincInterpolateImageFunctionBase::RealType
Superclass::RealType RealType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:166
otb::WindowedSincInterpolateImageHammingFunction::RealType
Superclass::RealType RealType
Definition: otbWindowedSincInterpolateImageHammingFunction.h:125
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::WindowedSincInterpolateImageHammingFunction::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbWindowedSincInterpolateImageHammingFunction.h:127
otb::WindowedSincInterpolateImageFunctionBase::OutputType
Superclass::OutputType OutputType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:158
otb::WindowedSincInterpolateImageHammingFunction::SizeType
Superclass::SizeType SizeType
Definition: otbWindowedSincInterpolateImageHammingFunction.h:124
otb::WindowedSincInterpolateImageFunctionBase::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:168
otb::WindowedSincInterpolateImageFunctionBase::IteratorType
Superclass::IteratorType IteratorType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:167
otb::WindowedSincInterpolateImageHammingFunction::~WindowedSincInterpolateImageHammingFunction
~WindowedSincInterpolateImageHammingFunction() override
Definition: otbWindowedSincInterpolateImageHammingFunction.h:131
otb::WindowedSincInterpolateImageHammingFunction
Use the WindowedSincInterpolateImageFunctionBase with a Hamming Function.
Definition: otbWindowedSincInterpolateImageHammingFunction.h:95
otb::Function::HammingWindowFunction::GetFactor
double GetFactor()
Definition: otbWindowedSincInterpolateImageHammingFunction.h:56
otb::WindowedSincInterpolateImageHammingFunction::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbWindowedSincInterpolateImageHammingFunction.h:107
otb::Function::HammingWindowFunction::m_Radius
unsigned int m_Radius
Definition: otbWindowedSincInterpolateImageHammingFunction.h:71
otb::WindowedSincInterpolateImageHammingFunction::OutputType
Superclass::OutputType OutputType
Definition: otbWindowedSincInterpolateImageHammingFunction.h:117
otb::Function::HammingWindowFunction::m_Factor
double m_Factor
Definition: otbWindowedSincInterpolateImageHammingFunction.h:73
otb::Function::HammingWindowFunction
Window function for sinc interpolation.
Definition: otbWindowedSincInterpolateImageHammingFunction.h:41
otb::WindowedSincInterpolateImageHammingFunction::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbWindowedSincInterpolateImageHammingFunction.h:106
otb::WindowedSincInterpolateImageHammingFunction::IndexType
Superclass::IndexType IndexType
Definition: otbWindowedSincInterpolateImageHammingFunction.h:123
otb::WindowedSincInterpolateImageHammingFunction::WindowedSincInterpolateImageHammingFunction
WindowedSincInterpolateImageHammingFunction()
Definition: otbWindowedSincInterpolateImageHammingFunction.h:130
otb::WindowedSincInterpolateImageHammingFunction::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbWindowedSincInterpolateImageHammingFunction.h:134
otbWindowedSincInterpolateImageFunctionBase.h
otb::WindowedSincInterpolateImageFunctionBase
Use the windowed sinc function to interpolate.
Definition: otbWindowedSincInterpolateImageFunctionBase.h:140
otb::Function::HammingWindowFunction::HammingWindowFunction
HammingWindowFunction()
Definition: otbWindowedSincInterpolateImageHammingFunction.h:44
otb::WindowedSincInterpolateImageHammingFunction::IteratorType
Superclass::IteratorType IteratorType
Definition: otbWindowedSincInterpolateImageHammingFunction.h:126