|
|
Line 1: |
Line 1: |
| {{multiple image
| | Nice to meet you, my name is Refugia. Hiring is his profession. Years ago we moved to North Dakota. The thing she adores most is body developing and now she is trying to make cash with it.<br><br>Here is my blog; [http://www.article-galaxy.com/profile.php?a=165109 std testing at home] |
| | footer = Partial plot of a discrete signal (black dots) and of its Lanczos interpolation (solid blue curve), with size parameter ''a'' equal to 1 (top), 2 (middle) and 3 (bottom). Also shown are two copies of the Lanczos kernel, shifted and scaled, corresponding to samples 4 and 11 (dashed curves).
| |
| | width = 320
| |
| | direction = vertical
| |
| | image1 = Lanczos-r01-filtering.svg | alt1 = Lanczos interpolation with radius 1
| |
| | image2 = Lanczos-r02-filtering.svg | alt1 = Lanczos interpolation with radius 2
| |
| | image3 = Lanczos-r03-filtering.svg | alt1 = Lanczos interpolation with radius 3
| |
| }}
| |
| | |
| '''Lanczos resampling''' or '''Lanczos filter''' is a mathematical formula used to smoothly [[interpolation|interpolate]] the value of a [[digital signal]] between its [[sample (signal)|samples]]. It maps each sample of the given signal to a translated and scaled copy of the '''Lanczos kernel''', which is a [[sinc function]] [[window function|windowed]] by the central hump of a dilated 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]] of a digital signal, or to shift it by a fraction of the sampling interval. It is often used also for [[multivariate interpolation]], for example to [[image scaling|resize]] or [[rotation (geometry)|rotate]] a [[digital image]]. It has been considered the "best compromise" among several simple filters for this purpose.<ref name="turkgab">{{cite book
| |
| | author = Ken Turkowski and Steve Gabriel
| |
| | year = 1990
| |
| | editor = Andrew S. Glassner
| |
| | chapter = Filters for Common Resampling Tasks
| |
| | title = Graphics Gems I
| |
| | publisher = Academic Press
| |
| | pages = 147–165
| |
| | isbn = 978-0-12-286165-9
| |
| | id = {{citeseerx|10.1.1.116.7898}}
| |
| }}</ref>
| |
| | |
| The filter is named after [[Cornelius Lanczos]] ({{IPA-hu|ˈlaːntsoʃ}}), because of his contributions to the application of [[Fourier series]] and [[Chebyshev polynomials]].<ref>{{cite journal | |
| | doi = 10.1175/1520-0450(1979)018<1016:LFIOAT>2.0.CO;2
| |
| | title = Lanczos Filtering in One and Two Dimensions
| |
| | author = Claude E. Duchon
| |
| | journal = Journal of Applied Meteorology
| |
| | year = 1979
| |
| | volume = 18
| |
| | issue = 8
| |
| | pages = 1016–1022
| |
| | month = August
| |
| | url = http://journals.ametsoc.org/doi/pdf/10.1175/1520-0450%281979%29018%3C1016%3ALFIOAT%3E2.0.CO%3B2
| |
| }}</ref>
| |
| | |
| == Definition ==
| |
| ===Lanczos kernel===
| |
| [[File:Lanczos-windows.svg|thumb|Lanczos windows for ''a'' = 1, 2, 3.]]
| |
| | |
| [[Image:Lanczos-kernel.svg|thumb|right|Lanczos kernels for the cases ''a'' = 2 and ''a'' = 3. Note that the function obtains negative values.]]
| |
| | |
| The effect of each input sample on the interpolated values is defined by the filter's [[signal reconstruction|reconstruction kernel]] {{math|''L''(''x'')}}, called the Lanczos kernel. It is the normalized sinc function {{math|sinc(''x'')}}, [[window function|windowed]] (multiplied) by the '''Lanczos window,'''{{anchor|Lanczos window}} or '''sinc window''', which is the central lobe of a horizontally-stretched sinc function {{math|sinc(''x''/''a'')}} for {{math| −''a'' ≤ ''x'' ≤ ''a''}}.
| |
| | |
| : <math> L(x) = \begin{cases} \operatorname{sinc}(x)\, \operatorname{sinc}(x/a) & \text{if}\;\; -a < x < a\\ 0 & \text{otherwise} \end{cases} </math>
| |
| | |
| Equivalently,
| |
| | |
| :<math>L(x) = \begin{cases} 1 & \text{if}\;\; x = 0\\ \quad & \\ \displaystyle \frac{a \sin(\pi x) \sin(\pi x / a)}{\pi^2 x^2} & \text{if}\;\; 0 < |x| < a \\ \quad & \\ 0 & \text{otherwise} \end{cases}</math>
| |
| | |
| The parameter {{math|''a''}} is a positive integer, typically 2 or 3, which determines the size of the kernel. The Lanczos kernel has {{math|2''a'' − 1}} lobes, a positive one at the center and {{math|''a'' − 1}} alternating negative and positive lobes on each side.
| |
| | |
| === Interpolation formula ===
| |
| Given a one-dimensional signal with samples {{math|''s''<sub>''i''</sub>}}, for integer values of {{math|''i''}}, the value {{math|''S''(''x'')}} interpolated at an arbitrary real argument {{math|''x''}} is obtained by the discrete [[convolution]] of those samples with the Lanczos kernel;<ref name="burger">{{cite book
| |
| | title = Principles of digital image processing: core algorithms
| |
| | author = Wilhelm Burger, Mark J. Burge
| |
| | publisher = Springer
| |
| | year = 2009
| |
| | isbn = 978-1-84800-194-7
| |
| | pages = 231–232
| |
| | url = http://books.google.com/books?id=s5CBZLBakawC
| |
| }}</ref> namely,
| |
| : <math>S(x) = \sum_{i=\lfloor x \rfloor - a + 1}^{\lfloor x \rfloor + a} s_{i} L(x - i),</math>
| |
| where {{math|''a''}} is the filter size parameter and <math>\lfloor x \rfloor </math> is the [[floor function]]. The bounds of this sum are such that the kernel is zero outside of them.
| |
| | |
| == Properties ==
| |
| As long as the parameter {{math|''a''}} is a positive integer, the Lanczos kernel is [[continuous function|continuous]] everywhere, and its [[derivative]] is defined and continuous everywhere (even at {{math|''x''}} = {{math|±''a''}}, where both sinc functions go to zero). Therefore, the reconstructed signal {{math|''S''(''x'')}} too will be continuous, with continuous derivative.
| |
| | |
| The Lanczos kernel is zero at every integer argument {{math|''x''}}, except at {{math|''x''}} = 0, where it has value 1. Therefore, the reconstructed signal exactly interpolates the given samples: we will have {{math|''S''(''x'')}} = {{math|''s''<sub>''i''</sub>}} for every integer argument {{math|''x''}} = {{math|''i''}}.
| |
| | |
| == Multidimensional interpolation==
| |
| [[Image:Lanczos interpolation - Sheet music, original.jpg|thumb|right| [[Incipit]] of a piece by [[Gaspar Sanz]]. Original, low quality expansion with JPEG artifacts. Open the picture to see the details.]]
| |
| | |
| [[Image:Lanczos interpolation - Sheet music, interpolated.jpg|thumb|The same image resampled to five times as many samples in each direction, using Lanczos resampling. Pixelation artifacts were removed changing the image's transfer function. Open the picture to see the details.]]
| |
| Lanczos filter's kernel in two dimensions is simply the product of two one-dimensional kernels:<ref name="burger" />{{dubious|Unintuitive and seems to be contradicted by Duchon.|date=November 2012}}
| |
| | |
| : <math>L(x, y) = L(x) \cdot L(y).</math>
| |
| | |
| Given a two-dimensional signal {{math|''s''<sub>''ij''</sub>}} defined at integer points {{math|(''i'',''j'')}} of the plane (e.g. intensities of pixels in a digital image), the reconstructed function is
| |
| : <math> S(x, y) =
| |
| \sum_{i=\lfloor x \rfloor - a + 1}^{\lfloor x \rfloor + a}
| |
| \sum_{j=\lfloor y \rfloor - a + 1}^{\lfloor y \rfloor + a}
| |
| s_{i\,j} L(x - i) L(y - j).</math>
| |
| | |
| When resampling a two-dimensional signal at regularly spaced points {{math|(''x'',''y'')}}, one can save some computation by resampling the entire signal along a single axis, then resampling the resulting two-dimensional signal along the other axis.
| |
| | |
| These formulas generalize to signals with three or more dimensions, in the obvious way.
| |
| | |
| == Evaluation ==
| |
| === Advantages ===
| |
| [[File:Window function and frequency response - Lanczos.svg|thumb|A discrete Lanczos window and its [[frequency response]]; see [[Window function]] for comparison with other windows.]]
| |
| | |
| The theoretically optimal reconstruction filter for [[bandlimiting|band-limited signal]]s is the [[sinc filter]], which has infinite [[support (mathematics)|support]]. The Lanczos filter is one of many practical (finitely supported) approximations of the sinc filter. Each interpolated value is the weighted sum of {{math|2''a''}} consecutive input samples. Thus, by varying the {{math|2''a''}} 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 tradeoff is between the reduction of [[aliasing]] artifacts and the preservation of sharp edges.
| |
| | |
| The Lanczos filter has been compared with other interpolation methods for discrete signals, particularly other windowed versions of the sinc filter. [[Kenneth Turkowski|Turkowski]] and [[Steven Gabriel|Gabriel]] claimed that the Lanczos filter (with {{math|''a''}} = 2) the "best compromise in terms of reduction of aliasing, sharpness, and minimal ringing", compared with truncated sinc and the [[Bartlett window|Bartlett]], [[cosine window|cosine-]], and [[Hann window|Hann-window]]ed sinc, for decimation and interpolation of 2-dimensional image data.<ref name="turkgab"/> According to [[Jim Blinn]], the Lanczos kernel (with {{math|''a''}} = 3) "keeps low frequencies and rejects high frequencies better than any (achievable) filter we've seen so far."<ref>{{cite book
| |
| | title = Jim Blinn's corner: dirty pixels
| |
| | publisher = Morgan Kaufmann
| |
| | year = 1998
| |
| | isbn = 978-1-55860-455-1
| |
| | pages = 26–27
| |
| | url = http://books.google.com/?id=4fjFQs3cPckC&pg=PA27&dq=blinn+lanczos
| |
| }}</ref>
| |
| | |
| Lanczos interpolation is a popular filter for "upscaling" videos in various media utilities, such as [[AviSynth]]<ref>{{cite web|url=http://avisynth.org/mediawiki/Resize#LanczosResize |title=Resize |publisher=Avisynth |date=2011-07-27 |accessdate=2012-07-31}}</ref> and [[FFmpeg]].<ref>{{cite web|url=http://www.neowin.net/forum/topic/422992-a-how-to-guide-upconverting-video-using-ffdshow |title=A How To guide: Upconverting video using FFDShow - Neowin Forums |publisher=Neowin.net |date=2006-04-18 |accessdate=2012-07-31}}</ref>
| |
| | |
| === Limitations ===
| |
| Since the kernel assumes negative values for {{math|''a'' > 1}}, 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]] just before and after abrupt changes in the sample values, which may lead to [[clipping (signal processing)|clipping artifacts]]. However, these effects are reduced compared to the (non-windowed) sinc filter.
| |
| | |
| 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 [[acutance|perceived sharpness]], and therefore provide a form of [[edge enhancement]]. This may improve the subjective quality of the image, given the special role of edge sharpness in [[visual perception|vision]].<ref>{{cite web|url=http://www.ipol.im/pub/algo/g_linear_methods_for_image_interpolation/#index19h1 |title=IPOL: Linear Methods for Image Interpolation |publisher=Ipol.im |date=2011-09-27 |accessdate=2012-07-31}}</ref>
| |
| | |
| 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]] property. That is, the sum <math>U(x) = \sum_{i\in \mathbb{Z}} L(x-i)</math> 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 {{math|''a''}} = 1. Also, for {{math|''a''}} = 1 the interpolated signal has zero derivative at every integer argument.
| |
| | |
| ==See also==
| |
| | |
| *[[Bicubic interpolation]]
| |
| *[[Bilinear interpolation]]
| |
| *[[Spline interpolation]]
| |
| *[[Nearest-neighbor interpolation]]
| |
| *[[Sinc filter]]
| |
| | |
| == References ==
| |
| {{Reflist}}
| |
| | |
| ==External links==
| |
| * [http://www.antigrain.com/demo/index.html Anti-Grain Geometry examples]: <tt>image_filters.cpp</tt> shows comparisons of repeatedly resampling an image with various kernels.
| |
| * [http://code.google.com/p/imageresampler/ imageresampler]: A public domain image resampling class in C++ with support for several windowed Lanczos filter kernels.
| |
| | |
| [[Category:Signal processing]]
| |
| [[Category:Multivariate interpolation]]
| |