I am using sitk::ForwardFFT in C++ to apply 1D FFT on each row or column on a 2D image. However, I found the processing speed is quite slow even using buffer operations.
Is there any built-in function in SimpleITK to apply 1D FFT or can anyone advise to speed up the 1D FFD procedure?
Not specific to FFT, is your build in release mode or could it be that it is in debug mode? The issue with speed and build type has happened to others in the past.
Thanks for pointing this out. I try to use “Forward1DFFTImageFilter”. However, the image seems not changed after apply fft then modulus. Where the input (imageIn) is sitk 2D image (float32).
using PixelType = float;
constexpr unsigned int Dimension = 2;
using ImageType = itk::Image<PixelType, Dimension>;
using ComplexImageType = itk::Image<std::complex<float>, Dimension>;
ImageType::Pointer itkImage = dynamic_cast<ImageType*>(imageIn.GetITKBase());
using FFTFilterType = itk::Forward1DFFTImageFilter<ImageType, ComplexImageType>;
FFTFilterType::Pointer fftFilter = FFTFilterType::New();
fftFilter->SetInput(itkImage);
fftFilter->SetDirection(1);
fftFilter->Update();
using ModulusFilterType = itk::ComplexToModulusImageFilter<ComplexImageType, ImageType>;
ModulusFilterType::Pointer modulusFilter = ModulusFilterType::New();
modulusFilter->SetInput(fftFilter->GetOutput());
modulusFilter->Update();
sitk::Image modulusImage = sitk::Image(modulusFilter->GetOutput());
Thanks. The Release mode is significant faster than debug mode using my old codes. But using built-in method “Forward1DFFTImageFilter” from ITK probably can further speed it up. Do you have any idea why the example codes posted here does not working (the output modulusImage is still the original image)?
For posterity, can you share the approximate speedup you got from using Release mode instead of Debug, and from Forward1DFFTImageFilter over regular ForwardFFT?