OTB  10.0.0
Orfeo Toolbox
otbWindowedSincInterpolateImageCosineFunction.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 otbWindowedSincInterpolateImageCosineFunction_h
22 #define otbWindowedSincInterpolateImageCosineFunction_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_Factor = CONST_PI / (2 * static_cast<double>(radius));
51  }
52  unsigned int GetRadius() const
53  {
54  return m_Radius;
55  }
56  double GetFactor()
57  {
58  return m_Factor;
59  }
61 
62  inline TOutput operator()(const TInput& A) const
63  {
64  double x = static_cast<double>(A);
65  double px = CONST_PI * x;
66  double temp = std::cos(x * m_Factor);
67  return (x == 0.0) ? static_cast<TOutput>(temp) : static_cast<TOutput>(temp * std::sin(px) / px);
68  }
69 
70 private:
71  unsigned int m_Radius;
72  // Equal to \f$ \frac{\pi}{2 m} \f$
73  double m_Factor;
74 };
75 } // namespace Function
76 
92 template <class TInputImage, class TBoundaryCondition = itk::ConstantBoundaryCondition<TInputImage>, class TCoordRep = double,
93  class TInputInterpolator = double, class TOutputInterpolator = double>
95  : public WindowedSincInterpolateImageFunctionBase<TInputImage, typename Function::CosineWindowFunction<TInputInterpolator, TOutputInterpolator>,
96  TBoundaryCondition, TCoordRep>
97 {
98 public:
99 
103  TBoundaryCondition, TCoordRep>
105  typedef itk::SmartPointer<Self> Pointer;
106  typedef itk::SmartPointer<const Self> ConstPointer;
107 
110 
112  itkNewMacro(Self);
113 
115  typedef typename Superclass::InputImageType InputImageType;
116  typedef typename Superclass::OutputType OutputType;
117 
119  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
120 
122  typedef typename Superclass::IndexType IndexType;
123  typedef typename Superclass::SizeType SizeType;
124  typedef typename Superclass::RealType RealType;
125  typedef typename Superclass::IteratorType IteratorType;
126  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
127 
128 protected:
131  {
132  }
133  void PrintSelf(std::ostream& os, itk::Indent indent) const override
134  {
135  Superclass::PrintSelf(os, indent);
136  }
137 
138 private:
140  void operator=(const Self&) = delete;
141 };
142 
143 } // end namespace otb
144 
145 #endif
Generic interpolation of an otb::Image.
Use the WindowedSincInterpolateImageFunctionBase with a Cosine Function.
WindowedSincInterpolateImageCosineFunction(const Self &)=delete
WindowedSincInterpolateImageFunctionBase< TInputImage, typename Function::CosineWindowFunction< TInputInterpolator, TOutputInterpolator >, TBoundaryCondition, TCoordRep > Superclass
void PrintSelf(std::ostream &os, itk::Indent indent) const override
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
constexpr double CONST_PI
Definition: otbMath.h:49