OTB  6.7.0
Orfeo Toolbox
otbWindowedSincInterpolateImageBlackmanFunction.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 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:
44  BlackmanWindowFunction(): m_Radius(1), m_Factor1(CONST_PI), m_Factor2(2.0 * CONST_PI) {} // default radius is 1 at construction
45  void SetRadius(unsigned int radius)
46  {
47  m_Radius = radius;
48  m_Factor1 = CONST_PI / static_cast<double>(radius);
49  m_Factor2 = 2.0 * CONST_PI / static_cast<double>(radius);
50  }
51  unsigned int GetRadius() const
52  {
53  return m_Radius;
54  }
55  double GetFactor1()
56  {
57  return m_Factor1;
58  }
59  double GetFactor2()
60  {
61  return m_Factor2;
62  }
64 
65  inline TOutput operator ()(const TInput& A) const
66  {
67  double x = static_cast<double>(A);
68  double px = CONST_PI * x;
69  double temp = 0.42 + 0.5 * std::cos(x * m_Factor1) + 0.08 * std::cos(x * m_Factor2);
70  return (x == 0.0) ? static_cast<TOutput>(temp) : static_cast<TOutput>(temp * std::sin(px) / px);
71  }
72 private:
73  unsigned int m_Radius;
74  // Equal to \f$ \frac{\pi}{m} \f$
75  double m_Factor1;
76  // Equal to \f$ \frac{2 \pi}{m} \f$
77  double m_Factor2;
78 };
79 } //namespace Function
80 
96 template<class TInputImage, class TBoundaryCondition = itk::ConstantBoundaryCondition<TInputImage>, class TCoordRep =
97  double, class TInputInterpolator = double, class TOutputInterpolator = double>
100  typename Function::BlackmanWindowFunction<TInputInterpolator, TOutputInterpolator>,
101  TBoundaryCondition,
102  TCoordRep>
103 {
104 public:
105 
108  typedef WindowedSincInterpolateImageFunctionBase<TInputImage,
109  typename Function::BlackmanWindowFunction<TInputInterpolator,
110  TOutputInterpolator>,
111  TBoundaryCondition,
112  TCoordRep>
116 
119 
121  itkNewMacro(Self);
122 
126 
128  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
129 
132  typedef typename Superclass::SizeType SizeType;
133  typedef typename Superclass::RealType RealType;
134  typedef typename Superclass::IteratorType IteratorType;
136 
137 protected:
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
itk::Size< Monteverdi_DIMENSION > SizeType
Definition: mvdTypes.h:137
Use the WindowedSincInterpolateImageFunctionBase with a Blackman Function.
void PrintSelf(std::ostream &os, itk::Indent indent) const override
constexpr double CONST_PI
Definition: otbMath.h:48
InputImageType::IndexType IndexType
WindowedSincInterpolateImageFunctionBase< TInputImage, typename Function::BlackmanWindowFunction< TInputInterpolator, TOutputInterpolator >, TBoundaryCondition, TCoordRep > Superclass
Monteverdi_FLOATING_TYPE RealType
Definition: mvdTypes.h:84
TInputImage InputImageType