Orfeo Toolbox  4.0
otbComplexToVectorImageCastFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbComplexToVectorImageCastFilter_h
19 #define __otbComplexToVectorImageCastFilter_h
20 
21 #include "itkUnaryFunctorImageFilter.h"
22 #include "vnl/vnl_math.h"
24 
25 
26 namespace otb
27 {
28 
37 namespace Functor {
38 
39 template<class TInput, class TOutput>
41 {
42 public:
43  typedef typename TOutput::ValueType OutputValueType;
44 
47 
48  inline TOutput operator()( const TInput & A ) const
49  {
50  TOutput output;
51  output.SetSize( 2 );
52 
53  output[0] = static_cast<OutputValueType>(A.real());
54  output[1] = static_cast<OutputValueType>(A.imag());
55 
56  return output;
57  }
58 };
59 
60 
61 template<class TInput, class TOutput>
63 {
64 public:
65  typedef typename TOutput::ValueType OutputValueType;
66  typedef typename TInput::ValueType ValueType;
68 
71 
72  inline TOutput operator()( const TInput & A ) const
73  {
74  TOutput output;
75  output.SetSize( 2*A.Size() );
76 
77  for(unsigned int i=0; i<A.Size(); ++i)
78  {
79  output[2*i] = static_cast<OutputValueType>(A[i].real());
80  output[2*i+1] = static_cast<OutputValueType>(A[i].imag());
81  }
82 
83  return output;
84  }
85 
86 };
87 
88 
89 template< class TInput, class TOutput >
91 {
92 public:
94 };
95 
96 
97 template< class TInput, class TOutput >
98 class ComplexToVector<itk::VariableLengthVector<TInput>, TOutput>
99 {
100 public:
102 };
103 
104 }
105 
106 
107 template <class TInputImage, class TOutputImage>
109  public
110 itk::UnaryFunctorImageFilter<TInputImage, TOutputImage,
111  typename Functor::ComplexToVector<
112  typename TInputImage::PixelType,
113  typename TOutputImage::PixelType>::FunctorType >
114 {
115 public:
119  TInputImage, TOutputImage,
120  typename Functor::ComplexToVector< typename TInputImage::PixelType,
121  typename TOutputImage::PixelType>::FunctorType > Superclass;
124 
126  itkNewMacro(Self);
127 
129  itkTypeMacro(ComplexToVectorImageCastFilter,
131 
132  typedef typename TInputImage::PixelType InputPixelType;
133  typedef typename TOutputImage::PixelType OutputPixelType;
134 
135 
136 protected:
139 
140  template<class T>
141  bool PixelIsSingle(const T& /*dummy*/)
142  {
143  return true;
144  }
145 
146  template<class T>
147  bool PixelIsSingle(const itk::VariableLengthVector<T>& /*dummy*/)
148  {
149  return false;
150  }
151 
152  void GenerateOutputInformation()
153  {
154  Superclass::GenerateOutputInformation();
155  InputPixelType dummy;
156  if (!this->PixelIsSingle(dummy))
157  {
158  this->GetOutput()->SetNumberOfComponentsPerPixel(2 * this->GetInput()->GetNumberOfComponentsPerPixel());
159  }
160  }
161 
162 private:
163  ComplexToVectorImageCastFilter(const Self&); //purposely not implemented
164  void operator=(const Self&); //purposely not implemented
165 
166 };
167 
168 } // end namespace otb
169 
170 
171 #endif

Generated at Sat Mar 8 2014 15:52:56 for Orfeo Toolbox with doxygen 1.8.3.1