OTB  10.0.0
Orfeo Toolbox
otbWindowedSincInterpolateImageBlackmanFunction.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 
122  typedef typename Superclass::InputImageType InputImageType;
123  typedef typename Superclass::OutputType OutputType;
124 
126  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
127 
129  typedef typename Superclass::IndexType IndexType;
130  typedef typename Superclass::SizeType SizeType;
131  typedef typename Superclass::RealType RealType;
132  typedef typename Superclass::IteratorType IteratorType;
133  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
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:
147  void operator=(const Self&) = delete;
148 };
149 
150 } // end namespace otb
151 
152 #endif
Generic interpolation of an otb::Image.
Use the WindowedSincInterpolateImageFunctionBase with a Blackman Function.
WindowedSincInterpolateImageBlackmanFunction(const Self &)=delete
void PrintSelf(std::ostream &os, itk::Indent indent) const override
WindowedSincInterpolateImageFunctionBase< TInputImage, typename Function::BlackmanWindowFunction< TInputInterpolator, TOutputInterpolator >, TBoundaryCondition, TCoordRep > Superclass
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
constexpr double CONST_PI
Definition: otbMath.h:49