1
/*=========================================================================
3
Program: Insight Segmentation & Registration Toolkit
4
Module: $RCSfile: itkFFTComplexToComplexImageFilterTest01.cxx,v $
6
Date: $Date: 2008-10-06 15:36:14 $
7
Version: $Revision: 1.5 $
9
Copyright (c) Insight Software Consortium. All rights reserved.
10
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
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.
16
=========================================================================*/
19
#pragma warning ( disable : 4786 )
23
#define ITK_LEAN_AND_MEAN
26
/** Example illustrating use of FFTComplexToComplexImageFilter
28
* \author Simon K. Warfield simon.warfield@childrens.harvard.edu
30
* \note Attribution Notice. This research work was made possible by Grant
31
* Number R01 RR021885 (PI Simon K. Warfield, Ph.D.) from
32
* the National Center for Research Resources (NCRR), a component of the
33
* National Institutes of Health (NIH). Its contents are solely the
34
* responsibility of the authors and do not necessarily represent the
35
* official view of NCRR or NIH.
37
* Contributed to the Insight Journal paper:
38
* http://insight-journal.org/midas/handle.php?handle=1926/326
43
#include "itkImageFileReader.h"
44
#include "itkImageFileWriter.h"
45
#include "itkFFTComplexToComplexImageFilter.h"
46
// #include "itkFFTWComplexToComplexImageFilter.h"
48
#if !defined(USE_FFTWF)
49
//#error "This example only works when single precision FFTW is used"
50
//Changing WorkPixeltype to double and changing this conditional to USE_FFTWD
54
int itkFFTComplexToComplexImageFilterTest01( int argc, char * argv[] )
59
std::cerr << "Usage: " << argv[0] << " input output [dir]" << std::endl;
60
std::cerr << " " "dir: -1 for forward" << std::endl;
61
std::cerr << " " "dir: 1 for backward" << std::endl;
66
const unsigned int Dimension = 2;
67
typedef float PixelComponentType;
68
typedef std::complex< PixelComponentType > PixelType;
70
typedef itk::Image< PixelType, Dimension > ImageType;
71
typedef itk::ImageFileReader< ImageType > ReaderType;
72
typedef itk::ImageFileWriter< ImageType > WriterType;
75
ReaderType::Pointer reader = ReaderType::New();
76
WriterType::Pointer writer = WriterType::New();
78
reader->SetFileName( argv[1] );
79
writer->SetFileName( argv[2] );
83
typedef itk::FFTComplexToComplexImageFilter < PixelComponentType, Dimension> FFTFilterType;
89
Direction = atoi(argv[3]);
90
if( Direction != -1 && Direction != 1 )
92
std::cerr << "Usage: " << argv[0] << " input output [dir]" << std::endl;
93
std::cerr << " " "dir: -1 for forward transform" << std::endl;
94
std::cerr << " " "dir: 1 for backward transform" << std::endl;
101
FFTFilterType::Pointer fftFilter = FFTFilterType::New();
106
fftFilter->SetTransformDirection( FFTFilterType::DIRECT );
110
fftFilter->SetTransformDirection( FFTFilterType::INVERSE );
114
fftFilter->SetInput( reader->GetOutput() );
115
writer->SetInput( fftFilter->GetOutput() );
122
catch( itk::ExceptionObject & excp )
124
std::cerr << excp << std::endl;