# [Numpy-discussion] Interpolation via Fourier transform

Anne Archibald peridot.faceted@gmail....
Thu Mar 5 14:06:56 CST 2009

```2009/3/5 M Trumpis <mtrumpis@berkeley.edu>:
> Hi Nadav.. if you want a lower resolution 2d function with the same
> field of view (or whatever term is appropriate to your case), then in
> principle you can truncate your higher frequencies and do this:
>
> sig = ifft2_func(sig[N/2 - M/2:N/2 + M/2, N/2 - M/2:N/2+M/2])
>
> I like to use an fft that transforms from an array indexing
> negative-to-positive freqs to an array that indexes
> negative-to-positive spatial points, so in both spaces, the origin is
> at (N/2,N/2). Then the expression works as-is.
>
> The problem is if you've got different indexing in one or both spaces
> (typically positive frequencies followed by negative) you can play
> around with a change of variables in your DFT in one or both spaces.
> If the DFT is defined as a computing frequencies from 0,N, then
> putting in n' = n-N/2  leads to a term like exp(1j*pi*q) that
> multiplies f[q]. Here's a toy example:
>
> a = np.cos(2*np.pi*5*np.arange(64)/64.)
>
> P.plot(np.fft.fft(a).real)
>
> P.plot(np.fft.fft(np.power(-1,np.arange(64))*a).real)
>
> The second one is centered about index N/2
>
> Similarly, if you need to change the limits of the summation of the
> DFT from 0,N to -N/2,N/2, then you can multiply exp(1j*pi*n) to the
> outside of the summation.
>
> Like I said, easy enough in principle!

There's also the hit-it-with-a-hammer approach: Just downsample in x
then in y, using the one-dimensional transforms.

Anne
```