OTB  9.0.0
Orfeo Toolbox
otbWindowedSincInterpolateImageBlackmanFunction.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 otbWindowedSincInterpolateImageBlackmanFunction_h
22 #define otbWindowedSincInterpolateImageBlackmanFunction_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_Factor1 = CONST_PI / static_cast<double>(radius);
51  m_Factor2 = 2.0 * CONST_PI / static_cast<double>(radius);
52  }
53  unsigned int GetRadius() const
54  {
55  return m_Radius;
56  }
57  double GetFactor1()
58  {
59  return m_Factor1;
60  }
61  double GetFactor2()
62  {
63  return m_Factor2;
64  }
66 
67  inline TOutput operator()(const TInput& A) const
68  {
69  double x = static_cast<double>(A);
70  double px = CONST_PI * x;
71  double temp = 0.42 + 0.5 * std::cos(x * m_Factor1) + 0.08 * std::cos(x * m_Factor2);
72  return (x == 0.0) ? static_cast<TOutput>(temp) : static_cast<TOutput>(temp * std::sin(px) / px);
73  }
74 
75 private:
76  unsigned int m_Radius;
77  // Equal to \f$ \frac{\pi}{m} \f$
78  double m_Factor1;
79  // Equal to \f$ \frac{2 \pi}{m} \f$
80  double m_Factor2;
81 };
82 } // namespace Function
83 
99 template <class TInputImage, class TBoundaryCondition = itk::ConstantBoundaryCondition<TInputImage>, class TCoordRep = double,
100  class TInputInterpolator = double, class TOutputInterpolator = double>
102  : public WindowedSincInterpolateImageFunctionBase<TInputImage, typename Function::BlackmanWindowFunction<TInputInterpolator, TOutputInterpolator>,
103  TBoundaryCondition, TCoordRep>
104 {
105 public:
106 
110  TBoundaryCondition, TCoordRep>
112  typedef itk::SmartPointer<Self> Pointer;
113  typedef itk::SmartPointer<const Self> ConstPointer;
114 
117 
119  itkNewMacro(Self);
120 
124 
126  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
127 
130  typedef typename Superclass::SizeType SizeType;
131  typedef typename Superclass::RealType RealType;
134 
135 protected:
138  {
139  }
140  void PrintSelf(std::ostream& os, itk::Indent indent) const override
141  {
142  Superclass::PrintSelf(os, indent);
143  }
144 
145 private:
146  WindowedSincInterpolateImageBlackmanFunction(const Self&) = delete;
147  void operator=(const Self&) = delete;
148 };
149 
150 } // end namespace otb
151 
152 #endif
otb::Function::BlackmanWindowFunction
Window function for sinc interpolation.
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:41
otb::WindowedSincInterpolateImageBlackmanFunction::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:133
otb::WindowedSincInterpolateImageBlackmanFunction::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:112
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::WindowedSincInterpolateImageBlackmanFunction::OutputType
Superclass::OutputType OutputType
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:123
otb::Function::BlackmanWindowFunction::SetRadius
void SetRadius(unsigned int radius)
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:47
otb::WindowedSincInterpolateImageFunctionBase::SizeType
Superclass::SizeType SizeType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:165
otb::WindowedSincInterpolateImageFunctionBase::RealType
Superclass::RealType RealType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:166
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Function::BlackmanWindowFunction::GetFactor1
double GetFactor1()
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:57
otb::WindowedSincInterpolateImageBlackmanFunction::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:140
otb::Function::BlackmanWindowFunction::GetFactor2
double GetFactor2()
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:61
otb::WindowedSincInterpolateImageBlackmanFunction::RealType
Superclass::RealType RealType
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:131
otb::WindowedSincInterpolateImageBlackmanFunction::IndexType
Superclass::IndexType IndexType
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:129
otb::WindowedSincInterpolateImageFunctionBase::OutputType
Superclass::OutputType OutputType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:158
otb::WindowedSincInterpolateImageFunctionBase::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:168
otb::WindowedSincInterpolateImageBlackmanFunction::Self
WindowedSincInterpolateImageBlackmanFunction Self
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:108
otb::Function::BlackmanWindowFunction::m_Radius
unsigned int m_Radius
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:76
otb::WindowedSincInterpolateImageBlackmanFunction::InputImageType
Superclass::InputImageType InputImageType
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:119
otb::WindowedSincInterpolateImageFunctionBase::IteratorType
Superclass::IteratorType IteratorType
Definition: otbWindowedSincInterpolateImageFunctionBase.h:167
otb::Function::BlackmanWindowFunction::GetRadius
unsigned int GetRadius() const
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:53
otb::Function::BlackmanWindowFunction::m_Factor1
double m_Factor1
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:78
otb::Function::BlackmanWindowFunction::BlackmanWindowFunction
BlackmanWindowFunction()
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:44
otb::Function::BlackmanWindowFunction::operator()
TOutput operator()(const TInput &A) const
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:67
otb::WindowedSincInterpolateImageBlackmanFunction::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:113
otb::WindowedSincInterpolateImageBlackmanFunction
Use the WindowedSincInterpolateImageFunctionBase with a Blackman Function.
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:101
otb::WindowedSincInterpolateImageBlackmanFunction::Superclass
WindowedSincInterpolateImageFunctionBase< TInputImage, typename Function::BlackmanWindowFunction< TInputInterpolator, TOutputInterpolator >, TBoundaryCondition, TCoordRep > Superclass
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:111
otbWindowedSincInterpolateImageFunctionBase.h
otb::WindowedSincInterpolateImageFunctionBase
Use the windowed sinc function to interpolate.
Definition: otbWindowedSincInterpolateImageFunctionBase.h:140
otb::Function::BlackmanWindowFunction::m_Factor2
double m_Factor2
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:80
otb::WindowedSincInterpolateImageBlackmanFunction::WindowedSincInterpolateImageBlackmanFunction
WindowedSincInterpolateImageBlackmanFunction()
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:136
otb::WindowedSincInterpolateImageBlackmanFunction::SizeType
Superclass::SizeType SizeType
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:130
otb::WindowedSincInterpolateImageBlackmanFunction::IteratorType
Superclass::IteratorType IteratorType
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:132
otb::WindowedSincInterpolateImageBlackmanFunction::~WindowedSincInterpolateImageBlackmanFunction
~WindowedSincInterpolateImageBlackmanFunction() override
Definition: otbWindowedSincInterpolateImageBlackmanFunction.h:137