OTB  10.0.0
Orfeo Toolbox
otbImageFunctionAdaptor.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 otbImageFunctionAdaptor_h
22 #define otbImageFunctionAdaptor_h
23 
24 #include "itkImageFunction.h"
25 
27 #include "OTBImageBaseExport.h"
28 
29 #include <complex>
30 
31 namespace otb
32 {
48 template <class TInternalImageFunctionType, class TOutputPrecision = double>
49 class OTBImageBase_EXPORT_TEMPLATE ImageFunctionAdaptor
50  : public itk::ImageFunction<typename TInternalImageFunctionType::InputImageType, itk::VariableLengthVector<TOutputPrecision>,
51  typename TInternalImageFunctionType::CoordRepType>
52 {
53 public:
54  // Standard class typedefs. //
56  typedef itk::ImageFunction<typename TInternalImageFunctionType::InputImageType, itk::VariableLengthVector<TOutputPrecision>,
57  typename TInternalImageFunctionType::CoordRepType>
59  typedef itk::SmartPointer<Self> Pointer;
60  typedef itk::SmartPointer<const Self> ConstPointer;
61 
62  // Run-time type information (and related methods). //
63  itkTypeMacro(ImageFunctionAdaptor, ImageFunction);
64 
65  // Method for creation through the object factory. //
66  itkNewMacro(Self);
67 
68  // InputImageType typedef support. //
69  typedef typename TInternalImageFunctionType::InputImageType InputImageType;
70  typedef typename TInternalImageFunctionType::CoordRepType CoordRepType;
71  typedef typename Superclass::IndexType IndexType;
72  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
73  typedef typename Superclass::PointType PointType;
74  typedef typename Superclass::OutputType OutputType;
75  typedef typename OutputType::ValueType OutputValueType;
76 
77  // InternalImageFunction related typedefs //
78  typedef TInternalImageFunctionType InternalImageFunctionType;
79  typedef typename InternalImageFunctionType::OutputType InternalImageFunctionOutputType;
80 
81  // Converter related typedefs //
83 
84 
85  // Dimension of the underlying image. //
86  itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension);
87 
88  // Evalulate the function at specified index //
89  OutputType EvaluateAtIndex(const IndexType& index) const override;
90 
91  // Evaluate the function at non-integer positions //
92  OutputType Evaluate(const PointType& point) const override
93  {
94  IndexType index;
95  this->ConvertPointToNearestIndex(point, index);
96  return this->EvaluateAtIndex(index);
97  }
99  {
100  IndexType index;
101  this->ConvertContinuousIndexToNearestIndex(cindex, index);
102  return this->EvaluateAtIndex(index);
103  }
104 
105  // Accessors //
106  itkGetConstMacro(InternalImageFunction, typename InternalImageFunctionType::Pointer);
107  itkSetMacro(InternalImageFunction, typename InternalImageFunctionType::Pointer);
108 
109 protected:
112  {
113  }
114  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
115 
116 private:
117  ImageFunctionAdaptor(const Self&) = delete;
118  void operator=(const Self&) = delete;
119 
120  // Internal Image Function //
121  typename InternalImageFunctionType::Pointer m_InternalImageFunction;
122  // Converter //
124 };
125 
126 } // end namespace otb
127 
128 #ifndef OTB_MANUAL_INSTANTIATION
130 #endif
131 
132 #endif
Adapt the output of the internal image function to be a itk::VariableLengthVector.
OutputType::ValueType OutputValueType
VariableLengthVectorConverter< InternalImageFunctionOutputType, TOutputPrecision > ConverterType
OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
TInternalImageFunctionType::InputImageType InputImageType
itk::SmartPointer< const Self > ConstPointer
Superclass::PointType PointType
Superclass::ContinuousIndexType ContinuousIndexType
Superclass::IndexType IndexType
ConverterType::Pointer m_Converter
OutputType Evaluate(const PointType &point) const override
itk::SmartPointer< Self > Pointer
TInternalImageFunctionType::CoordRepType CoordRepType
InternalImageFunctionType::Pointer m_InternalImageFunction
itk::ImageFunction< typename TInternalImageFunctionType::InputImageType, itk::VariableLengthVector< TOutputPrecision >, typename TInternalImageFunctionType::CoordRepType > Superclass
void operator=(const Self &)=delete
TInternalImageFunctionType InternalImageFunctionType
Superclass::OutputType OutputType
InternalImageFunctionType::OutputType InternalImageFunctionOutputType
ImageFunctionAdaptor(const Self &)=delete
Convert any data container type into a VariableLengthVector.
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.