~ubuntu-branches/ubuntu/precise/insighttoolkit/precise

« back to all changes in this revision

Viewing changes to Testing/Code/Review/itkFFTComplexToComplexImageFilterTest01.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-12-19 20:16:49 UTC
  • mfrom: (1.2.1 upstream) (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081219201649-drt97guwl2ryt0cn

* New upstream version.
  - patches/nifti-versioning.patch: Remove.  Applied upstream.
  - control:
  - rules: Update version numbers, package names.

* control: Build-depend on uuid-dev (gdcm uses it).

* copyright: Update download URL.

* rules: Adhere to parallel=N in DEB_BUILD_OPTIONS by setting MAKEFLAGS.

* compat: Set to 7.
* control: Update build-dep on debhelper to version >= 7.

* CMakeCache.txt.debian: Set CMAKE_BUILD_TYPE to "RELEASE" so that we
  build with -O3 (not -O2), necessary to optimize the templated code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*=========================================================================
 
2
 
 
3
  Program:   Insight Segmentation & Registration Toolkit
 
4
  Module:    $RCSfile: itkFFTComplexToComplexImageFilterTest01.cxx,v $
 
5
  Language:  C++
 
6
  Date:      $Date: 2008-10-06 15:36:14 $
 
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
 
 
18
#if defined(_MSC_VER)
 
19
#pragma warning ( disable : 4786 )
 
20
#endif
 
21
 
 
22
#ifdef __BORLANDC__
 
23
#define ITK_LEAN_AND_MEAN
 
24
#endif
 
25
 
 
26
/** Example illustrating use of FFTComplexToComplexImageFilter
 
27
 *
 
28
 * \author Simon K. Warfield simon.warfield@childrens.harvard.edu
 
29
 *
 
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.
 
36
 *
 
37
 * Contributed to the Insight Journal paper:
 
38
 * http://insight-journal.org/midas/handle.php?handle=1926/326
 
39
 *
 
40
 */
 
41
 
 
42
#include "itkImage.h"
 
43
#include "itkImageFileReader.h"
 
44
#include "itkImageFileWriter.h"
 
45
#include "itkFFTComplexToComplexImageFilter.h"
 
46
// #include "itkFFTWComplexToComplexImageFilter.h"
 
47
 
 
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
 
51
//will also work.
 
52
#endif
 
53
 
 
54
int itkFFTComplexToComplexImageFilterTest01( int argc, char * argv[] )
 
55
{
 
56
 
 
57
  if( argc < 3 )
 
58
    {
 
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;
 
62
 
 
63
    return EXIT_FAILURE;
 
64
    }
 
65
 
 
66
  const unsigned int                              Dimension = 2;
 
67
  typedef float                                   PixelComponentType;
 
68
  typedef std::complex< PixelComponentType >      PixelType;
 
69
 
 
70
  typedef itk::Image< PixelType,  Dimension >     ImageType;
 
71
  typedef itk::ImageFileReader< ImageType >       ReaderType;
 
72
  typedef itk::ImageFileWriter< ImageType >       WriterType;
 
73
 
 
74
 
 
75
  ReaderType::Pointer reader = ReaderType::New();
 
76
  WriterType::Pointer writer = WriterType::New();
 
77
 
 
78
  reader->SetFileName( argv[1] );
 
79
  writer->SetFileName( argv[2] );
 
80
 
 
81
 
 
82
  //  FFT filter
 
83
  typedef itk::FFTComplexToComplexImageFilter < PixelComponentType, Dimension> FFTFilterType;
 
84
 
 
85
  int Direction = 1;
 
86
 
 
87
  if( argc == 4 )
 
88
    {
 
89
    Direction = atoi(argv[3]);
 
90
    if( Direction != -1 && Direction != 1 )
 
91
      {
 
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;
 
95
      return EXIT_FAILURE;
 
96
      }
 
97
 
 
98
    }
 
99
 
 
100
 
 
101
  FFTFilterType::Pointer fftFilter =    FFTFilterType::New();
 
102
 
 
103
 
 
104
  if( Direction == 1 )
 
105
    {
 
106
    fftFilter->SetTransformDirection( FFTFilterType::DIRECT );
 
107
    }
 
108
  else
 
109
    {
 
110
    fftFilter->SetTransformDirection( FFTFilterType::INVERSE );
 
111
    }
 
112
 
 
113
 
 
114
  fftFilter->SetInput( reader->GetOutput() );
 
115
  writer->SetInput( fftFilter->GetOutput() );
 
116
 
 
117
 
 
118
  try
 
119
    {
 
120
    writer->Update();
 
121
    }
 
122
  catch( itk::ExceptionObject & excp )
 
123
    {
 
124
    std::cerr << excp << std::endl;
 
125
    return EXIT_FAILURE;
 
126
    }
 
127
 
 
128
  return EXIT_SUCCESS;
 
129
 
 
130
}