OTB  6.3.0
Orfeo Toolbox
otbWindowedSincInterpolateImageGaussianFunction.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2017 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  void SetRadius(unsigned int radius)
45  {
46  m_Radius = radius;
47  m_Factor = -2. / (static_cast<double>(m_Radius * m_Radius) * CONST_PI);
48  }
49  double GetFactor()
50  {
51  return m_Factor;
52  }
53  unsigned int GetRadius() const
54  {
55  return m_Radius;
56  }
58 
59  inline TOutput operator ()(const TInput& A) const
60  {
61  double x = static_cast<double>(A);
62  double px = CONST_PI * x;
63  double temp = vcl_exp(px * px * m_Factor);
64  return (x == 0.0) ? static_cast<TOutput>(temp) : static_cast<TOutput>(temp * vcl_sin(px) / px);
65  }
66 private:
67  double m_Factor;
68  unsigned int m_Radius;
69 };
70 
71 } //namespace Function
72 
88 template<class TInputImage, class TBoundaryCondition = itk::ZeroFluxNeumannBoundaryCondition<TInputImage>, class TCoordRep =
89  double, class TInputInterpolator = double, class TOutputInterpolator = double>
92  typename Function::GaussianWindowFunction<TInputInterpolator,
93  TOutputInterpolator>,
94  TBoundaryCondition,
95  TCoordRep>
96 {
97 public:
98 
101  typedef WindowedSincInterpolateImageFunctionBase<TInputImage,
102  typename Function::GaussianWindowFunction<TInputInterpolator,
103  TOutputInterpolator>,
104  TBoundaryCondition,
105  TCoordRep>
109 
112 
114  itkNewMacro(Self);
115 
119 
121  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
122 
125  typedef typename Superclass::SizeType SizeType;
126  typedef typename Superclass::RealType RealType;
127  typedef typename Superclass::IteratorType IteratorType;
129 
130 protected:
133  void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE
134  {
135  Superclass::PrintSelf(os, indent);
136  }
137 
138 private:
139  WindowedSincInterpolateImageGaussianFunction(const Self &); //purposely not implemented
140  void operator =(const Self&); //purposely not implemented
141 };
142 
143 } // end namespace otb
144 
145 #endif
const double CONST_PI
Definition: otbMath.h:48
itk::Size< Monteverdi_DIMENSION > SizeType
Definition: mvdTypes.h:146
Use the WindowedSincInterpolateImageFunctionBase with a Gaussian Function.
InputImageType::IndexType IndexType
Monteverdi_FLOATING_TYPE RealType
Definition: mvdTypes.h:93
TInputImage InputImageType
WindowedSincInterpolateImageFunctionBase< TInputImage, typename Function::GaussianWindowFunction< TInputInterpolator, TOutputInterpolator >, TBoundaryCondition, TCoordRep > Superclass
void PrintSelf(std::ostream &os, itk::Indent indent) const ITK_OVERRIDE