int main( int argc, char * argv [] )
{
if( argc < 5 )
{
std::cerr << "Usage: " << argv[0] << " inputScalarImage outputRealPartOfComplexImage outputRealImaginaryPartOfComplexImage outputComplex" << std::endl;
}
typedef float PixelType;
FFTFilterType::Pointer fftFilter = FFTFilterType::New();
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( argv[1] );
fftFilter->SetInput( reader->GetOutput() );
try
{
fftFilter->Update();
}
{
std::cerr << "Error: " << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
typedef FFTFilterType::OutputImageType ComplexImageType;
ComplexWriterType::Pointer complexWriter = ComplexWriterType::New();
complexWriter->SetFileName( argv[4] );
complexWriter->SetInput( fftFilter->GetOutput() );
try
{
complexWriter->Update();
}
{
std::cerr << "Error: " << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
ComplexImageType, ImageType > RealFilterType;
RealFilterType::Pointer realFilter = RealFilterType::New();
realFilter->SetInput( fftFilter->GetOutput() );
typedef unsigned char WritePixelType;
ImageType,
WriteImageType > RescaleFilterType;
RescaleFilterType::Pointer intensityRescaler = RescaleFilterType::New();
intensityRescaler->SetInput( realFilter->GetOutput() );
intensityRescaler->SetOutputMinimum( 0 );
intensityRescaler->SetOutputMaximum( 255 );
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( argv[2] );
writer->SetInput( intensityRescaler->GetOutput() );
try
{
writer->Update();
}
{
std::cerr << "Error writing the real image: " << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
typedef FFTFilterType::OutputImageType ComplexImageType;
ComplexImageType, ImageType > ImaginaryFilterType;
ImaginaryFilterType::Pointer imaginaryFilter = ImaginaryFilterType::New();
imaginaryFilter->SetInput( fftFilter->GetOutput() );
intensityRescaler->SetInput( imaginaryFilter->GetOutput() );
writer->SetFileName( argv[3] );
try
{
writer->Update();
}
{
std::cerr << "Error writing the imaginary image: " << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
ComplexReaderType::Pointer complexReader = ComplexReaderType::New();
complexReader->SetFileName( argv[4] );
complexReader->Update();
complexReader->GetImageIO()->GetPixelTypeAsString(
complexReader->GetImageIO()->GetPixelType() );
return EXIT_SUCCESS;
}