# Consistent FFT Output

Cory Quammen
2011-09-27
Made output and expected input of FFT filters consistent The ForwardFFTImageFilter's output was different depending on whether FFTW was enabled. If FFTW was enabled, the output consisted of only the non-redundant half of the full complex transformed image. If it was not enabled, the output consisted of the full complex transformed image. This change makes the output of ForwardFFTImageFilter always consist of the full complex image, and the InverseFFTImageFilter expects its input to be the full complex image.

In addition, the API has changed for the forward and inverse FFT filters. Because the full complex image is produced, the method FullMatrix() has been removed from both ForwardFFTImageFilter and InverseFFTImageFilter. The methods ActualXDimensionIsOdd(), SetActualXDimensionIsOdd(), SetActualXDimensionIsOddOff(), and SetActualXDimensionIsOddOn() have been removed from InverseFFTImageFilter.

For access to FFT filters optimized for real inputs, two new filters have been added: RealToHalfHermitianForwardFFTImageFilter and HalfHermitianToRealInverseFFTImageFilter. RealToHalfHermitianForwardFFTImageFilter produces the non-redundant half complex image that used to be produced by ForwardFFTImageFilter when FFTW was enabled, and HalfHermitianToRealInverseFFTImageFilter expects that format as input.
// This assumes that FFTW is not enabled. typedef FFTFilterType::OutputImageType ComplexImageType; complexWriter->SetInput( fftFilter->GetOutput() ); realFilter->SetInput( fftFilter->GetOutput() ); imaginaryFilter->SetInput( fftFilter->GetOutput() );
// It doesn't matter if FFTW is enabled or not. typedef FFTFilterType::OutputImageType ComplexImageType; complexWriter->SetInput( fftFilter->GetOutput() ); realFilter->SetInput( fftFilter->GetOutput() ); imaginaryFilter->SetInput( fftFilter->GetOutput() );
// This assumes that FFTW was enabled typedef itk::ForwardFFTImageFilter< InputImageType > FFTFilterType; typedef itk::InverseFFTImageFilter< InputImageType > IFFTFilterType; FFTFilterType::Pointer fft = FFTFilterType::New(); fft->SetInput( ... );

// Do some processing on the half complex frequency image. frequencyImageFilter->SetInput( fft->GetOutput() );

IFFTFilterType::Pointer ifft = IFFTFilterType::New(); ifft->SetActualXDimensionIsOdd( true ); bool isOdd = ifft->ActualXDimensionIsOdd(); ifft->SetInput( frequencyImageFilter->GetOutput() );
// It doesn't matter whether FFTW is enabled or not. typedef itk::RealToHalfHermitianForwardFFTImageFilter< InputImageType > FFTFilterType; typedef itk::HalfHermitianToRealInverseFFTImageFilter< InputImageType > IFFTFilterType; FFTFilterType::Pointer fft = FFTFilterType::New(); fft->SetInput( ... );

// Do some processing on the half complex frequency image. frequencyImageFilter->SetInput( fft->GetOutput() );

IFFTFilterType::Pointer ifft = IFFTFilterType::New(); ifft->SetActualXDimensionIsOdd( true ); bool isOdd = ifft->ActualXDimensionIsOdd(); ifft->SetInput( frequencyImageFilter->GetOutput() );
// This assumes that FFTW was not enabled typedef itk::ForwardFFTImageFilter< InputImageType > FFTFilterType; typedef itk::InverseFFTImageFilter< InputImageType > IFFTFilterType; FFTFilterType::Pointer fft = FFTFilterType::New(); fft->SetInput( ... );

// Do some processing on the half complex frequency image. frequencyImageFilter->SetInput( fft->GetOutput() );

