OTB  9.0.0
Orfeo Toolbox
otbImageFunctionAdaptor.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 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
otb::ImageFunctionAdaptor::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbImageFunctionAdaptor.h:59
otb::ImageFunctionAdaptor::InternalImageFunctionOutputType
InternalImageFunctionType::OutputType InternalImageFunctionOutputType
Definition: otbImageFunctionAdaptor.h:79
otb::ImageFunctionAdaptor::IndexType
Superclass::IndexType IndexType
Definition: otbImageFunctionAdaptor.h:71
otb::ImageFunctionAdaptor::OutputValueType
OutputType::ValueType OutputValueType
Definition: otbImageFunctionAdaptor.h:75
otb::ImageFunctionAdaptor::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbImageFunctionAdaptor.h:72
otb::VariableLengthVectorConverter
Convert any data container type into a VariableLengthVector.
Definition: otbVariableLengthVectorConverter.h:46
otb::ImageFunctionAdaptor::InputImageType
TInternalImageFunctionType::InputImageType InputImageType
Definition: otbImageFunctionAdaptor.h:66
otb::ImageFunctionAdaptor::Evaluate
OutputType Evaluate(const PointType &point) const override
Definition: otbImageFunctionAdaptor.h:92
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::ImageFunctionAdaptor::Self
ImageFunctionAdaptor Self
Definition: otbImageFunctionAdaptor.h:55
otb::ImageFunctionAdaptor
Adapt the output of the internal image function to be a itk::VariableLengthVector.
Definition: otbImageFunctionAdaptor.h:49
otb::ImageFunctionAdaptor::EvaluateAtContinuousIndex
OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
Definition: otbImageFunctionAdaptor.h:98
otb::VariableLengthVectorConverter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVariableLengthVectorConverter.h:52
otb::ImageFunctionAdaptor::m_InternalImageFunction
InternalImageFunctionType::Pointer m_InternalImageFunction
Definition: otbImageFunctionAdaptor.h:121
otb::ImageFunctionAdaptor::PointType
Superclass::PointType PointType
Definition: otbImageFunctionAdaptor.h:73
otb::ImageFunctionAdaptor::CoordRepType
TInternalImageFunctionType::CoordRepType CoordRepType
Definition: otbImageFunctionAdaptor.h:70
otb::ImageFunctionAdaptor::ConverterType
VariableLengthVectorConverter< InternalImageFunctionOutputType, TOutputPrecision > ConverterType
Definition: otbImageFunctionAdaptor.h:82
otb::ImageFunctionAdaptor::~ImageFunctionAdaptor
~ImageFunctionAdaptor() override
Definition: otbImageFunctionAdaptor.h:111
otbVariableLengthVectorConverter.h
otb::ImageFunctionAdaptor::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbImageFunctionAdaptor.h:60
otb::ImageFunctionAdaptor::InternalImageFunctionType
TInternalImageFunctionType InternalImageFunctionType
Definition: otbImageFunctionAdaptor.h:78
otb::ImageFunctionAdaptor::m_Converter
ConverterType::Pointer m_Converter
Definition: otbImageFunctionAdaptor.h:123
otb::ImageFunctionAdaptor::Superclass
itk::ImageFunction< typename TInternalImageFunctionType::InputImageType, itk::VariableLengthVector< TOutputPrecision >, typename TInternalImageFunctionType::CoordRepType > Superclass
Definition: otbImageFunctionAdaptor.h:58
otbImageFunctionAdaptor.hxx
otb::ImageFunctionAdaptor::OutputType
Superclass::OutputType OutputType
Definition: otbImageFunctionAdaptor.h:74