OTB  9.0.0
Orfeo Toolbox
otbBCOInterpolateImageFunction.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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 
167  typedef typename Superclass::RealType RealType;
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
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbBCOInterpolateImageFunction.h:196
otb::BCOInterpolateImageFunctionBase::InputPixelType
Superclass::InputPixelType InputPixelType
Definition: otbBCOInterpolateImageFunction.h:79
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::InputPixelType
Superclass::InputPixelType InputPixelType
Definition: otbBCOInterpolateImageFunction.h:204
otb::BCOInterpolateImageFunction::PointType
Superclass::PointType PointType
Definition: otbBCOInterpolateImageFunction.h:170
otb::BCOInterpolateImageFunction::IndexType
Superclass::IndexType IndexType
Definition: otbBCOInterpolateImageFunction.h:168
otb::BCOInterpolateImageFunctionBase::OutputType
Superclass::OutputType OutputType
Definition: otbBCOInterpolateImageFunction.h:70
otb::BCOInterpolateImageFunction::IndexValueType
Superclass::IndexValueType IndexValueType
Definition: otbBCOInterpolateImageFunction.h:169
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbBCOInterpolateImageFunction.h:195
otbVectorImage.h
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::InputImageType
Superclass::InputImageType InputImageType
Definition: otbBCOInterpolateImageFunction.h:203
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::PointType
Superclass::PointType PointType
Definition: otbBCOInterpolateImageFunction.h:208
otb::BCOInterpolateImageFunctionBase::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbBCOInterpolateImageFunction.h:95
otb::BCOInterpolateImageFunction::RealType
Superclass::RealType RealType
Definition: otbBCOInterpolateImageFunction.h:167
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::~BCOInterpolateImageFunction
~BCOInterpolateImageFunction() override
Definition: otbBCOInterpolateImageFunction.h:216
otb::BCOInterpolateImageFunction::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbBCOInterpolateImageFunction.h:158
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::IndexType
Superclass::IndexType IndexType
Definition: otbBCOInterpolateImageFunction.h:206
otb::BCOInterpolateImageFunction::Self
BCOInterpolateImageFunction Self
Definition: otbBCOInterpolateImageFunction.h:155
otbMath.h
otb::BCOInterpolateImageFunction::CoefContainerType
Superclass::CoefContainerType CoefContainerType
Definition: otbBCOInterpolateImageFunction.h:172
otb::BCOInterpolateImageFunction::Superclass
BCOInterpolateImageFunctionBase< TInputImage, TCoordRep > Superclass
Definition: otbBCOInterpolateImageFunction.h:156
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::BCOInterpolateImageFunction::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbBCOInterpolateImageFunction.h:157
otb::BCOInterpolateImageFunctionBase::RealType
Superclass::RealType RealType
Definition: otbBCOInterpolateImageFunction.h:82
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::BCOInterpolateImageFunction
BCOInterpolateImageFunction()
Definition: otbBCOInterpolateImageFunction.h:215
otb::BCOInterpolateImageFunctionBase::IndexValueType
Superclass::IndexValueType IndexValueType
Definition: otbBCOInterpolateImageFunction.h:89
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::OutputType
Superclass::OutputType OutputType
Definition: otbBCOInterpolateImageFunction.h:202
otb::BCOInterpolateImageFunctionBase::BCOInterpolateImageFunctionBase
BCOInterpolateImageFunctionBase()
Definition: otbBCOInterpolateImageFunction.h:129
otb::BCOInterpolateImageFunctionBase::m_Radius
unsigned int m_Radius
Definition: otbBCOInterpolateImageFunction.h:136
otb::BCOInterpolateImageFunctionBase::InputImageType
Superclass::InputImageType InputImageType
Definition: otbBCOInterpolateImageFunction.h:76
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbBCOInterpolateImageFunction.h:209
otb::BCOInterpolateImageFunctionBase< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::CoefContainerType
vnl_vector< double > CoefContainerType
Definition: otbBCOInterpolateImageFunction.h:105
otb::BCOInterpolateImageFunction::BCOInterpolateImageFunction
BCOInterpolateImageFunction()
Definition: otbBCOInterpolateImageFunction.h:177
otb::BCOInterpolateImageFunction::~BCOInterpolateImageFunction
~BCOInterpolateImageFunction() override
Definition: otbBCOInterpolateImageFunction.h:178
otb::BCOInterpolateImageFunctionBase
Definition: otbBCOInterpolateImageFunction.h:62
otb::BCOInterpolateImageFunctionBase::Self
BCOInterpolateImageFunctionBase Self
Definition: otbBCOInterpolateImageFunction.h:66
otb::BCOInterpolateImageFunction
Interpolate an image at specified positions using bicubic interpolation.
Definition: otbBCOInterpolateImageFunction.h:151
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::Self
BCOInterpolateImageFunction Self
Definition: otbBCOInterpolateImageFunction.h:193
otbBCOInterpolateImageFunction.hxx
otb::BCOInterpolateImageFunctionBase::Superclass
itk::InterpolateImageFunction< TInputImage, TCoordRep > Superclass
Definition: otbBCOInterpolateImageFunction.h:67
otb::BCOInterpolateImageFunctionBase::PointType
Superclass::PointType PointType
Definition: otbBCOInterpolateImageFunction.h:92
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::Superclass
BCOInterpolateImageFunctionBase< otb::VectorImage< TPixel, VImageDimension >, TCoordRep > Superclass
Definition: otbBCOInterpolateImageFunction.h:194
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::CoefContainerType
Superclass::CoefContainerType CoefContainerType
Definition: otbBCOInterpolateImageFunction.h:210
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::RealType
Superclass::RealType RealType
Definition: otbBCOInterpolateImageFunction.h:205
otb::BCOInterpolateImageFunctionBase::IndexType
Superclass::IndexType IndexType
Definition: otbBCOInterpolateImageFunction.h:88
otb::BCOInterpolateImageFunction::InputImageType
Superclass::InputImageType InputImageType
Definition: otbBCOInterpolateImageFunction.h:165
otb::BCOInterpolateImageFunctionBase::~BCOInterpolateImageFunctionBase
~BCOInterpolateImageFunctionBase() override
Definition: otbBCOInterpolateImageFunction.h:130
otb::BCOInterpolateImageFunctionBase::ContinuousIndexValueType
TCoordRep ContinuousIndexValueType
Definition: otbBCOInterpolateImageFunction.h:96
otb::BCOInterpolateImageFunction::OutputType
Superclass::OutputType OutputType
Definition: otbBCOInterpolateImageFunction.h:164
otb::BCOInterpolateImageFunctionBase::m_Alpha
double m_Alpha
Definition: otbBCOInterpolateImageFunction.h:142
otb::BCOInterpolateImageFunction::InputPixelType
Superclass::InputPixelType InputPixelType
Definition: otbBCOInterpolateImageFunction.h:166
otb::BCOInterpolateImageFunctionBase::m_WinSize
unsigned int m_WinSize
Definition: otbBCOInterpolateImageFunction.h:139
otb::VectorImage
Creation of an "otb" vector image which contains metadata.
Definition: otbVectorImage.h:45
otb::BCOInterpolateImageFunction::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbBCOInterpolateImageFunction.h:171
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::IndexValueType
Superclass::IndexValueType IndexValueType
Definition: otbBCOInterpolateImageFunction.h:207