# Sinc Interpolation based on FFT

**URL:** <https://discourse.julialang.org/t/sinc-interpolation-based-on-fft/52512>\
**Category:** Signal and Image Processing\
**Tags:** fftw, interpolations, dsp\
**Created:** [December 28, 2020, 1:56pm UTC](https://discourse.julialang.org/t/sinc-interpolation-based-on-fft/52512 "2020-12-28T13:56:28Z")\
**Posts on this page:** 1\
**Showing post:** 27

<div class="post-metadata">

**Author:** ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Post date:** [January 7, 2021, 10:56am UTC](https://discourse.julialang.org/t/sinc-interpolation-based-on-fft/52512/27 "2021-01-07T10:56:53Z")

</div>

I am not sure I got your message correctly.

But for downsampling you might do one of 3 things:

1. Upsample to an integer factor and then decimate.
2. Use the Fourier Series equations.
3. Apply low pass in frequency domain while keeping the symmetry.

If I get you right, you tried 3 (Which is what’s posted as a sample code in my answer).  
I will add to my answer the code for the other 2.

But to answer your questions, let’s say the input has `n` samples and you want to interpolate it to `m < n` samples.

What you can do, as in (1) above is:

```julia
subSampleFctr = floor(numSamples / numSamplesO) + 1;
numSamplesO = subSampleFctr * numSamplesO;

```

The upsample to `numSamplesO` and then decimate by `vX = vX(1:subSampleFctr:numSamplesO);`.

Regarding your code.  
My code supports Complex and Real signals.  
When I know the output should be Real I use `ifft(SincInterpolationDft(fft(vX), numSamplesOutput), 'symmetric');`. Since for real signals the Nyquist sample must be real you can either force specifically that sample or just on the inverse DFT use the symmetric property.  
For the Nyquist sample (The one which I multiply by 0.5) taking only the real part is equivalent to what you did (You added a conjugate term).

The Fourier Series equation, for real signals, allows using half the data with `cos()` instead of complex numbers. Yet it doesn’t have all the optimizations of the `fft()` / `ifft()` so I’m not sure it will be faster.

---

_[View the full topic](https://discourse.julialang.org/t/sinc-interpolation-based-on-fft/52512)._
