Image FFT implements the Fourier Transform applied to 2D images, supporting real- and complex-valued inputs. It returns the image representation in the frequency domain. It is useful for content analysis based on signal frequencies, and enables image operations that are more efficiently performed on the frequency domain, among other uses.
Input in space domain | Magnitude spectrum |
---|---|
![]() | ![]() |
The FFT - Fast Fourier Transform is a divide-and-conquer algorithm for efficiently computing discrete Fourier transforms of complex or real-valued data sets in \(O(n \log n)\). It is one of the most important and widely used numerical algorithms in computational physics and general signal processing.
The Discrete Fourier Transform (DFT) generally maps a complex-valued vector \(x_k\) on the space domain into its frequency domain representation given by:
\[ I'[u,v] = \sum^{M-1}_{m=0} \sum^{N-1}_{n=0} I[m,n] e^{-2\pi i (\frac{um}{M}+\frac{vn}{N})} \]
Where:
Note that the \(I'\) is left denormalized as the spectrum is eventually normalized in subsequent stages of the pipeline (if at all).
Depending on image dimension, different techniques are employed for best performance:
In general the smaller the prime factor is, the better the performance, i.e., powers of two are fastest.
Image FFT supports the following transform types:
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_TYPE_2F32 and have the same size. In R2C mode, each input image row \((x_1,x_2,\dots,x_N)\) with type VPI_IMAGE_TYPE_F32 results in an output row \((X_1,X_2,\dots,X_{\lfloor\frac{N}{2}\rfloor+1})\) of non-redundant complex elements with type VPI_IMAGE_TYPE_2F32. In both cases, input and output image heights are the same.
FFT type | input | output | ||
---|---|---|---|---|
type | size | type | size | |
C2C | VPI_IMAGE_TYPE_2F32 | \(W \times H\) | VPI_IMAGE_TYPE_2F32 | \(W \times H\) |
R2C | VPI_IMAGE_TYPE_F32 | \(W \times H\) | VPI_IMAGE_TYPE_2F32 | \(\big( \lfloor\frac{W}{2}\rfloor+1 \big) \times H\) |
For real inputs, the output contains only the non-redundant elements, thus only the left half of spectrum returned. In order to retrieve the whole Hermitian (symmetric-conjugate) output, the right half must be completed so that the following conditions are met:
\begin{align*} F_{\textbf{re}}(u,v) &= F_{\textbf{re}}(-u,-v) \\ F_{\textbf{re}}(-u,v) &= F_{\textbf{re}}(u,-v) \\ F_{\textbf{im}}(u,v) &= -F_{\textbf{im}}(-u,-v) \\ F_{\textbf{im}}(-u,v) &= -F_{\textbf{im}}(u,-v) \end{align*}
The following diagram shows how this is accomplished:
The zero-th element in spectrum output represents the DC (0 Hz) component. Usually for visualization it's preferred that DC is at the center. One way to accomplish this is to shift the 4 quadrants around as shown in the diagram below:
| \(\rightarrow\) |
|
Constraints for specific backends supersede the ones specified for all backends.
For further information on how performance was benchmarked, see Performance Measurement.
size | type | CPU | CUDA | PVA |
---|---|---|---|---|
1920x1080 | R2C | 6.6 ms | 0.7999 ms | n/a |
1920x1080 | C2C | 19.3 ms | 1.2648 ms | n/a |
1024x1024 | R2C | 4.3 ms | 0.1945 ms | n/a |
1024x1024 | C2C | 7.2 ms | 0.4792 ms | n/a |
626x626 | R2C | 33.8 ms | 0.4283 ms | n/a |
626x626 | C2C | 66.8 ms | 0.7824 ms | n/a |
size | type | CPU | CUDA | PVA |
---|---|---|---|---|
1920x1080 | R2C | 17.80 ms | 2.48 ms | n/a |
1920x1080 | C2C | 45.2 ms | 4.18 ms | n/a |
1024x1024 | R2C | 11.12 ms | 0.927 ms | n/a |
1024x1024 | C2C | 39.52 ms | 1.52 ms | n/a |
626x626 | R2C | 73.3 ms | 1.387 ms | n/a |
626x626 | C2C | 144.9 ms | 2.91 ms | n/a |
size | type | CPU | CUDA | PVA |
---|---|---|---|---|
1920x1080 | R2C | 34.5 ms | 5.711 ms | n/a |
1920x1080 | C2C | 74.7 ms | 10.46 ms | n/a |
1024x1024 | R2C | 22.10 ms | 1.871 ms | n/a |
1024x1024 | C2C | 63.3 ms | 3.044 ms | n/a |
626x626 | R2C | 171.3 ms | 3.265 ms | n/a |
626x626 | C2C | 341 ms | 6.268 ms | n/a |