mr2.utils.filters.fft_filters

mr2.utils.filters.fft_filters(kernel_size: tuple[int, ...], dtype: dtype = torch.complex64) → Tensor[source]

Create the complex Fourier modes of an N-dimensional patch.

For spatial shape \((s_1,\ldots,s_d)\) and \(N=\prod_j s_j\), the filter indexed by \((k_1,\ldots,k_d)\) is

\[h_{k_1,\ldots,k_d}[m_1,\ldots,m_d] = N^{-1/2}\exp\!\left(2\pi\mathrm{i}\sum_{j=1}^d \frac{k_jm_j}{s_j}\right).\]

These are positive-exponent (inverse-DFT) modes. Their Hermitian inner products with a patch give its orthonormal forward-DFT coefficients. Frequency indices use FFT order, with the last axis varying fastest; the first filter is constant. Spatial indices start at zero, without shifting.

Parameters:
  • kernel_size (tuple[int, ...]) – Spatial shape of the Fourier filters, e.g. (7, 7) or (5, 7, 9).

  • dtype (dtype, default: torch.complex64) – Complex data type of the filters.

Returns:

Fourier basis filters of shape (prod(kernel_size), *kernel_size).