OTB  7.2.0
Orfeo Toolbox
otbBCOInterpolateImageFunction.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2020 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 otbBCOInterpolateImageFunction_h
22 #define otbBCOInterpolateImageFunction_h
23 
24 #include <boost/version.hpp>
25 #if BOOST_VERSION >= 105800
26 #include <boost/container/small_vector.hpp>
27 #else
28 #include "vnl/vnl_vector.h"
29 #endif
30 
31 #include "itkInterpolateImageFunction.h"
32 #include "otbMath.h"
33 
34 #include "otbVectorImage.h"
35 
36 namespace otb
37 {
61 template <class TInputImage, class TCoordRep = double>
62 class ITK_EXPORT BCOInterpolateImageFunctionBase : public itk::InterpolateImageFunction<TInputImage, TCoordRep>
63 {
64 public:
67  typedef itk::InterpolateImageFunction<TInputImage, TCoordRep> Superclass;
68 
70  itkTypeMacro(BCOInterpolateImageFunctionBase, InterpolateImageFunction);
71 
73  typedef typename Superclass::OutputType OutputType;
74 
76  typedef typename Superclass::InputImageType InputImageType;
77 
79  typedef typename Superclass::InputPixelType InputPixelType;
80 
82  typedef typename Superclass::RealType RealType;
83 
85  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
86 
88  typedef typename Superclass::IndexType IndexType;
89  typedef typename Superclass::IndexValueType IndexValueType;
90 
92  typedef typename Superclass::PointType PointType;
93 
95  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
96  typedef TCoordRep ContinuousIndexValueType;
97 
98 #if BOOST_VERSION >= 105800
99  // Faster path for small radii.
101  typedef boost::container::small_vector<double, 7> CoefContainerType;
102 #else
103 
105  typedef vnl_vector<double> CoefContainerType;
106 #endif
107 
109  virtual void SetRadius(unsigned int radius);
110  virtual unsigned int GetRadius() const;
112 
114  virtual void SetAlpha(double alpha);
115  virtual double GetAlpha() const;
117 
126  OutputType EvaluateAtContinuousIndex(const ContinuousIndexType& index) const override = 0;
127 
128 protected:
129  BCOInterpolateImageFunctionBase() : m_Radius(2), m_WinSize(5), m_Alpha(-0.5){};
131  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
133  CoefContainerType EvaluateCoef(const ContinuousIndexValueType& indexValue) const;
134 
136  unsigned int m_Radius;
137 
139  unsigned int m_WinSize;
140 
142  double m_Alpha;
143 
144 private:
145  BCOInterpolateImageFunctionBase(const Self&) = delete;
146  void operator=(const Self&) = delete;
147 };
148 
149 
150 template <class TInputImage, class TCoordRep = double>
151 class ITK_EXPORT BCOInterpolateImageFunction : public otb::BCOInterpolateImageFunctionBase<TInputImage, TCoordRep>
152 {
153 public:
157  typedef itk::SmartPointer<Self> Pointer;
158  typedef itk::SmartPointer<const Self> ConstPointer;
159 
161  itkNewMacro(Self);
162  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
163 
165  typedef typename Superclass::InputImageType InputImageType;
166  typedef typename Superclass::InputPixelType InputPixelType;
167  typedef typename Superclass::RealType RealType;
169  typedef typename Superclass::IndexValueType IndexValueType;
171  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
172  typedef typename Superclass::CoefContainerType CoefContainerType;
173 
174  OutputType EvaluateAtContinuousIndex(const ContinuousIndexType& index) const override;
175 
176 protected:
179  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
180 
181 private:
182  BCOInterpolateImageFunction(const Self&) = delete;
183  void operator=(const Self&) = delete;
184 };
185 
186 
187 template <typename TPixel, unsigned int VImageDimension, class TCoordRep>
188 class ITK_EXPORT BCOInterpolateImageFunction<otb::VectorImage<TPixel, VImageDimension>, TCoordRep>
189  : public otb::BCOInterpolateImageFunctionBase<otb::VectorImage<TPixel, VImageDimension>, TCoordRep>
190 {
191 public:
195  typedef itk::SmartPointer<Self> Pointer;
196  typedef itk::SmartPointer<const Self> ConstPointer;
197 
199  itkNewMacro(Self);
200  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
201 
205  typedef typename Superclass::RealType RealType;
209  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
211 
212  OutputType EvaluateAtContinuousIndex(const ContinuousIndexType& index) const override;
213 
214 protected:
217  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
218 
219 private:
220  BCOInterpolateImageFunction(const Self&) = delete;
221  void operator=(const Self&) = delete;
222 };
223 
224 } // end namespace otb
225 
226 #ifndef OTB_MANUAL_INSTANTIATION
228 #endif
229 
230 #endif
itk::Index< Monteverdi_DIMENSION > IndexType
Definition: mvdTypes.h:133
Creation of an "otb" vector image which contains metadata.
itk::InterpolateImageFunction< TInputImage, TCoordRep > Superclass
BCOInterpolateImageFunctionBase< otb::VectorImage< TPixel, VImageDimension >, TCoordRep > Superclass
BCOInterpolateImageFunctionBase< TInputImage, TCoordRep > Superclass
Interpolate an image at specified positions using bicubic interpolation.
Superclass::ContinuousIndexType ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Monteverdi_FLOATING_TYPE RealType
Definition: mvdTypes.h:84
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Superclass::CoefContainerType CoefContainerType
itk::SmartPointer< const Self > ConstPointer
VectorImageType::PointType PointType
Definition: mvdTypes.h:183