Resampling of Images and Signals

Lecture 15 min.



Resampling of Images and Signals
Illustration of the aliasing effect when reducing the resolution (decimation) of a raster image. Top: the image reduced without filtering. Bottom: the image reduced using a low-pass filter.

Resampling in signal processing is a change in the sampling rate of a discrete (most often digital) signal. Resampling algorithms are widely used in the processing of audio signals, radio signals, and images (resampling a raster image means changing its resolution in pixels).

The signal samples corresponding to the new sampling rate are computed from the existing samples and contain no new information.

Increasing the sampling rate is called interpolation, and decreasing it is called decimation.

General principles

Resampling of Images and Signals

Computing an intermediate sample (at the point −0.5) of a discrete signal using an ideal low-pass filter. The blue curve is the original continuous signal, and the green one is the impulse response of the ideal low-pass filter. For interpolation, the values of the impulse response at the sample points, multiplied by the values of the corresponding samples, are summed.

According to the Nyquist–Shannon (Kotelnikov) sampling theorem, any continuous signal with a finite spectrum (that is, a spectrum in which the spectral components corresponding to frequencies greater than or equal to some frequency Resampling of Images and Signals are absent) can be represented as samples of a discrete signal with the sampling rate Resampling of Images and Signals. Moreover, this transformation is one-to-one, that is, if the conditions of the sampling theorem are met, the original signal with a band-limited spectrum can be recovered from the discrete signal without distortion.

In resampling, the samples of a signal corresponding to one sampling rate are computed from the existing samples of the same signal corresponding to another sampling rate (it is assumed that both sampling rates satisfy the conditions of the sampling theorem). Ideal resampling is equivalent to reconstructing the continuous signal from its samples and then sampling it at the new rate.

The value of the original continuous signal at a given point is computed exactly as follows:

Resampling of Images and Signals

where Resampling of Images and Signals is the i-th sample of the signal, Resampling of Images and Signals is the time instant corresponding to this sample, Resampling of Images and Signals is the angular sampling frequency, and Resampling of Images and Signals is the interpolated value of the signal at the time instant Resampling of Images and Signals.

The function Resampling of Images and Signals is not finite in extent, so computing the value of the signal at a given instant using the expression above requires processing an infinite number of its samples (both in the past and in the future), which is impossible in practice. In real life, interpolation is performed with other filters, and the expression for it takes the following form:

Resampling of Images and Signals

where Resampling of Images and Signals is the impulse response of the corresponding reconstruction filter. The type of this filter is chosen depending on the task.

Directly computing new signal samples using the formulas above requires significant computational resources and is undesirable for real-time applications. There are important special cases of resampling for which the new samples are computed more simply:

  • decimation by an integer factor (reducing the sampling rate by an integer number of times);
  • interpolation by an integer factor (increasing the sampling rate by an integer number of times);
  • changing the sampling rate by a rational (Resampling of Images and Signals) factor (this case can be viewed as a combination of the previous two).

Under such restrictions, it becomes convenient to use standard digital filter implementations for resampling.

Resampling with digital filters

Resampling of Images and Signals
Illustration of the decimation algorithm for a discrete signal (by a factor of 2). The red dots denote samples, and the solid lines denote the continuous signal that these samples represent. Top: the original signal. Middle: the same signal after filtering in a digital low-pass filter. Bottom: the decimated signal.
Resampling of Images and Signals
Illustration of the interpolation algorithm for a discrete signal (by a factor of 2). The red dots denote the original samples of the signal, and the solid lines denote the continuous signal that these samples represent. Top: the original signal. Middle: the same signal with inserted zero samples (green dots). Bottom: the interpolated signal (the blue dots are the interpolated sample values).

Choosing a filter for resampling

The choice of the function Resampling of Images and Signals is a compromise between the quality of resampling (that is, how close it is to ideal) and the computational complexity of the process. In principle, any low-pass filter with the required cutoff frequency can be used for resampling. FIR filters are used for these tasks more often than IIR filters because FIR filters can be built with a linear phase response.[10]

The following classes of digital filters are most often used in resampling:[11]

1. Filters designed on the criterion of closeness of the frequency response to that of an ideal low-pass filter:

1.1. Windowed sinc filters, whose impulse response Resampling of Images and Signals is obtained by multiplying the impulse response of the ideal low-pass filter by a window function,

1.2. Equiripple Chebyshev filters.

2. Classical function interpolation methods (often used for images)[12]:

2.1. Linear interpolators,

2.2. Lagrange interpolators (a special case is cubic interpolation).

3. CIC filters (cascades of comb filters and integrators).[13] This class of filters does not use multiplications in its computation, which saves computational resources.

Decimation by an integer factor

