Orfeo Toolbox  3.16
itkFFTComplexToComplexImageFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkFFTComplexToComplexImageFilter.txx,v $
5  Language: C++
6  Date: $Date: 2008-10-04 12:38:06 $
7  Version: $Revision: 1.5 $
8 
9  Copyright (c) Insight Software 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 
31 #ifndef __itkFFTComplexToComplexImageFilter_txx
32 #define __itkFFTComplexToComplexImageFilter_txx
33 
36 
37 namespace itk
38 {
39 
40 #if defined(USE_FFTWD) || defined(USE_FFTWF)
41 template <class TPixel,unsigned int NDimension> class FFTWComplexToComplexImageFilter;
42 #endif
43 
44 template < class TPixel, unsigned int NDimension >
45 typename FFTComplexToComplexImageFilter< TPixel, NDimension >::Pointer
47 ::New(void)
48 {
50 
51 #ifdef USE_FFTWD
52  if( smartPtr.IsNull() )
53  {
54  if( typeid(TPixel) == typeid(double) )
55  {
56  smartPtr = dynamic_cast<Self *>(
58  }
59  }
60 #endif
61 #ifdef USE_FFTWF
62  if(smartPtr.IsNull())
63  {
64  if( typeid(TPixel) == typeid(float) )
65  {
66  smartPtr = dynamic_cast<Self *>(
68  }
69  }
70 #endif
71 
72  return smartPtr;
73 }
74 
75 
76 template <class TPixel, unsigned int NDimension >
77 void
80 {
81  // call the superclass' implementation of this method
82  Superclass::GenerateOutputInformation();
83  //
84  // If this implementation returns a full result
85  // instead of a 'half-complex' matrix, then none of this
86  // is necessary
87  if(this->FullMatrix())
88  return;
89 
90  // get pointers to the input and output
91  typename InputImageType::ConstPointer inputPtr = this->GetInput();
92  typename OutputImageType::Pointer outputPtr = this->GetOutput();
93 
94  if ( !inputPtr || !outputPtr )
95  {
96  return;
97  }
98 
99  //
100  // This is all based on the same function in itk::ShrinkImageFilter
101  // ShrinkImageFilter also modifies the image spacing, but spacing
102  // has no meaning in the result of an FFT. For an IFFT, since the
103  // spacing is propagated to the complex result, we can use the spacing
104  // from the input to propagate back to the output.
105  unsigned int i;
106  const typename InputImageType::SizeType& inputSize
107  = inputPtr->GetLargestPossibleRegion().GetSize();
108  const typename InputImageType::IndexType& inputStartIndex
109  = inputPtr->GetLargestPossibleRegion().GetIndex();
110 
111  typename OutputImageType::SizeType outputSize;
112  typename OutputImageType::IndexType outputStartIndex;
113 
114  //
115  // Size of output FFT:C2C is the same as input
116  //
117 
118  outputSize[0] = inputSize[0];
119  outputStartIndex[0] = inputStartIndex[0];
120 
121  for (i = 1; i < OutputImageType::ImageDimension; i++)
122  {
123  outputSize[i] = inputSize[i];
124  outputStartIndex[i] = inputStartIndex[i];
125  }
126  typename OutputImageType::RegionType outputLargestPossibleRegion;
127  outputLargestPossibleRegion.SetSize( outputSize );
128  outputLargestPossibleRegion.SetIndex( outputStartIndex );
129 
130  outputPtr->SetLargestPossibleRegion( outputLargestPossibleRegion );
131 }
132 
133 template <class TPixel, unsigned int NDimension >
134 void
137 {
138  Superclass::GenerateInputRequestedRegion();
139  // get pointers to the input and output
140  typename InputImageType::Pointer inputPtr =
141  const_cast<InputImageType *>(this->GetInput());
142  inputPtr->SetRequestedRegionToLargestPossibleRegion();
143 }
144 
145 }
146 #endif

Generated at Sat Feb 2 2013 23:37:18 for Orfeo Toolbox with doxygen 1.8.1.1