OTB  9.0.0
Orfeo Toolbox
otbComplexToVectorImageCastFilter.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 otbComplexToVectorImageCastFilter_h
22 #define otbComplexToVectorImageCastFilter_h
23 
24 #include "itkUnaryFunctorImageFilter.h"
25 #include "vnl/vnl_math.h"
26 #include "itkVariableLengthVector.h"
27 
28 
29 namespace otb
30 {
31 
42 namespace Functor
43 {
44 
45 template <class TInput, class TOutput>
47 {
48 public:
49  typedef typename TOutput::ValueType OutputValueType;
50 
52  {
53  }
55  {
56  }
57 
58  inline TOutput operator()(const TInput& A) const
59  {
60  TOutput output;
61  output.SetSize(2);
62 
63  output[0] = static_cast<OutputValueType>(A.real());
64  output[1] = static_cast<OutputValueType>(A.imag());
65 
66  return output;
67  }
68 };
69 
70 
71 template <class TInput, class TOutput>
73 {
74 public:
75  typedef typename TOutput::ValueType OutputValueType;
76  typedef typename TInput::ValueType ValueType;
77  typedef itk::VariableLengthVector<ValueType> TestType;
78 
80  {
81  }
83  {
84  }
85 
86  inline TOutput operator()(const TInput& A) const
87  {
88  TOutput output;
89  output.SetSize(2 * A.Size());
90 
91  for (unsigned int i = 0; i < A.Size(); ++i)
92  {
93  output[2 * i] = static_cast<OutputValueType>(A[i].real());
94  output[2 * i + 1] = static_cast<OutputValueType>(A[i].imag());
95  }
96 
97  return output;
98  }
99 };
100 
101 
102 template <class TInput, class TOutput>
104 {
105 public:
107 };
108 
109 
110 template <class TInput, class TOutput>
111 class ComplexToVector<itk::VariableLengthVector<TInput>, TOutput>
112 {
113 public:
115 };
116 }
117 
118 
119 template <class TInputImage, class TOutputImage>
121  : public itk::UnaryFunctorImageFilter<TInputImage, TOutputImage,
122  typename Functor::ComplexToVector<typename TInputImage::PixelType, typename TOutputImage::PixelType>::FunctorType>
123 {
124 public:
127  typedef itk::UnaryFunctorImageFilter<TInputImage, TOutputImage,
130  typedef itk::SmartPointer<Self> Pointer;
131  typedef itk::SmartPointer<const Self> ConstPointer;
132 
134  itkNewMacro(Self);
135 
137  itkTypeMacro(ComplexToVectorImageCastFilter, itk::UnaryFunctorImageFilter);
138 
139  typedef typename TInputImage::PixelType InputPixelType;
140  typedef typename TOutputImage::PixelType OutputPixelType;
141 
142 
143 protected:
145  {
146  }
148  {
149  }
150 
151  template <class T>
152  bool PixelIsSingle(const T& /*dummy*/)
153  {
154  return true;
155  }
156 
157  template <class T>
158  bool PixelIsSingle(const itk::VariableLengthVector<T>& /*dummy*/)
159  {
160  return false;
161  }
162 
164  {
165  Superclass::GenerateOutputInformation();
166  InputPixelType dummy;
167  if (!this->PixelIsSingle(dummy))
168  {
169  this->GetOutput()->SetNumberOfComponentsPerPixel(2 * this->GetInput()->GetNumberOfComponentsPerPixel());
170  }
171  }
172 
173 private:
174  ComplexToVectorImageCastFilter(const Self&) = delete;
175  void operator=(const Self&) = delete;
176 };
177 
178 } // end namespace otb
179 
180 
181 #endif
otb::ComplexToVectorImageCastFilter::ComplexToVectorImageCastFilter
ComplexToVectorImageCastFilter()
Definition: otbComplexToVectorImageCastFilter.h:144
otb::Functor::SingleComplexToVector::~SingleComplexToVector
~SingleComplexToVector()
Definition: otbComplexToVectorImageCastFilter.h:54
otb::Functor::VectorComplexToVector::operator()
TOutput operator()(const TInput &A) const
Definition: otbComplexToVectorImageCastFilter.h:86
otb::ComplexToVectorImageCastFilter::PixelIsSingle
bool PixelIsSingle(const T &)
Definition: otbComplexToVectorImageCastFilter.h:152
otb::ComplexToVectorImageCastFilter::~ComplexToVectorImageCastFilter
~ComplexToVectorImageCastFilter() override
Definition: otbComplexToVectorImageCastFilter.h:147
otb::Functor::ComplexToVector< itk::VariableLengthVector< TInput >, TOutput >::FunctorType
VectorComplexToVector< itk::VariableLengthVector< TInput >, TOutput > FunctorType
Definition: otbComplexToVectorImageCastFilter.h:114
otb::Functor::SingleComplexToVector::OutputValueType
TOutput::ValueType OutputValueType
Definition: otbComplexToVectorImageCastFilter.h:49
otb::Functor::SingleComplexToVector::operator()
TOutput operator()(const TInput &A) const
Definition: otbComplexToVectorImageCastFilter.h:58
otb::Functor::VectorComplexToVector::OutputValueType
TOutput::ValueType OutputValueType
Definition: otbComplexToVectorImageCastFilter.h:75
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::SingleComplexToVector
Definition: otbComplexToVectorImageCastFilter.h:46
otb::ComplexToVectorImageCastFilter::Superclass
itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, typename Functor::ComplexToVector< typename TInputImage::PixelType, typename TOutputImage::PixelType >::FunctorType > Superclass
Definition: otbComplexToVectorImageCastFilter.h:129
otb::Functor::ComplexToVector::FunctorType
SingleComplexToVector< TInput, TOutput > FunctorType
Definition: otbComplexToVectorImageCastFilter.h:106
otb::ComplexToVectorImageCastFilter::GenerateOutputInformation
void GenerateOutputInformation() override
Definition: otbComplexToVectorImageCastFilter.h:163
otb::Functor::VectorComplexToVector::VectorComplexToVector
VectorComplexToVector()
Definition: otbComplexToVectorImageCastFilter.h:79
otb::Functor::VectorComplexToVector
Definition: otbComplexToVectorImageCastFilter.h:72
otb::ComplexToVectorImageCastFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbComplexToVectorImageCastFilter.h:131
otb::ComplexToVectorImageCastFilter::Self
ComplexToVectorImageCastFilter Self
Definition: otbComplexToVectorImageCastFilter.h:126
otb::Functor::ComplexToVector
Definition: otbComplexToVectorImageCastFilter.h:103
otb::Functor::VectorComplexToVector::~VectorComplexToVector
~VectorComplexToVector()
Definition: otbComplexToVectorImageCastFilter.h:82
otb::Functor::VectorComplexToVector::TestType
itk::VariableLengthVector< ValueType > TestType
Definition: otbComplexToVectorImageCastFilter.h:77
otb::ComplexToVectorImageCastFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbComplexToVectorImageCastFilter.h:130
otb::ComplexToVectorImageCastFilter
Transform a complex image into a 2 channels vector image. The first channel is the real part,...
Definition: otbComplexToVectorImageCastFilter.h:120
otb::Functor::VectorComplexToVector::ValueType
TInput::ValueType ValueType
Definition: otbComplexToVectorImageCastFilter.h:76
itk
Definition: otbNoDataHelper.h:31
otb::ComplexToVectorImageCastFilter::OutputPixelType
TOutputImage::PixelType OutputPixelType
Definition: otbComplexToVectorImageCastFilter.h:140
otb::Functor::SingleComplexToVector::SingleComplexToVector
SingleComplexToVector()
Definition: otbComplexToVectorImageCastFilter.h:51
otb::ComplexToVectorImageCastFilter::InputPixelType
TInputImage::PixelType InputPixelType
Definition: otbComplexToVectorImageCastFilter.h:137
otb::ComplexToVectorImageCastFilter::PixelIsSingle
bool PixelIsSingle(const itk::VariableLengthVector< T > &)
Definition: otbComplexToVectorImageCastFilter.h:158