Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkDftImageFilter.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef __itkDftImageFilter_txx
18 #define __itkDftImageFilter_txx
19 
20 #include <time.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 
24 #include "itkDftImageFilter.h"
25 #include <itkImageRegionConstIterator.h>
26 #include <itkImageRegionConstIteratorWithIndex.h>
27 #include <itkImageRegionIterator.h>
28 
29 #define _USE_MATH_DEFINES
30 #include <math.h>
31 
32 namespace itk {
33 
34 template< class TPixelType >
37 {
38  this->SetNumberOfRequiredInputs( 1 );
39 }
40 
41 template< class TPixelType >
44 {
45 
46 }
47 
48 template< class TPixelType >
50 ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType)
51 {
52  typename OutputImageType::Pointer outputImage = static_cast< OutputImageType * >(this->ProcessObject::GetOutput(0));
53 
54  ImageRegionIterator< OutputImageType > oit(outputImage, outputRegionForThread);
55 
56  typedef ImageRegionConstIterator< InputImageType > InputIteratorType;
57  typename InputImageType::Pointer inputImage = static_cast< InputImageType * >( this->ProcessObject::GetInput(0) );
58 
59  int szx = outputImage->GetLargestPossibleRegion().GetSize(0);
60  int szy = outputImage->GetLargestPossibleRegion().GetSize(1);
61 
62  while( !oit.IsAtEnd() )
63  {
64  double kx = oit.GetIndex()[0];
65  double ky = oit.GetIndex()[1];
66 // kx -= (double)szx/2;
67 // ky -= (double)szy/2;
68 
69  if ((int)szx%2==1)
70  kx -= (szx-1)/2;
71  else
72  kx -= szx/2;
73  if ((int)szy%2==1)
74  ky -= (szy-1)/2;
75  else
76  ky -= szy/2;
77 
78 // if( kx < szx/2 )
79 // kx = kx + szx/2;
80 // else
81 // kx = kx - szx/2;
82 
83 // if( ky < szy/2 )
84 // ky = ky + szy/2;
85 // else
86 // ky = ky - szy/2;
87 
88  vcl_complex<double> s(0,0);
89  InputIteratorType it(inputImage, inputImage->GetLargestPossibleRegion() );
90  while( !it.IsAtEnd() )
91  {
92  int x = it.GetIndex()[0];
93  int y = it.GetIndex()[1];
94 // x -= (double)szx/2;
95 // y -= (double)szy/2;
96 
97  if ((int)szx%2==1)
98  x -= (szx-1)/2;
99  else
100  x -= szx/2;
101  if ((int)szy%2==1)
102  y -= (szy-1)/2;
103  else
104  y -= szy/2;
105 
106  vcl_complex<double> f(it.Get().real(), it.Get().imag());
107 
108  s += f * exp( std::complex<double>(0, -2 * M_PI * (kx*(double)x/szx + ky*(double)y/szy) ) );
109 
110  ++it;
111  }
112 
113  oit.Set(s);
114  ++oit;
115  }
116 }
117 
118 }
119 #endif
itk::SmartPointer< Self > Pointer
Superclass::OutputImageType OutputImageType
Superclass::OutputImageRegionType OutputImageRegionType
Image class for storing images.
Definition: mitkImage.h:76
const RegionType & GetLargestPossibleRegion() const
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId)