int main( int argc, char * argv[] )
{
if( argc != 3 )
{
std::cerr << "Usage: " << argv[0] << " input output" << std::endl;
return EXIT_FAILURE;
}
const unsigned int Dimension = 2;
typedef unsigned short IOPixelType;
typedef float WorkPixelType;
ReaderType::Pointer inputreader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
inputreader->SetFileName( argv[1] );
writer->SetFileName( argv[2] );
IOImageType,
WorkImageType > ResamplerType;
ResamplerType::Pointer inputresampler = ResamplerType::New();
inputresampler->SetDefaultPixelValue(0);
inputreader->Update();
IOImageType::SizeType inputsize;
IOImageType::SizeType worksize;
inputsize = inputreader->GetOutput()->GetLargestPossibleRegion().GetSize();
for( unsigned int i=0; i < 2; i++ )
{
unsigned int n=0;
worksize[i] = inputsize[i];
while( worksize[i] >>= 1 )
{
n++;
}
std::cout << "inputsize[" << i << "]=" << inputsize[i] << std::endl;
std::cout << "worksize[" << i << "]=" << worksize[i] << std::endl;
}
inputresampler->SetSize( worksize );
inputresampler->SetInput( inputreader->GetOutput() );
FFTFilterType::Pointer fftinput = FFTFilterType::New();
fftinput->SetInput( inputresampler->GetOutput() );
typedef FFTFilterType::OutputImageType ComplexImageType;
invFFTFilterType::Pointer fftoutput = invFFTFilterType::New();
fftoutput->SetInput(fftinput->GetOutput());
ResampleOutType::Pointer outputResampler = ResampleOutType::New();
outputResampler->SetDefaultPixelValue( 0 );
outputResampler->SetSize( inputsize );
outputResampler->SetInput( fftoutput->GetOutput() );
writer->SetInput(outputResampler->GetOutput());
writer->Update();
return EXIT_SUCCESS;
}