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