Lanczos Window
   HOME

TheInfoList



OR:

Lanczos filtering and Lanczos resampling are two applications of a mathematical formula. It can be used as a
low-pass filter A low-pass filter is a filter that passes signals with a frequency lower than a selected cutoff frequency and attenuates signals with frequencies higher than the cutoff frequency. The exact frequency response of the filter depends on the filter des ...
or used to smoothly
interpolate In the mathematical field of numerical analysis, interpolation is a type of estimation, a method of constructing (finding) new data points based on the range of a discrete set of known data points. In engineering and science, one often has a n ...
the value of a
digital signal A digital signal is a signal that represents data as a sequence of discrete values; at any given time it can only take on, at most, one of a finite number of values. This contrasts with an analog signal, which represents continuous values; at ...
between its samples. In the latter case it maps each sample of the given signal to a translated and scaled copy of the Lanczos kernel, which is a
sinc function In mathematics, physics and engineering, the sinc function, denoted by , has two forms, normalized and unnormalized.. In mathematics, the historical unnormalized sinc function is defined for by \operatornamex = \frac. Alternatively, the u ...
windowed by the central lobe of a second, longer, sinc function. The sum of these translated and scaled kernels is then evaluated at the desired points. Lanczos resampling is typically used to increase the
sampling rate In signal processing, sampling is the reduction of a continuous-time signal to a discrete-time signal. A common example is the conversion of a sound wave to a sequence of "samples". A sample is a value of the signal at a point in time and/or spac ...
of a digital signal, or to shift it by a fraction of the sampling interval. It is often used also for
multivariate interpolation In numerical analysis, multivariate interpolation is interpolation on functions of more than one variable; when the variates are spatial coordinates, it is also known as spatial interpolation. The function to be interpolated is known at given poin ...
, for example to resize or
rotate Rotation, or spin, is the circular movement of an object around a '' central axis''. A two-dimensional rotating object has only one possible central axis and can rotate in either a clockwise or counterclockwise direction. A three-dimensional ...
a
digital image A digital image is an image composed of picture elements, also known as ''pixels'', each with ''finite'', '' discrete quantities'' of numeric representation for its intensity or gray level that is an output from its two-dimensional functions ...
. It has been considered the "best compromise" among several simple filters for this purpose. The filter is named after its inventor,
Cornelius Lanczos __NOTOC__ Cornelius (Cornel) Lanczos ( hu, Lánczos Kornél, ; born as Kornél Lőwy, until 1906: ''Löwy (Lőwy) Kornél''; February 2, 1893 – June 25, 1974) was a Hungarian-American and later Hungarian-Irish mathematician and physicist. Accor ...
().


Definition


Lanczos kernel

The effect of each input sample on the interpolated values is defined by the filter's reconstruction kernel , called the Lanczos kernel. It is the normalized
sinc In mathematics, physics and engineering, the sinc function, denoted by , has two forms, normalized and unnormalized.. In mathematics, the historical unnormalized sinc function is defined for by \operatornamex = \frac. Alternatively, the u ...
function , windowed (multiplied) by the Lanczos window, or sinc window, which is the central lobe of a horizontally stretched sinc function for . : L(x) = \begin \operatorname(\pi x) \operatorname(\pi x/a) & \text\ -a < x < a, \\ 0 & \text. \end Equivalently, :L(x) = \begin 1 & \text\ x = 0, \\ \dfrac & \text\ -a \leq x < a \ \text\ x \neq 0, \\ 0 & \text. \end The parameter is a positive integer, typically 2 or 3, which determines the size of the kernel. The Lanczos kernel has lobes: a positive one at the center, and alternating negative and positive lobes on each side.


Interpolation formula

Given a one-dimensional signal with samples , for integer values of , the value interpolated at an arbitrary real argument is obtained by the discrete
convolution In mathematics (in particular, functional analysis), convolution is a operation (mathematics), mathematical operation on two function (mathematics), functions ( and ) that produces a third function (f*g) that expresses how the shape of one is ...
of those samples with the Lanczos kernel: : S(x) = \sum_^ s_ L(x - i), where is the filter size parameter, and \lfloor x \rfloor is the
floor function In mathematics and computer science, the floor function is the function that takes as input a real number , and gives as output the greatest integer less than or equal to , denoted or . Similarly, the ceiling function maps to the least int ...
. The bounds of this sum are such that the kernel is zero outside of them.


Properties

As long as the parameter is a positive integer, the Lanczos kernel is
continuous Continuity or continuous may refer to: Mathematics * Continuity (mathematics), the opposing concept to discreteness; common examples include ** Continuous probability distribution or random variable in probability and statistics ** Continuous ...
everywhere, and its
derivative In mathematics, the derivative of a function of a real variable measures the sensitivity to change of the function value (output value) with respect to a change in its argument (input value). Derivatives are a fundamental tool of calculus. F ...
is defined and continuous everywhere (even at , where both sinc functions go to zero). Therefore, the reconstructed signal too will be continuous, with continuous derivative. The Lanczos kernel is zero at every integer argument , except at , where it has value 1. Therefore, the reconstructed signal exactly interpolates the given samples: we will have for every integer argument . Lanczos resampling is one form of a general method developed by Lanczos to counteract the
Gibbs phenomenon In mathematics, the Gibbs phenomenon, discovered by Available on-line at:National Chiao Tung University: Open Course Ware: Hewitt & Hewitt, 1979. and rediscovered by , is the oscillatory behavior of the Fourier series of a piecewise continuousl ...
by multiplying coefficients of a truncated
Fourier series A Fourier series () is a summation of harmonically related sinusoidal functions, also known as components or harmonics. The result of the summation is a periodic function whose functional form is determined by the choices of cycle length (or ''p ...
by \mathrm(\pi k / m), where k is the coefficient index and m is how many coefficients we're keeping. The same reasoning applies in the case of truncated functions if we wish to remove Gibbs oscillations in their spectrum.


Multidimensional interpolation

Lanczos filter's kernel in two dimensions is :L(x, y) = L(x)L(y).


Evaluation


Advantages

The theoretically optimal reconstruction filter for band-limited signals is the
sinc filter In signal processing, a sinc filter is an idealized filter that removes all frequency components above a given cutoff frequency, without affecting lower frequencies, and has linear phase response. The filter's impulse response is a sinc functio ...
, which has infinite
support Support may refer to: Arts, entertainment, and media * Supporting character Business and finance * Support (technical analysis) * Child support * Customer support * Income Support Construction * Support (structure), or lateral support, a ...
. The Lanczos filter is one of many practical (finitely supported) approximations of the sinc filter. Each interpolated value is the weighted sum of consecutive input samples. Thus, by varying the parameter one may trade computation speed for improved frequency response. The parameter also allows one to choose between a smoother interpolation or a preservation of sharp transients in the data. For image processing, the trade-off is between the reduction of
aliasing In signal processing and related disciplines, aliasing is an effect that causes different signals to become indistinguishable (or ''aliases'' of one another) when sampled. It also often refers to the distortion or artifact that results when a ...
artefacts and the preservation of sharp edges. Also as with any such processing, there are no results for the borders of the image. Increasing the length of the kernel increases the cropping of the edges of the image. The Lanczos filter has been compared with other interpolation methods for discrete signals, particularly other windowed versions of the sinc filter. Turkowski and
Gabriel In Abrahamic religions (Judaism, Christianity and Islam), Gabriel (); Greek: grc, Γαβριήλ, translit=Gabriḗl, label=none; Latin: ''Gabriel''; Coptic: cop, Ⲅⲁⲃⲣⲓⲏⲗ, translit=Gabriêl, label=none; Amharic: am, ገብር ...
claimed that the Lanczos filter (with ) the "best compromise in terms of reduction of aliasing, sharpness, and minimal ringing", compared with truncated sinc and the Bartlett, cosine-, and Hann-windowed sinc, for decimation and interpolation of 2-dimensional image data. According to
Jim Blinn James F. Blinn (born 1949) is an American computer scientist who first became widely known for his work as a computer graphics expert at NASA's Jet Propulsion Laboratory (JPL), particularly his work on the pre-encounter animations for the Voya ...
, the Lanczos kernel (with ) "keeps low frequencies and rejects high frequencies better than any (achievable) filter we've seen so far." Lanczos interpolation is a popular filter for "upscaling" videos in various media utilities, such as
AviSynth AviSynth is a frameserver program for Microsoft Windows, Linux and macOS initially developed by Ben Rudiak-Gould, Edwin van Eggelen, Klaus Post, Richard Berg and Ian Brabham in May 2000 and later picked up and maintained by the open source communi ...
and
FFmpeg FFmpeg is a free and open-source software project consisting of a suite of libraries and programs for handling video, audio, and other multimedia files and streams. At its core is the command-line ffmpeg tool itself, designed for processing of vid ...
.


Limitations

Since the kernel assumes negative values for , the interpolated signal can be negative even if all samples are positive. More generally, the range of values of the interpolated signal may be wider than the range spanned by the discrete sample values. In particular, there may be
ringing artifacts In signal processing, particularly digital image processing, ringing artifacts are artifacts that appear as spurious signals near sharp transitions in a signal. Visually, they appear as bands or "ghosts" near edges; audibly, they appear as "ec ...
just before and after abrupt changes in the sample values, which may lead to clipping artifacts. However, these effects are reduced compared to the (non-windowed) sinc filter. For ''a'' = 2 (a three-lobed kernel) the ringing is < 1%. The method is one of the interpolation options available in the free software GNU Image Manipulation Program (GIMP). One way to visualize the ringing effect is to rescale a black and white block graphic and select Lanczos interpolation. When using the Lanczos filter for image resampling, the ringing effect will create light and dark halos along any strong edges. While these bands may be visually annoying, they help increase the perceived sharpness, and therefore provide a form of
edge enhancement Edge enhancement is an image processing filter that enhances the edge contrast of an image or video in an attempt to improve its acutance (apparent sharpness). The filter works by identifying sharp edge boundaries in the image, such as the edge ...
. This may improve the subjective quality of the image, given the special role of edge sharpness in
vision Vision, Visions, or The Vision may refer to: Perception Optical perception * Visual perception, the sense of sight * Visual system, the physical mechanism of eyesight * Computer vision, a field dealing with how computers can be made to gain un ...
. In some applications, the low-end clipping artifacts can be ameliorated by transforming the data to a logarithmic domain prior to filtering. In this case the interpolated values will be a weighted geometric mean, rather than an arithmetic mean, of the input samples. The Lanczos kernel does not have the
partition of unity In mathematics, a partition of unity of a topological space is a set of continuous functions from to the unit interval ,1such that for every point x\in X: * there is a neighbourhood of where all but a finite number of the functions of are 0, ...
property. That is, the sum U(x) = \sum_ L(x-i) of all integer-translated copies of the kernel is not always 1. Therefore, the Lanczos interpolation of a discrete signal with constant samples does not yield a constant function. This defect is most evident when . Also, for the interpolated signal has zero derivative at every integer argument. This is rather academic, since using a single-lobe kernel (''a'' = 1) loses all the benefits of the Lanczos approach and provides a poor filter. There are many better single-lobe, bell-shaped windowing functions.


See also

*
Bicubic interpolation In mathematics, bicubic interpolation is an extension of cubic interpolation (not to be confused with cubic spline interpolation, a method of applying cubic interpolation to a data set) for interpolating data points on a two-dimensional regular ...
*
Bilinear interpolation In mathematics, bilinear interpolation is a method for interpolating functions of two variables (e.g., ''x'' and ''y'') using repeated linear interpolation. It is usually applied to functions sampled on a 2D rectilinear grid, though it can be ge ...
*
Spline interpolation In the mathematical field of numerical analysis, spline interpolation is a form of interpolation where the interpolant is a special type of piecewise polynomial called a spline. That is, instead of fitting a single, high-degree polynomial to all ...
*
Nearest-neighbor interpolation Nearest-neighbor interpolation (also known as proximal interpolation or, in some contexts, point sampling) is a simple method of multivariate interpolation in one or more dimensions. Interpolation is the problem of approximating the value of ...
*
Sinc filter In signal processing, a sinc filter is an idealized filter that removes all frequency components above a given cutoff frequency, without affecting lower frequencies, and has linear phase response. The filter's impulse response is a sinc functio ...


References

{{Reflist


External links


Anti-Grain Geometry examples
image_filters.cpp shows comparisons of repeatedly resampling an image with various kernels.
imageresampler
A public domain image resampling class in C++ with support for several windowed Lanczos filter kernels. Signal processing Multivariate interpolation