# Is adding a mean point between every two points a valid way of upsampling?

Suppose we need to double the sampling rate of an audio signal.

Is adding a mean point between every two points a valid way of upsampling? If no, then why not?

For example, in images, pixels may be interpolated by averaging the extremes. Similarly, I imagine that in an audio signal, upsampling may be possible by averaging the extreme points.

Is this method completely absurd? Or is there some merit in it in some cases?

– Peter K.
Mar 15 at 15:13
• @PeterK. I recommended they open a new one since I think the edit significantly changed the question and made it a different one (see revision history) - though the old one should be rolled back to not make it a dupe Mar 15 at 15:18
• I think this is a decent questions. Answer: it's a method that will sort of work, but it's not very good as it produces a fair bit of aliasing. The error between the result and the "correct" upsampled signal can be quite large. It's not completely absurd either. Mar 15 at 15:33
• @Ratesh Singh: Are you familiar with the sampling theorem, the relationship between discretization vs. periodicity and aliasing? If not, I would suggest reading up on these first, otherwise you will have a lot of trouble getting your arms around upsampling. Mar 15 at 15:36
• To echo @Hilmar’s comments, this is a similar question to yours (although it’s about decimation, not interpolation, they share some commonalities), hopefully that helps.
– Jdip
Mar 15 at 16:02

I will first summarize the frequency domain view of the interpolation process in general. This will then be used to provide a quantitative result of the distortion when interpolating using linear interpolation as the OP is suggesting, as well as the case of just holding the current value to create the new sample (zero-order hold).

Interpolation by $$I$$ is commonly done by inserting $$I-1$$ zeros between the existing samples (called “Upsampling”) and then following that with an interpolation filter which serves to grow those zeros to the correct value to complete the interpolation. This assumes the original samples provided are samples of a waveform with its frequency content fully in the first Nyquist zone (between $$\pm f_s/2$$ where $$f_s$$ represents the sampling rate of the input prior to upsampling).

The process of inserting zeros increases the sampling rate but results in spectral images which need to be filtered out to avoid distortion in the result. These images will be the original spectrum replicated at every multiple of the original sampling rate.

For example, if we had an original sampling rate of 100 KHz the first Nyquist zone is $$\pm 50$$ KHz. If we wanted to increase the sampling rate by 4 and did that by inserting three zeros between every sample the first Nyquist zone of the output would be $$\pm 200$$ KHz. Within that there would be images of the original spectrum (perfect copies) centered at $$\pm 100$$ KHz and $$\pm 200$$ KHz. (With half the spectrum up to $$200$$ KHz and the other half down to $$-200$$ KHz if we restrict ourselves to observing the first Nyquist zone).

A “perfect” interpolation filter would pass the original spectrum with no distortion and completely reject the higher frequency images. Perfect is not realizable, but by trading filter complexity we can, at the expense of delay, reduce the distortion to be below any level of concern.

With that we can quantify specifically what occurs in simple interpolation by two approaches such a zero-order hold (hold the current sample to create the interpolated sample) and as the OP is doing, linear interpolation. Both techniques can be viewed as simple implementations of the interpolation filter. Being simple, they will also be very poor at rejecting the interpolation image that exists at Nyquist of the output sample rate (centered at $$\pm f_s$$ where $$f_s$$ is the input sample rate).

