3
$\begingroup$

I'm seeing ripple in the time domain when resampling a "unity signal", that is, all ones, with lanczos filters. The ripple/error exactly resembles a cosine with a period of the sampling rate - ie. the error is largest at a fractionate sample offset of 0.5. Using larger $a$ for the lanczos kernel reduces the error, but it never ceases to exist.

  1. Is this supposed to happen, or am I making an implementation error somewhere? Doing the convolution by hand shows that the terms never sum up to 1 (unless at offset = 0). Truncated sinc shows the same problem.
  2. Are there any windowed sinc filters that do not exhibit this kind of error? Otherwise, any other suggestions for resampling techniques? I'm generally looking for something that offers the performance of a lanczos kernel with $a$ > 10.

Edit: Thanks for the comments. I'll elaborate a little on what I want: So I'm interpolating a waveform display. What's important and interesting is, that the interpolation passes through the original sample points and resembles the 'true' shape of the signal as much as possible. This means this is good:

enter image description here

So under- and overshoot is not a problem in itself (technically, it's the whole point). This, however, is (note this is just a DC signal) - ie. nothing in the signal provokes the ringing, it is just an artifact depending on your fractionate interpolation offset:

enter image description here

$\endgroup$
5
  • $\begingroup$ Hi Shaggi- The ringing can be difficult to avoid with any oscillating kernal with negative components. Not knowing enough to specifically give a clear answer below, but reducing ringing in the time domain is usually at the expense of frequency domain performance- that said have you considered using a Gaussian function as the kernal? It does not go negative nor has any oscillations so will not cause any ringing in your interpolation (although will have more errors at your known sample points (for images for example this will cause the well known "Gaussian blur"). May be worth trying? $\endgroup$ Commented Feb 23, 2017 at 3:13
  • $\begingroup$ Also related to my previous comment, if you do end up using a Gaussian filter (and perhaps others that have more experience with this for interpolation specifically can comment on its merits or otherwise), please see my other post on how to implement such a filter with no multipliers: dsp.stackexchange.com/questions/31483/… $\endgroup$ Commented Feb 23, 2017 at 3:14
  • $\begingroup$ Also I believe if you can use a=2 for the Lanczos you will have no ringing (only oveshoot) since it only goes negative, unlike higher values for a which go negative and then positive again (causing ringing). $\endgroup$ Commented Feb 23, 2017 at 3:22
  • $\begingroup$ The window is only a smooth truncation, the underlying impulse response is still a sinc, which oscillates around zero, so I would expect the majority of FIRs to have some sort of oscillations and/or under-/over-shoots. If you use filters with Gaussian impulse response (such as @DanBoschen's suggestion), you will get zero overshoot at the cost of poor frequency domain behaviour. Alasw, it's an age old problem: what matters most to you, frequency or time domain. $\endgroup$ Commented Feb 23, 2017 at 7:48
  • $\begingroup$ Hi, thanks for the thoughts. As I've explained in the edit, the ringing is actually needed but the interpolation artifacts in the second picture isn't. $\endgroup$
    – Shaggi
    Commented Feb 23, 2017 at 13:30

2 Answers 2

2
$\begingroup$

Illustration of the problem
Figure 1. Illustration of the problem with Lanczos2 interpolation: The sum of the four time-shifted Lanczos-window multiplied sinc functions (red) do not sum (black) to unity in the middle between horizontal coordinates 1 and 2.

A simple fix would be to distribute one fourth of the deviation from unity as function of the fractional position in the middle interval, with negative sign, to each quadrant of the Lanczos2 kernel. The equations are lengthy, but this is all very easily done numerically. The difference to the original Lanczos2 kernel is small:

Comparison of Lanczos2 kernel and fixed Lanczos2 kernel
Figure 2. Lanczos2 kernel (blue) and fixed Lanczos2 kernel (red).

enter image description here
Figure 3. Fixed Lanczos2 kernels (red) sum to unity (black).

The magnitude frequency response from the fixed Lanczos2 kernel looks just fine compared to the original, by some measures even better:

enter image description here
Figure 4. Magnitude frequency response of Lanczos2 interpolation (blue) and the same with the fixed kernel (red).

A similar fix could be tried on larger Lanczos kernels. I tested it on Lanczos3 and saw no problems.

$\endgroup$
1
  • 1
    $\begingroup$ Very interesting approach. The spectrum almost looks like a 2-lobe optimized Minimum Side Lobe Level (MSLL) window function except no explicit optimizations have been done. $\endgroup$ Commented Jan 29, 2018 at 15:08
1
$\begingroup$
  1. It's supposed to happen. A WolframAlpha simulation of the piecewise addition of Lanczos3 shows it doesn't have a flat top. It's not a cosine either, it's the part of this graph between -1 and 1 that gets repeated. (Zoom).

A crude workaround is to normalize the signal before resampling and afterwards add back the DC (or whatever curve you subtracted from the signal).

  1. For example, cubic resampling (often confused with Bicubic, which only applies to 2D data, i.e. images) adds to unity. A simulation of the piecewise addition shows a nice straight line at unity and even the (infinite on the x-axis) symbolic simplification results in just "1".

I'm also in search for other (more frequency-conserving) curves that add to unity when I stumbled on your question.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.