IFFTFilterType::Pointer ifft = IFFTFilterType::New(); ifft->SetInput( frequencyImageFilter->GetOutput() );
// No change required
I645fe0fd39f5c2811e4a89987b589cf6d576e379
Documentation/Migration/ConsistentFFTOutput.xml Modules/Filtering/FFT/include/itkFFTWForwardFFTImageFilter.h Modules/Filtering/FFT/include/itkFFTWForwardFFTImageFilter.hxx Modules/Filtering/FFT/include/itkFFTWHalfHermitianToRealInverseFFTImageFilter.h Modules/Filtering/FFT/include/itkFFTWHalfHermitianToRealInverseFFTImageFilter.hxx Modules/Filtering/FFT/include/itkFFTWInverseFFTImageFilter.h Modules/Filtering/FFT/include/itkFFTWInverseFFTImageFilter.hxx Modules/Filtering/FFT/include/itkFFTWRealToHalfHermitianForwardFFTImageFilter.h Modules/Filtering/FFT/include/itkFFTWRealToHalfHermitianForwardFFTImageFilter.hxx Modules/Filtering/FFT/include/itkForwardFFTImageFilter.h Modules/Filtering/FFT/include/itkForwardFFTImageFilter.hxx Modules/Filtering/FFT/include/itkFullToHalfHermitianImageFilter.h Modules/Filtering/FFT/include/itkFullToHalfHermitianImageFilter.hxx Modules/Filtering/FFT/include/itkHalfHermitianToRealInverseFFTImageFilter.h Modules/Filtering/FFT/include/itkHalfHermitianToRealInverseFFTImageFilter.hxx Modules/Filtering/FFT/include/itkHalfToFullHermitianImageFilter.h Modules/Filtering/FFT/include/itkHalfToFullHermitianImageFilter.hxx Modules/Filtering/FFT/include/itkInverseFFTImageFilter.h Modules/Filtering/FFT/include/itkInverseFFTImageFilter.hxx Modules/Filtering/FFT/include/itkRealToHalfHermitianForwardFFTImageFilter.h Modules/Filtering/FFT/include/itkRealToHalfHermitianForwardFFTImageFilter.hxx Modules/Filtering/FFT/include/itkVnlFFTCommon.h Modules/Filtering/FFT/include/itkVnlFFTCommon.hxx Modules/Filtering/FFT/include/itkVnlForwardFFTImageFilter.h Modules/Filtering/FFT/include/itkVnlForwardFFTImageFilter.hxx Modules/Filtering/FFT/include/itkVnlHalfHermitianToRealInverseFFTImageFilter.h Modules/Filtering/FFT/include/itkVnlHalfHermitianToRealInverseFFTImageFilter.hxx Modules/Filtering/FFT/include/itkVnlInverseFFTImageFilter.h Modules/Filtering/FFT/include/itkVnlInverseFFTImageFilter.hxx Modules/Filtering/FFT/include/itkVnlRealToHalfHermitianForwardFFTImageFilter.h Modules/Filtering/FFT/include/itkVnlRealToHalfHermitianForwardFFTImageFilter.hxx Modules/Filtering/FFT/test/CMakeLists.txt Modules/Filtering/FFT/test/itkFFTTest.h Modules/Filtering/FFT/test/itkFFTWD_FFTTest.cxx Modules/Filtering/FFT/test/itkFFTWD_RealFFTTest.cxx Modules/Filtering/FFT/test/itkFFTWF_FFTTest.cxx Modules/Filtering/FFT/test/itkFFTWF_RealFFTTest.cxx Modules/Filtering/FFT/test/itkFullToHalfHermitianImageFilterTest.cxx Modules/Filtering/FFT/test/itkHalfToFullHermitianImageFilterTest.cxx Modules/Filtering/FFT/test/itkRealFFTTest.h Modules/Filtering/FFT/test/itkVnlFFTTest.cxx Modules/Filtering/FFT/test/itkVnlFFTWD_RealFFTTest.cxx Modules/Filtering/FFT/test/itkVnlFFTWF_FFTTest.cxx Modules/Filtering/FFT/test/itkVnlFFTWF_RealFFTTest.cxx Modules/Filtering/FFT/test/itkVnlRealFFTTest.cxx