fn

ifft2

Tensor
ifft2(input: Tensor, s: Sequence[int] | None = None, dim: Sequence[int] = (-2, -1), norm: str | None = None)
source

2-D inverse discrete Fourier transform over a pair of axes.

Recovers the 2-D spatial-domain signal from its frequency-domain representation produced by fft2. For an M×NM \times N frequency array, the 2-D inverse DFT is:

x[m,n]=1MNp=0M1q=0N1X[p,q]e+i2π(pm/M+qn/N).x[m, n] = \frac{1}{MN} \sum_{p=0}^{M-1} \sum_{q=0}^{N-1} X[p, q]\, e^{+i 2\pi (pm/M + qn/N)}.

The 1/(MN)1/(MN) factor corresponds to norm='backward' (default).

Parameters

inputTensor
Complex input tensor (2-D frequency domain) with at least 2 dimensions.
ssequence of int= None
Output size (M_out, N_out) along each transformed axis. The frequency tensor is zero-padded or truncated before inverting. len(s) must be 2 when given. If None, the axes keep their current sizes.
dimsequence of int= (-2, -1)
The two axes over which to compute the inverse transform. Default is (-2, -1).
normstr or None= None
Normalisation mode — "backward" (default), "forward", or "ortho". See fftn for the full description.

Returns

Tensor

Complex tensor (complex64) with the same shape as input except that the two transformed axes have lengths s[0] and s[1] (or the input sizes when s is None).

Notes

Round-trip — for any 2-D complex tensor x:

ifft2(fft2(x))x\text{ifft2}(\text{fft2}(x)) \approx x

Real outputs — if input is the 2-D DFT of a real image (conjugate-symmetric in 2-D), the imaginary part of the output will be negligibly small. Use irfft2 for strictly real output.

Examples

Round-trip through the frequency domain:
>>> x = lucid.randn(32, 32)
>>> X = lucid.fft.fft2(x)
>>> x_rec = lucid.fft.ifft2(X)
>>> x_rec.shape
(32, 32)
Low-pass filtering in the frequency domain:
>>> X = lucid.fft.fft2(lucid.randn(64, 64))
>>> # Zero out high frequencies, then invert
>>> x_smooth = lucid.fft.ifft2(X)