The process of reducing the sampling rate of a signal is called decimation. Sometimes this term is used only for reducing the sampling rate by an integer factor (hereafter Resampling of Images and Signals).[14] Decimation of a digital signal by an integer factor is performed in two stages:[10][15]

  1. Digital filtering of the signal to remove high-frequency components that do not satisfy the conditions of the sampling theorem for the new sampling rate;
  2. Removal (discarding) of the excess samples (every Resampling of Images and Signals-th sample is kept).

In English-language literature, the second of these stages is sometimes denoted by the term downsampling.[16] In everyday usage, this term may be used as a synonym for "decimation".

The first stage is necessary to eliminate aliasing, whose nature is similar to the aliasing that occurs during the initial sampling of an analog signal.[15] Aliasing is especially noticeable in those parts of the signal that contain significant high-frequency spectral components. Thus, in the photographs at the beginning of the article, the sky has practically not been affected by aliasing, but the effect becomes noticeable if you look at the sharp transitions.

When the decimation algorithm is implemented in software, the "extra" samples are not deleted but simply never computed. As a result, the number of calls to the digital filter is reduced by a factor of Resampling of Images and Signals. In a hardware implementation, savings can be achieved by using polyphase filters.

Interpolation by an integer factor

Interpolation is an increase in the sampling rate by an integer or fractional factor by computing intermediate samples from the existing ones. Ideal interpolation makes it possible to restore the values of the signal at the intermediate samples exactly.

The standard algorithm for interpolating a signal by an integer factor is as follows:

  1. insert zero samples in place of the samples that need to be computed;
  2. filter the signal with a digital low-pass filter to remove the spectral components that, according to the Nyquist–Shannon (Kotelnikov) theorem, could not have been present in the original signal; the filter output is multiplied by the interpolation factor for normalization.

In English-language literature, the first of these steps is sometimes called upsampling. In everyday usage, this term may also be used as a synonym for "interpolation."

In a software implementation of interpolation, the zero samples do not take part in computing the filter output, which makes it possible to optimize the computation. In a hardware implementation, polyphase filters can be used to save resources

Combining interpolation and decimation

To change the sampling rate of a signal by a factor of Resampling of Images and Signals (Resampling of Images and Signals and Resampling of Images and Signals are positive integers), you can first increase the sampling rate by a factor of Resampling of Images and Signals and then reduce it by a factor of Resampling of Images and Signals. It is enough to filter the signal just once, between the interpolation and the decimation

The drawback of this method is that the signal has to be filtered at a sampling rate raised by a factor of Resampling of Images and Signals, which requires significant computational resources. The corresponding rate can be many times higher than both the original and the final resampling rate, especially if Resampling of Images and Signals and Resampling of Images and Signals are close large numbers. For example, when resampling an audio signal from 44100 Hz to 48000 Hz by this method, the sampling rate must be increased 160 times to 7056000 Hz and then reduced 147 times to 48000 Hz. Thus, in this example the computations have to be performed at a sampling rate of more than 7 MHz.

Resampling with polyphase filters

The polyphase-filter resampling method is similar to the previous one, except that instead of a single filter running at a high sampling rate, it uses several filters running at a low rate. This reduces the amount of computation required, since for each sample only the output of one of these filters has to be computed

A polyphase filter is a set of small filters working in parallel, each of which processes only a subset of the signal samples (if there are Resampling of Images and Signals filters in total, each filter will process only every Resampling of Images and Signals-th sample).

Polyphase filters are used for resampling by both integer and fractional factors

Resampling using the discrete Fourier transform

Resampling with the DFT is used to increase the sampling rate by an integer or fractional factor. The algorithm works only with finite segments of a signal. Let Resampling of Images and Signals be the initial number of samples and Resampling of Images and Signals the number of samples in the resampled signal. The algorithm includes the following operations:[25][26]

1. The DFT of the original signal is computed (most often with the fast Fourier transform algorithm).

2. The required number of zero components is inserted into the middle of the spectrum:

2.1. if Resampling of Images and Signals is odd:

Resampling of Images and Signals

2.2. if Resampling of Images and Signals is even:

Resampling of Images and Signals

3. The inverse discrete Fourier transform is computed, with normalization.

Any DFT-based method is intended primarily for periodic discrete signals. To process non-periodic signals, the segments used to compute the DFT must be chosen so that their ends overlap.

Applications

Both hardware implementations of resampling algorithms (based on specialized chips or FPGAs ) and software implementations (on general-purpose processors (see below) or digital signal processors ) are widely used.

The choice of a particular resampling implementation is the result of a compromise between conversion quality and computational complexity. The main parameter affecting these characteristics is how close the digital filters used are to the ideal ones. Higher-quality filters require more computational resources

In practice, resampling in most cases leads to a loss of information about the signal, for the following reasons:

  • when the sampling rate is reduced, the signal must be filtered to remove the high-frequency spectral components that do not satisfy the conditions of the Nyquist–Shannon (Kotelnikov) theorem for the new sampling rate;
  • the unavoidable non-ideality of the digital filters used;
  • computations performed on digital (level-quantized) signals lead to irreversible rounding errors

Thus, if the sampling rate is increased and then reduced back to the original value, the signal quality will be lost (unless the high rate is a multiple of the low one).

Oversampling

Oversampling means sampling a signal at a rate several times higher than the Nyquist (Kotelnikov) rate, followed by decimation. This approach offers the following advantages :

  • a simpler and cheaper analog anti-aliasing filter can be used.
  • an ADC with lower bit depth can be used.

A similar approach is used when reconstructing a signal from its samples, in order to simplify the analog reconstruction filter.

In audio processing

Equipment intended for playing back digital audio is, as a rule, designed for a specific, fixed sampling rate immediately before digital-to-analog conversion. All audio signals with other sampling rates must sooner or later be resampled .

Resampling an audio signal to the required rate can be done by the media player, the sound card driver, or the sound card itself. Using the player software for this purpose can be justified if you want to avoid hardware resampling (or resampling by the driver) in order to achieve higher quality (at the cost of higher CPU load). However, software resampling of the played material to a rate other than the one supported by the hardware makes no sense and only degrades the signal quality.

There are open-source software resamplers for audio signals:

  • SRC (Secret Rabbit Code) or libsamplerate — there is a plugin for foobar2000;
  • SSRC — there are plugins for Winamp and foobar2000.
  • SOXR — high quality, fast, with minimal resource requirements . It includes a library to replace SRC, plugs into foobar2000, and is used in FFmpeg (since version 1.1.1), Audacity and other projects.

Resampling is also supported by audio editors (such as Adobe Audition, Sony Sound Forge or Audacity).

In image processing

Resampling of Images and Signals
An illustration of the moiré effect caused by aliasing when an image's resolution is reduced. Top: the original; bottom left: the image reduced by a factor of 2 without filtering; bottom right: the image reduced by a factor of 2 with filtering.

Changing resolution is one of the most common image processing operations. Resampling that comes close to the ideal is not always desirable. On the contrary, the results of filters with a frequency response far from ideal may be perceived visually as good. The choice of a resampling filter is a compromise between the type and severity of artifacts and the computational complexity of the conversion (which matters for real-time applications).

Typical artifacts when changing image resolution:

  • Blocking (pixelation);
  • Ringing;
  • Aliasing and the associated moiré effect;
  • Blurring.

A large number of filters are used for image resampling, and they can be classified as follows:

  1. Interpolation-type filters with a relatively narrow impulse response. These include, in particular, the triangle filter, which performs bilinear interpolation, and the Lagrange polynomial, which can be used to implement bicubic interpolation. Using such filters allows an image to be resampled quite quickly.
  2. Filters with a bell-shaped response, such as the Gaussian filter. These filters cope well with blocking, ringing and aliasing, and also filter out high-frequency noise. Their drawback is noticeable blurring of the image.
  3. Windowed sinc filters. The sinc filter is the ideal low-pass filter. As mentioned above, it cannot be implemented. However, if the frequency response of a sinc filter is multiplied by a window function, the result is a realizable filter with good spectral properties. Applying these filters to images preserves relatively high sharpness (even when the resolution is increased), but ringing can be very noticeable. One of the most commonly used filters of this type is the Lanczos filter.

The images below illustrate the application of the most commonly used image resizing filters. When an image is enlarged without a filter, it stays sharp but pixelated. With bilinear interpolation, the pixelation is less noticeable, but the image is blurred. With the Gaussian filter, the image is blurred, but there is practically no visible pixelation. With the Lanczos filter, there is no pixelation, the image is also blurred, and ringing is visible (seen as a light halo around the shapes).

Resampling of Images and Signals

Image enlarged 4 times without a filter

Resampling of Images and Signals

Image enlarged 4 times with bilinear interpolation

Resampling of Images and Signals

Image enlarged 4 times with the Gaussian filter

Resampling of Images and Signals

Image enlarged 4 times with the Lanczos filter

In radio signal processing

When demodulating digital signals, it is desirable for the sampling rate of the signal to be a multiple of its symbol rate (in other words, for each symbol to correspond to the same number of signal samples). However, the sampling rate of an input signal from an ADC is usually fixed, while the symbol rate may vary. The solution is to resample the signal

See also

  • [[b9830]]
  • [[b4869]]
  • Quantization (signal processing)
  • Sampling
  • Delta modulation
  • Sigma-delta modulation
  • Analog-to-digital converter
  • Digital-to-analog converter

See also

created: 2022-02-13
updated: 2026-09-29
188



Was this answer useful?
Choose a quick rating so we can improve the next answer for you.
How satisfied are you?


Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Digital image processing"

Terms: Digital image processing