Inverse FFT implements the inverse Fourier Transform for 2D images, supporting real- and complex-valued outputs. Given a 2D spectrum (frequency domain), it returns the image representation on the spatial domain. It is the exact inverse of FFT algorithm.
Input as a magnitude spectrum
Output in spatial domain
Implementation
The inverse Fast Fourier Transform follows closely forward FFT's implementation, except for the sign of the exponent, which is positive here.
The normalization factor \(\frac{1}{MN}\) is applied by default to make IFFT an exact inverse of FFT. As this incurs in a performance hit and normalization might not be needed, user can pass the flag VPI_DENORMALIZED_OUTPUT to vpiSubmitIFFT to indicate that output must be left denormalized.
As with direct FFT, depending on \(N\), different techniques are employed for best performance:
CPU backend
Fast paths when \(N\) can be factored into \(2^a \times 3^b \times 5^c\)
CUDA backend
Fast paths when \(N\) can be factored into \(2^a \times 3^b \times 5^c \times 7^d\)
In general the smaller the prime factor is, the better the performance, i.e., powers of two are fastest.
IFFT supports the following transform types:
complex-to-complex, C2C
complex-to-real, C2R.
Data Layout
Data layout depends strictly on the transform type. In case of general C2C transform, both input and output data shall be of type VPI_IMAGE_FORMAT_2F32 and have the same size. In C2R mode, each input image row \((X_1,X_2,\dots,X_{\lfloor\frac{N}{2}\rfloor+1})\) of type VPI_IMAGE_FORMAT_2F32 containing only non-redundant values results in row \((x_1,x_2,\dots,x_N)\) with type VPI_IMAGE_FORMAT_F32 representing the whole image. In both cases, input and output image heights are the same.
Usage
Language:
Import VPI module
import vpi
Run the C2R IFFT on a VPI image input with spectrum data in vpi.Format._2F32 format. The resulting VPI image has vpi.Format.F32 format. Operation is executed by the CUDA backend.
with vpi.Backend.CUDA:
output = input.irfft()
Initialization phase
Include the header that defines the inverse FFT functions.
Declares functions that implement the Fast Fourier Transform algorithm and its inverse.
Define the input spectrum image. Since we're performing a C2R IFFT, the input width must be \(\lfloor \frac{w}{2} \rfloor+1\), where \(w\) is the output image width. Input and output heights must match. Image format must be VPI_IMAGE_FORMAT_2F32.
Create the output image. Again, because of C2F IFFT, the output type must be VPI_IMAGE_FORMAT_F32. We're passing 0 as flags to make the function return a normalized output.
Submit the IFFT algorithm to the stream, passing the input spectrum and the output buffer. It'll be executed on the CUDA backend, since the payload is created there.