OTB  9.1.1
Orfeo Toolbox
otbBCOInterpolateImageFunction.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 otbBCOInterpolateImageFunction_h
22 #define otbBCOInterpolateImageFunction_h
23 
24 #include <boost/version.hpp>
25 #include <boost/container/small_vector.hpp>
26 
27 #include "itkInterpolateImageFunction.h"
28 #include "otbMath.h"
29 
30 #include "otbVectorImage.h"
31 
32 namespace otb
33 {
57 template <class TInputImage, class TCoordRep = double>
58 class ITK_EXPORT BCOInterpolateImageFunctionBase : public itk::InterpolateImageFunction<TInputImage, TCoordRep>
59 {
60 public:
63  typedef itk::InterpolateImageFunction<TInputImage, TCoordRep> Superclass;
64 
66  itkTypeMacro(BCOInterpolateImageFunctionBase, InterpolateImageFunction);
67 
69  typedef typename Superclass::OutputType OutputType;
70 
72  typedef typename Superclass::InputImageType InputImageType;
73 
75  typedef typename Superclass::InputPixelType InputPixelType;
76 
78  typedef typename Superclass::RealType RealType;
79 
81  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
82 
84  typedef typename Superclass::IndexType IndexType;
85  typedef typename Superclass::IndexValueType IndexValueType;
86 
88  typedef typename Superclass::PointType PointType;
89 
91  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
92  typedef TCoordRep ContinuousIndexValueType;
93 
95  typedef boost::container::small_vector<double, 7> CoefContainerType;
96 
98  virtual void SetRadius(unsigned int radius);
99  virtual unsigned int GetRadius() const;
101 
103  virtual void SetAlpha(double alpha);
104  virtual double GetAlpha() const;
106 
115  OutputType EvaluateAtContinuousIndex(const ContinuousIndexType& index) const override = 0;
116 
117 protected:
118  BCOInterpolateImageFunctionBase() : m_Radius(2), m_WinSize(5), m_Alpha(-0.5){};
120  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
122  CoefContainerType EvaluateCoef(const ContinuousIndexValueType& indexValue) const;
123 
125  unsigned int m_Radius;
126 
128  unsigned int m_WinSize;
129 
131  double m_Alpha;
132 
133 private:
134  BCOInterpolateImageFunctionBase(const Self&) = delete;
135  void operator=(const Self&) = delete;
136 };
137 
138 
139 template <class TInputImage, class TCoordRep = double>
140 class ITK_EXPORT BCOInterpolateImageFunction : public otb::BCOInterpolateImageFunctionBase<TInputImage, TCoordRep>
141 {
142 public:
146  typedef itk::SmartPointer<Self> Pointer;
147  typedef itk::SmartPointer<const Self> ConstPointer;
148 
150  itkNewMacro(Self);
151  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
152 
156  typedef typename Superclass::RealType RealType;
162 
163  OutputType EvaluateAtContinuousIndex(const ContinuousIndexType& index) const override;
164 
165 protected:
168  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
169 
170 private:
171  BCOInterpolateImageFunction(const Self&) = delete;
172  void operator=(const Self&) = delete;
173 };
174 
175 
176 template <typename TPixel, unsigned int VImageDimension, class TCoordRep>
177 class ITK_EXPORT BCOInterpolateImageFunction<otb::VectorImage<TPixel, VImageDimension>, TCoordRep>
178  : public otb::BCOInterpolateImageFunctionBase<otb::VectorImage<TPixel, VImageDimension>, TCoordRep>
179 {
180 public:
184  typedef itk::SmartPointer<Self> Pointer;
185  typedef itk::SmartPointer<const Self> ConstPointer;
186 
188  itkNewMacro(Self);
189  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
190 
194  typedef typename Superclass::RealType RealType;
198  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
200 
201  OutputType EvaluateAtContinuousIndex(const ContinuousIndexType& index) const override;
202 
203 protected:
206  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
207 
208 private:
209  BCOInterpolateImageFunction(const Self&) = delete;
210  void operator=(const Self&) = delete;
211 };
212 
213 } // end namespace otb
214 
215 #ifndef OTB_MANUAL_INSTANTIATION
217 #endif
218 
219 #endif
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbBCOInterpolateImageFunction.h:185
otb::BCOInterpolateImageFunctionBase::InputPixelType
Superclass::InputPixelType InputPixelType
Definition: otbBCOInterpolateImageFunction.h:75
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::InputPixelType
Superclass::InputPixelType InputPixelType
Definition: otbBCOInterpolateImageFunction.h:193
otb::BCOInterpolateImageFunction::PointType
Superclass::PointType PointType
Definition: otbBCOInterpolateImageFunction.h:159
otb::BCOInterpolateImageFunction::IndexType
Superclass::IndexType IndexType
Definition: otbBCOInterpolateImageFunction.h:157
otb::BCOInterpolateImageFunctionBase::OutputType
Superclass::OutputType OutputType
Definition: otbBCOInterpolateImageFunction.h:66
otb::BCOInterpolateImageFunction::IndexValueType
Superclass::IndexValueType IndexValueType
Definition: otbBCOInterpolateImageFunction.h:158
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbBCOInterpolateImageFunction.h:184
otbVectorImage.h
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::InputImageType
Superclass::InputImageType InputImageType
Definition: otbBCOInterpolateImageFunction.h:192
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::PointType
Superclass::PointType PointType
Definition: otbBCOInterpolateImageFunction.h:197
otb::BCOInterpolateImageFunctionBase::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbBCOInterpolateImageFunction.h:91
otb::BCOInterpolateImageFunction::RealType
Superclass::RealType RealType
Definition: otbBCOInterpolateImageFunction.h:156
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::~BCOInterpolateImageFunction
~BCOInterpolateImageFunction() override
Definition: otbBCOInterpolateImageFunction.h:205
otb::BCOInterpolateImageFunction::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbBCOInterpolateImageFunction.h:147
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::IndexType
Superclass::IndexType IndexType
Definition: otbBCOInterpolateImageFunction.h:195
otb::BCOInterpolateImageFunction::Self
BCOInterpolateImageFunction Self
Definition: otbBCOInterpolateImageFunction.h:144
otbMath.h
otb::BCOInterpolateImageFunction::CoefContainerType
Superclass::CoefContainerType CoefContainerType
Definition: otbBCOInterpolateImageFunction.h:161
otb::BCOInterpolateImageFunction::Superclass
BCOInterpolateImageFunctionBase< TInputImage, TCoordRep > Superclass
Definition: otbBCOInterpolateImageFunction.h:145
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::BCOInterpolateImageFunctionBase::CoefContainerType
boost::container::small_vector< double, 7 > CoefContainerType
Definition: otbBCOInterpolateImageFunction.h:95
otb::BCOInterpolateImageFunction::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbBCOInterpolateImageFunction.h:146
otb::BCOInterpolateImageFunctionBase::RealType
Superclass::RealType RealType
Definition: otbBCOInterpolateImageFunction.h:78
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::BCOInterpolateImageFunction
BCOInterpolateImageFunction()
Definition: otbBCOInterpolateImageFunction.h:204
otb::BCOInterpolateImageFunctionBase::IndexValueType
Superclass::IndexValueType IndexValueType
Definition: otbBCOInterpolateImageFunction.h:85
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::OutputType
Superclass::OutputType OutputType
Definition: otbBCOInterpolateImageFunction.h:191
otb::BCOInterpolateImageFunctionBase::BCOInterpolateImageFunctionBase
BCOInterpolateImageFunctionBase()
Definition: otbBCOInterpolateImageFunction.h:118
otb::BCOInterpolateImageFunctionBase::m_Radius
unsigned int m_Radius
Definition: otbBCOInterpolateImageFunction.h:125
otb::BCOInterpolateImageFunctionBase::InputImageType
Superclass::InputImageType InputImageType
Definition: otbBCOInterpolateImageFunction.h:72
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbBCOInterpolateImageFunction.h:198
otb::BCOInterpolateImageFunction::BCOInterpolateImageFunction
BCOInterpolateImageFunction()
Definition: otbBCOInterpolateImageFunction.h:166
otb::BCOInterpolateImageFunction::~BCOInterpolateImageFunction
~BCOInterpolateImageFunction() override
Definition: otbBCOInterpolateImageFunction.h:167
otb::BCOInterpolateImageFunctionBase
Definition: otbBCOInterpolateImageFunction.h:58
otb::BCOInterpolateImageFunctionBase::Self
BCOInterpolateImageFunctionBase Self
Definition: otbBCOInterpolateImageFunction.h:62
otb::BCOInterpolateImageFunction
Interpolate an image at specified positions using bicubic interpolation.
Definition: otbBCOInterpolateImageFunction.h:140
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::Self
BCOInterpolateImageFunction Self
Definition: otbBCOInterpolateImageFunction.h:182
otbBCOInterpolateImageFunction.hxx
otb::BCOInterpolateImageFunctionBase::Superclass
itk::InterpolateImageFunction< TInputImage, TCoordRep > Superclass
Definition: otbBCOInterpolateImageFunction.h:63
otb::BCOInterpolateImageFunctionBase::PointType
Superclass::PointType PointType
Definition: otbBCOInterpolateImageFunction.h:88
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::Superclass
BCOInterpolateImageFunctionBase< otb::VectorImage< TPixel, VImageDimension >, TCoordRep > Superclass
Definition: otbBCOInterpolateImageFunction.h:183
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::CoefContainerType
Superclass::CoefContainerType CoefContainerType
Definition: otbBCOInterpolateImageFunction.h:199
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::RealType
Superclass::RealType RealType
Definition: otbBCOInterpolateImageFunction.h:194
otb::BCOInterpolateImageFunctionBase::IndexType
Superclass::IndexType IndexType
Definition: otbBCOInterpolateImageFunction.h:84
otb::BCOInterpolateImageFunction::InputImageType
Superclass::InputImageType InputImageType
Definition: otbBCOInterpolateImageFunction.h:154
otb::BCOInterpolateImageFunctionBase::~BCOInterpolateImageFunctionBase
~BCOInterpolateImageFunctionBase() override
Definition: otbBCOInterpolateImageFunction.h:119
otb::BCOInterpolateImageFunctionBase::ContinuousIndexValueType
TCoordRep ContinuousIndexValueType
Definition: otbBCOInterpolateImageFunction.h:92
otb::BCOInterpolateImageFunction::OutputType
Superclass::OutputType OutputType
Definition: otbBCOInterpolateImageFunction.h:153
otb::BCOInterpolateImageFunctionBase::m_Alpha
double m_Alpha
Definition: otbBCOInterpolateImageFunction.h:131
otb::BCOInterpolateImageFunction::InputPixelType
Superclass::InputPixelType InputPixelType
Definition: otbBCOInterpolateImageFunction.h:155
otb::BCOInterpolateImageFunctionBase::m_WinSize
unsigned int m_WinSize
Definition: otbBCOInterpolateImageFunction.h:128
otb::VectorImage
Creation of an "otb" vector image which contains metadata.
Definition: otbVectorImage.h:45
otb::BCOInterpolateImageFunction::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbBCOInterpolateImageFunction.h:160
otb::BCOInterpolateImageFunction< otb::VectorImage< TPixel, VImageDimension >, TCoordRep >::IndexValueType
Superclass::IndexValueType IndexValueType
Definition: otbBCOInterpolateImageFunction.h:196