[Insight-users] FFT in 3D not working?
mhg at unizar.es
mhg at unizar.es
Wed Aug 2 06:44:38 EDT 2006
Dear Insight users,
I am trying to use the class itkVnlFFTRealToComplexConjugateImageFilter.h
to get the fft transform of a 3D image. I wrote the code presented avobe
using itk version 2.01 to write the real part of the Fourier transform
of a 3D image. I tested my code with a second order derivative kernel
of 64 x 64 x 64. In the following direction I posted the results:
http://webmail.unizar.es/DescargarFicheros.php?id0=1157193166.php3NXuyp&idn0=real1.vtk&id1=1157193166.php5tbxOn&idn1=real2.vtk&
where real1.vtk is the file with the itk computed result and real2.vtk is the
file computed with the fft implemented in vtk. Looking at these results
you can
appreciate that the image computed with the itk code is not correct.
Maybe there is an error in my code or maybe you already fixed this bug
in latest
releases of itk. I would appreciate if any of you can tell me what is
the reason
why my code is not working.
Best, Monica.
#include "itkVnlFFTRealToComplexConjugateImageFilter.h"
#include "itkFFTWRealToComplexConjugateImageFilter.h"
#include "itkComplexToRealImageFilter.h"
#include "itkComplexToImaginaryImageFilter.h"
using namespace std;
typedef FloatPixelType PixelType;
typedef FloatImageType ImageType;
typedef FloatIteratorType IteratorType;
typedef FloatNeighborhoodIteratorType NeighborhoodIteratorType;
typedef FloatNumericTraits NumericTraits;
typedef itk::VnlFFTRealToComplexConjugateImageFilter< PixelType, 3 >
FFTFilterType;
typedef FFTFilterType::OutputImageType ComplexImageType;
typedef itk::ComplexToRealImageFilter< ComplexImageType, ImageType >
RealFilterType;
typedef itk::ComplexToImaginaryImageFilter< ComplexImageType, ImageType >
ImaginaryFilterType;
typedef FloatReaderType ReaderType;
typedef FloatWriterType WriterType;
void usage()
{
cerr << "Usage: fftDemo [input] [output]" << endl;
exit(1);
}
int main( int argc, char **argv )
{
if( argc < 3 )
usage();
char *input_name = NULL, *output_name = NULL;
input_name = argv[1];
argc--;
argv++;
output_name = argv[1];
argc--;
argv++;
// Reading the images
ReaderType::Pointer sourceR = ReaderType::New();
sourceR->SetFileName( input_name );
sourceR->Update();
FFTFilterType::Pointer fft = FFTFilterType::New();
fft->SetInput( sourceR->GetOutput() );
try
{
fft->Update();
}
catch( itk::ExceptionObject & excp )
{
std::cerr << "Error: " << std::endl;
std::cerr << excp << std::endl;
}
RealFilterType::Pointer realFilter = RealFilterType::New();
realFilter->SetInput( fft->GetOutput() );
realFilter->Update();
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( output_name );
writer->SetInput( realFilter->GetOutput() );
writer->Update();
return 0;
}
More information about the Insight-users
mailing list