The zero-order hold as a filter has an impulse response of $$h[n]= \frac{1}{2}(\delta[n]+\delta[n-1])$$: (the output sample is the average of the current sample (in this case a zero after the zero-insert) and previous sample, so results in inserting the last input sample in between each input. The coefficients of the equivalent FIR filter construction would be $$[0.5, 0.5]$$. The transfer function of this is a (terrible) lowpass filter given as: $$H(z)= \frac{1+ z^{-1}}{2}$$

which has the following frequency response:

$$H(e^{j\omega})=\frac{1+ e^{j\omega}}{2}$$

$$= e^{-j\omega}\cos(\omega)$$

Where $$\omega = 4\pi f_s$$ with $$f_s$$ as the sampling rate of the input.

Thus we see the interpolation filter in this case has a magnitude that goes as a cosine function, passing DC and reducing to zero right at the center of the spectral image of the equivalent “zero insert and filter” operation. If the original signal occupied any bandwidth, much of it would get through the filter and the desired passband would take on a significant “passband droop” resulting in distortion from the original signal that was sampled.

That was the quantitative description of the resulting distortion with a zero-order hold (just hold the current value to be the interpolated sample). For the OP’s case of linear interpolation, we note that such an interpolation is the cascade of two zero-order hold filters! The coefficients of the equivalent FIR would be $$[0.25, 0.5, 0.25]$$ as the convolution of $$[0.5, 0.5]$$ and $$[0.5, 0.5]$$ (cascading two FIR filters convolves their coefficients). This the frequency response would be the square of the response for the zero-order hold:

$$H(e^{j\omega})= e^{-2\omega}\cos^2(\omega)$$

Resulting in more attenuation of the image but also more passband droop. Also a very poor interpolation filter.

• Equivalently, you could describe it as a time-domain triangular filter with a corresponding sinc squared freq domain response. To my mind that is more intuitive to describe linear interpolation as that process is often used for other factors than 1:2 upsampling, particularly in graphics Mar 22 at 16:21
• @KnutInge yes good point! We should also point out that It isn’t actually a Sinc Squared but a “Dirichlet Squared” response — which approaches a Sinc as the upsampling ratio increases but far from it for small ratios. Mar 22 at 16:42
• You are right I was thinking continuous domain (which of course is approximated by an infinite sample rate), where a triangular kernel (which is two rect functions convolved) have a freq domain response of two sincs multiplied by the time-freq dualities. I was not aware that sampling that system had anything to do with «Dirichlet» so that adds something on my «to-learn»-list. Thanks. Mar 22 at 16:56
• @KnutInge still a good example from the continuous time domain if that adds an additional intuition for those familiar with that, so thanks for the comment! Mar 22 at 17:08

That is called linear interpolation.

Technically it is a valid method and just one method among several methods.

It might not be a very good way as it is very simple and will not have very good performance in suppressing the spectral replicas and leaving the original bandwidth.

Consider this answer as a supplement material to the other answers provided.

The upsampling method (mean point between every two points) we are talking about can be represented in the form of equations as described below.

Let $$x[n]$$ be the original signal and $$x_{up}[n]$$ be the upsampled version of $$x[n]$$ obtained by linear interpolation technique. The equation presented below establishes the relationship between $$x_{up}[n]$$ and $$x[n]$$.

$$\begin{equation} x_{up}[2n] = x[n] \label{1} \end{equation}$$ $$\begin{equation} x_{up}[2n + 1] = \frac{x[n] + x[n + 1]}{2} \end{equation}$$

To understand the performance of this method let's apply this method on some fundamental signals and examine the resultant up-sampled signal.

1. Kronecker-Delta signal:

Let the upsampled version of the Kronecker-delta function $${\delta}[n]$$, obtained by using the linear interpolation method described above be $${\delta}_{up}[n]$$. Then it can be seen that $${\delta}_{up}[-1]$$ and $${\delta}_{up}$$ have non-zero values. So the upsampled signal $${\delta}_{up}[n]$$ is a combination of 3 Kronecker-delta (with delay) as shown below:

$$\begin{equation} {\delta}_{up}[n] = {\delta}[n] + 0.5 {\delta}[n + 1] + 0.5 {\delta}[n - 1] \end{equation}$$

Thus the distortion (let's call it $$d_{up}[n]$$) introduced by the linear interpolation techniques on the Kronecker-delta function can be quantified as $$\begin{equation} d_{up}[n] = 0.5 {\delta}[n + 1] + 0.5 {\delta}[n - 1] \end{equation}$$

The energy of distortion is of the order of the signal in this case.

2. Unit step signal:

Let the upsampled version of the unit step signal $$u[n]$$, obtained by using the linear interpolation method described above be $$u_{up}[n]$$. Then it can be seen that $$u_{up}[n]$$ has non-zero for $$n = -1$$. So the upsampled signal $$u_{up}[n]$$ is a combination of unit-step function and time delayed versions of unit step as shown below:

$$\begin{equation} u_{up}[n] = u[n] + \frac{ {\delta}[n + 1]}{2} \end{equation}$$

Thus the distortion (let's call it $$d_{up}[n]$$) introduced by the linear interpolation techniques on the unit-step function can be quantified as $$\begin{equation} d_{up}[n] = \frac{ {\delta}[n + 1]}{2} \end{equation}$$

The energy of distortion is arguably infinitesimally small in comparison with the energy of the signal in this case.

3. Sine Tone signal:

Let $$s[n]$$ be a pure sine tone signal as described below $$s[n] = \sin\bigg(\frac{2 \pi n} {N}\bigg)$$

Let $$s_{up}[n]$$ be the signal obtained by applying linear interpolation on the signal $$s[n]$$

Then $$\begin{equation} \begin{split} s_{up}[2n + 1] &= \frac{(s[n] + s[n + 1])}{2} \\ & = \frac{\bigg(\sin\bigg(\frac{2 \pi n} {N}\bigg) + \sin\bigg(\frac{2 \pi (n + 1)} {N}\bigg)\bigg)}{2} \\ \end{split} \end{equation}$$

Simplifying the above expression using reduced form of the $$sinA + sinB$$ we get the below $$\begin{equation} s_{up}[2n + 1] = \sin\bigg(\frac{2 \pi (2 n + 1)} {2 N}\bigg) \cos\bigg(\frac{2 \pi}{2 N}\bigg) \end{equation}$$

The expected value at point $$(2n + 1)$$ in the upsampled signal is $$\sin\bigg(\frac{2 \pi (2n + 1)} {2 N}\bigg)$$

Hence the distortion (let's call it $$d_{up}[n]$$) introduced in the signal is:

$$\begin{equation} d_{up}[2n + 1] = \sin\bigg(\frac{2 \pi (2 n + 1)} {2 N}\bigg) \bigg( 1 - \cos\bigg(\frac{2 \pi}{2 N}\bigg)\bigg) \end{equation}$$

The magnitude of distortion depends on the value of $$N$$

• Nice addition- Thanks! Mar 24 at 1:17
• @DanBoschen - Thanks for all the edits! Mar 24 at 1:36

Adding to Dan Boschens excellent answer. Linear interpolation can be a decent solution especially for relatively «smooth» input vectors and small upsampling ratios. It is particularly attractive for its low complexity and low delay.

In my head, I would think of the OP's case as inserting 0-samples in between every input sample (thus upsampling by 2x), then lowpass filtering with a sampled (continuous domain) triangular or «tent» function scaled such that the 0-to-0 width is exactly 4 (output sampling rate) samples, height is 1 and sampled as [0, 0.5, 1, 0.5, 0].

To a programmer this might seem like an overly fiddly way to describe what ends up being taking the average of two neighbor samples and injecting that «in-between». But this allows us to use DSP101 synchronous resampling chapters which I prefer. In that context one only needs to analyze the behavior of a plain triangular lowpass filter in terms of passband deviation and stop-band attenuation for an off-the-shelf resampling topology. Which is less work than thinking about sampling theory from scratch.