int
main(int argc, char * argv[])
{
if (argc != 3)
{
std::cerr << "Usage: " << argv[0] << " input output" << std::endl;
return EXIT_FAILURE;
}
using IOPixelType = unsigned short;
using WorkPixelType = float;
ReaderType::Pointer inputreader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
inputreader->SetFileName(argv[1]);
writer->SetFileName(argv[2]);
ResamplerType::Pointer inputresampler = ResamplerType::New();
inputresampler->SetDefaultPixelValue(0);
inputreader->Update();
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++;
}
worksize[i] = static_cast<IOImageType::SizeValueType>(1)
<< static_cast<IOImageType::SizeValueType>(n + 1);
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());
using ComplexImageType = FFTFilterType::OutputImageType;
invFFTFilterType::Pointer fftoutput = invFFTFilterType::New();
fftoutput->SetInput(
fftinput->GetOutput());
using ResampleOutType =
ResampleOutType::Pointer outputResampler = ResampleOutType::New();
outputResampler->SetDefaultPixelValue(0);
outputResampler->SetSize(inputsize);
outputResampler->SetInput(fftoutput->GetOutput());
writer->SetInput(outputResampler->GetOutput());
writer->Update();
return EXIT_SUCCESS;
}