OTB  6.7.0
Orfeo Toolbox
otbWindowedSincInterpolateImageGaussianFunction.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 otbWindowedSincInterpolateImageGaussianFunction_h
22 #define otbWindowedSincInterpolateImageGaussianFunction_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  GaussianWindowFunction(): m_Radius(1), m_Factor(-2.0 / CONST_PI) {} // default radius is 1 at construction
45  void SetRadius(unsigned int radius)
46  {
47  m_Radius = radius;
48  m_Factor = -2. / (static_cast<double>(m_Radius * m_Radius) * CONST_PI);
49  }
50  double GetFactor()
51  {
52  return m_Factor;
53  }
54  unsigned int GetRadius() const
55  {
56  return m_Radius;
57  }
59 
60  inline TOutput operator ()(const TInput& A) const
61  {
62  double x = static_cast<double>(A);
63  double px = CONST_PI * x;
64  double temp = std::exp(px * px * m_Factor);
65  return (x == 0.0) ? static_cast<TOutput>(temp) : static_cast<TOutput>(temp * std::sin(px) / px);
66  }
67 private:
68  unsigned int m_Radius;
69  double m_Factor;
70 };
71 
72 } //namespace Function
73 
89 template<class TInputImage, class TBoundaryCondition = itk::ZeroFluxNeumannBoundaryCondition<TInputImage>, class TCoordRep =
90  double, class TInputInterpolator = double, class TOutputInterpolator = double>
93  typename Function::GaussianWindowFunction<TInputInterpolator,
94  TOutputInterpolator>,
95  TBoundaryCondition,
96  TCoordRep>
97 {
98 public:
99 
102  typedef WindowedSincInterpolateImageFunctionBase<TInputImage,
103  typename Function::GaussianWindowFunction<TInputInterpolator,
104  TOutputInterpolator>,
105  TBoundaryCondition,
106  TCoordRep>
110 
113 
115  itkNewMacro(Self);
116 
120 
122  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
123 
126  typedef typename Superclass::SizeType SizeType;
127  typedef typename Superclass::RealType RealType;
128  typedef typename Superclass::IteratorType IteratorType;
130 
131 protected:
134  void PrintSelf(std::ostream& os, itk::Indent indent) const override
135  {
136  Superclass::PrintSelf(os, indent);
137  }
138 
139 private:
140  WindowedSincInterpolateImageGaussianFunction(const Self &) = delete;
141  void operator =(const Self&) = delete;
142 };
143 
144 } // end namespace otb
145 
146 #endif
itk::Size< Monteverdi_DIMENSION > SizeType
Definition: mvdTypes.h:137
constexpr double CONST_PI
Definition: otbMath.h:48
Use the WindowedSincInterpolateImageFunctionBase with a Gaussian Function.
InputImageType::IndexType IndexType
Monteverdi_FLOATING_TYPE RealType
Definition: mvdTypes.h:84
TInputImage InputImageType
WindowedSincInterpolateImageFunctionBase< TInputImage, typename Function::GaussianWindowFunction< TInputInterpolator, TOutputInterpolator >, TBoundaryCondition, TCoordRep > Superclass
void PrintSelf(std::ostream &os, itk::Indent indent) const override