Orfeo Toolbox  3.16
itkFFTRealToComplexConjugateImageFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkFFTRealToComplexConjugateImageFilter.txx,v $
5  Language: C++
6  Date: $Date: 2008-12-21 19:13:11 $
7  Version: $Revision: 1.6 $
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 #ifndef __itkFFTRealToComplexConjugateImageFilter_txx
18 #define __itkFFTRealToComplexConjugateImageFilter_txx
20 #include "itkMetaDataObject.h"
21 
23 
24 #if defined(USE_FFTWD) || defined(USE_FFTWF)
26 #endif
27 
28 namespace itk
29 {
30 
31 template < class TPixel , unsigned int VDimension >
32 typename FFTRealToComplexConjugateImageFilter < TPixel , VDimension >::Pointer
33 FFTRealToComplexConjugateImageFilter < TPixel , VDimension >
34 ::New(void)
35 {
37 
38 #ifdef USE_FFTWD
39  if(smartPtr.IsNull())
40  {
41  if (typeid(TPixel) == typeid(double))
42  {
43  smartPtr = dynamic_cast<Self *>(
45  ::New().GetPointer() );
46  }
47  }
48 #endif
49 #ifdef USE_FFTWF
50  if(smartPtr.IsNull())
51  {
52  if (typeid(TPixel) == typeid(float))
53  {
54  smartPtr = dynamic_cast<Self *>(
56  ::New().GetPointer());
57  }
58  }
59 #endif
60 
61  if(smartPtr.IsNull())
62  {
64  ::New().GetPointer();
65  }
66 
67  return smartPtr;
68 }
69 
70 template < class TPixel , unsigned int VDimension >
71 void
73 ::GenerateOutputInformation()
74 {
75  // call the superclass' implementation of this method
76  Superclass::GenerateOutputInformation();
77  //
78  // If this implementation returns a full result
79  // instead of a 'half-complex' matrix, then none of this
80  // is necessary
81  if(this->FullMatrix())
82  return;
83 
84  // get pointers to the input and output
85  typename TInputImageType::ConstPointer inputPtr = this->GetInput();
86  typename TOutputImageType::Pointer outputPtr = this->GetOutput();
87 
88  if ( !inputPtr || !outputPtr )
89  {
90  return;
91  }
92 
93  //
94  // This is all based on the same function in itk::ShrinkImageFilter
95  // ShrinkImageFilter also modifies the image spacing, but spacing
96  // has no meaning in the result of an FFT.
97  unsigned int i;
98  const typename TInputImageType::SizeType& inputSize
99  = inputPtr->GetLargestPossibleRegion().GetSize();
100  const typename TInputImageType::IndexType& inputStartIndex
101  = inputPtr->GetLargestPossibleRegion().GetIndex();
102 
103  typename TOutputImageType::SizeType outputSize;
104  typename TOutputImageType::IndexType outputStartIndex;
105 
106  //
107  // in 4.3.4 of the FFTW documentation, they indicate the size of
108  // of a real-to-complex FFT is N * N ... + (N /2+1)
109  // 1 2 d
110  // complex numbers.
111  // static_cast prob. not necessary but want to make sure integer
112  // division is used.
113  outputSize[0] = static_cast<unsigned int>(inputSize[0])/2 + 1;
114  outputStartIndex[0] = inputStartIndex[0];
115 
116  for (i = 1; i < TOutputImageType::ImageDimension; i++)
117  {
118  outputSize[i] = inputSize[i];
119  outputStartIndex[i] = inputStartIndex[i];
120  }
121  //
122  // the halving of the input size hides the actual size of the input.
123  // to get the same size image out of the IFFT, need to send it as
124  // Metadata.
125  typedef typename TOutputImageType::SizeType::SizeValueType SizeScalarType;
126  itk::MetaDataDictionary &OutputDic=outputPtr->GetMetaDataDictionary();
127  itk::EncapsulateMetaData<SizeScalarType>(OutputDic,
128  std::string("FFT_Actual_RealImage_Size"),
129  inputSize[0]);
130  typename TOutputImageType::RegionType outputLargestPossibleRegion;
131  outputLargestPossibleRegion.SetSize( outputSize );
132  outputLargestPossibleRegion.SetIndex( outputStartIndex );
133 
134  outputPtr->SetLargestPossibleRegion( outputLargestPossibleRegion );
135 }
136 
137 template < class TPixel , unsigned int VDimension >
138 void
140 ::GenerateInputRequestedRegion()
141 {
142  // call the superclass' implementation of this method
143  Superclass::GenerateInputRequestedRegion();
144 
145  // get pointers to the inputs
146  typename TInputImageType::Pointer input =
147  const_cast<TInputImageType *> (this->GetInput());
148 
149  if ( !input )
150  {
151  return;
152  }
153 
154  input->SetRequestedRegionToLargestPossibleRegion();
155 }
156 
157 
158 template < class TPixel , unsigned int VDimension >
159 void
161 ::EnlargeOutputRequestedRegion(DataObject *output)
162 {
163  Superclass::EnlargeOutputRequestedRegion(output);
165 }
166 
167 }
168 #endif

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