Orfeo Toolbox  3.16
itkVnlFFTComplexConjugateToRealImageFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: itkVnlFFTComplexConjugateToRealImageFilter.txx,v $
5 Language: C++
6 Date: $Date: 2010-02-26 23:50:55 $
7 Version: $Revision: 1.13 $
8 
9 Copyright (c) 2002 Insight Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkVnlFFTComplexConjugateToRealImageFilter_txx
18 #define __itkVnlFFTComplexConjugateToRealImageFilter_txx
19 
22 #include <complex>
23 #include "vnl/algo/vnl_fft_1d.h"
24 #include "vnl/algo/vnl_fft_2d.h"
25 #include "vnl_fft_3d.h"
26 #include "itkProgressReporter.h"
27 
28 namespace itk
29 {
30 
31 template <class TPixel, unsigned int VDimension>
32 void
35 {
36  unsigned int i;
37  // get pointers to the input and output
38  typename TInputImageType::ConstPointer inputPtr = this->GetInput();
39  typename TOutputImageType::Pointer outputPtr = this->GetOutput();
40 
41  if ( !inputPtr || !outputPtr )
42  {
43  return;
44  }
45 
46  // we don't have a nice progress to report, but at least this simple line
47  // reports the begining and the end of the process
48  ProgressReporter progress(this, 0, 1);
49 
50  const typename TInputImageType::SizeType& outputSize
51  = outputPtr->GetLargestPossibleRegion().GetSize();
52  unsigned int num_dims = outputPtr->GetImageDimension();
53 
54  if(num_dims != outputPtr->GetImageDimension())
55  return;
56 
57  // allocate output buffer memory
58  outputPtr->SetBufferedRegion( outputPtr->GetRequestedRegion() );
59  outputPtr->Allocate();
60 
61  std::complex<TPixel> *in = const_cast<std::complex<TPixel> *>
62  (inputPtr->GetBufferPointer());
63 
64  unsigned int vec_size = 1;
65  for(i = 0; i < num_dims; i++)
66  {
67  vec_size *= outputSize[i];
68  }
69 
70  vnl_vector< vcl_complex<TPixel> > signal(vec_size);
71  for(i = 0; i < vec_size; i++)
72  signal[i] = in[i];
73 
74  TPixel *out = outputPtr->GetBufferPointer();
75 
76  switch(num_dims)
77  {
78  case 1:
79  {
80  vnl_fft_1d<TPixel> v1d(vec_size);
81  v1d.fwd_transform(signal);
82  }
83  break;
84  case 2:
85  {
86  vnl_fft_2d<TPixel> v2d(outputSize[1],outputSize[0]);
87  v2d.vnl_fft_2d<TPixel>::base::transform(signal.data_block(),+1);
88  }
89  break;
90  case 3:
91  {
92  vnl_fft_3d<TPixel> v3d(outputSize[2],outputSize[1],outputSize[0]);
93  v3d.vnl_fft_3d<TPixel>::base::transform(signal.data_block(),+1);
94  }
95  break;
96  default:
97  break;
98  }
99  for(i = 0; i < vec_size; i++)
100  {
101  out[i] = signal[i].real() / vec_size;
102  }
103 }
104 
105 template <class TPixel, unsigned int VDimension>
106 bool
109 {
110  return true;
111 }
112 
113 }
114 #endif

Generated at Sun Feb 3 2013 00:13:09 for Orfeo Toolbox with doxygen 1.8.1.1