Talk:Lanczos resampling

From Wikipedia, the free encyclopedia

Contents

[edit] Why is it better than bicubic?

Dumb leading question, why is it better than bicubic?

  • Results are realy similar to bicubic, but a little bit sharper. --ManiacK 17:10, 12 May 2006 (UTC)
  • Without multiple lobes, it is no better than bicubic. With multiple lobs, it is mathematically better, but visually worse because of ringing artifacts. Yet another case where theory does not match reality. --anon user
  • The report of a "blind user test" (! 8-) proves nothing by itself. Was the test properly done? (Did the experimenter worry about gamma, dark/light clipping, etc.?) What were the images? (fuzzy, sharp, contrast-stretched, ...?) What were the evaluation criteria? ("looks nicer", "looks sharper", "looks more natural", "looks more like the original", or something else?) --User:Jorge Stolfi 143.106.23.149 18:27, 17 April 2007 (UTC)
  • In any case, a reconstruction filter R (used when enlarging an image I) should be matched to the sampling filter S (used when capturing the image I from the real world, or when producing it by reducing a larger image Q) and to the amount of quantization noise N. There is no "absolute best" filter R; the best R depends on S and N. Unfortunately, the S of scanners and cameras is usually unknown (although it can be measured with proper test targets and some image analysis). --User:Jorge Stolfi 143.106.23.149 18:27, 17 April 2007 (UTC)
  • In any case, JPEG-coded images are unsuitable for any serious image processing, unless they are captured at the highest possible quality setting and/or are substantially reduced in size AFTER conversion to some lossless format. Note that JPEG uses a non-linear non-uniform encoding which creates artifacts at the boundaries of its 8x8 processing blocks --User:Jorge Stolfi 143.106.23.149 18:27, 17 April 2007 (UTC)

[edit] Good only in theory?

I find the claims of lanczos resampling being only theoretically good but bad in practice, very dubious. I have done tests with both video and audio and in both cases lanczos seems to have superior after-resampling quality to any other method I've tried, except for hq2x and other methods specifically finetuned for pixel content at certain ratio. --Bisqwit 08:25, 29 April 2007 (UTC)

  • The {{fact}} template remained for two months, I removed the unsourced claim now. --Bisqwit 15:20, 8 June 2007 (UTC)
  • Some interesting tests there. Too bad they were done with a black background. Had you use a grey background, you would've noticed dark rings appearing around the bright areas using the Lanczos filter and possibly several others. These do not appear with a black background because, obviously, it doesn't get much darker than zero. 130.89.228.82 (talk) 01:35, 19 February 2008 (UTC)
  • Hmm, you're right. Therefore, I created a new test. It does show the "rings" you mention, appearing in such a stark upscaling as this. However, in the same breath, I'd say that it does the best job in preserving the contrast of the white cross, and keeping the aliasing off the yellow line. Catrom comes quite close, though. I also added downscaling tests. In that test, such "rings" are not observed, and it does among the best job in preserving the detail in the pillars and avoiding moire effects in the platform. However, mind you that for the purposes of Wikipedia, this is all original research, so it cannot be used for the article. --Bisqwit (talk) 07:22, 19 February 2008 (UTC)
  • Of course original research can't be used, but it might point out an article is incomplete. I doubt nobody ever noticed something this obvious in a peer reviewed article. 130.89.228.82 (talk) 14:49, 19 February 2008 (UTC)

[edit] Size of the contribution[] array in the example code

The original example code had the contribution array length specified as dest_len. A number of readers pointed out that the array maximum length should be src_len.

Here is the verification. The maximum dimension accessed contribution[] is nmax, due to the loop bounds.

  • where nmax = min(src_len, support * 2)
  • where support = 3 / min(factor, 1)
  • where factor = dest_len / src_len
  • i.e. nmax = min(src_len, 6 * max(src_len / dest_len, 1) )

if dest_len = 1, then nmax indeed equals src_len. So the correction is just. Imagemagick actually initializes the array size as 2*max(support,0.5)+3. But I guess, src_len is just as good. --Bisqwit (talk) 15:58, 6 December 2007 (UTC)

[edit] 2D?

What is the kernel in 2D? is it just the tensor product of the kernel in 1D? 155.212.242.34 (talk) 21:31, 21 December 2007 (UTC)

[edit] Window function

Why is the window function based on sinc rather than something simple like a polynomial? Is there a good reason to use this particular window function? 155.212.242.34 (talk) 22:21, 21 December 2007 (UTC)

Since a sinc function is an ideal lowpass filter, a windowed sinc function is usually a pretty good lowpass filter. Lanczos chose to use the central positive lobe of a wider sinc as the window. I don't know why, but it seems to work well. Dicklyon (talk) 08:14, 22 December 2007 (UTC)

[edit] Why the sinc function?

"it more closely approximates the optimal resampling filter, the sinc function": It is not obvious to our average reader why the sinc function would be the optimal resampling filter, in general, or more specifically, for image data. Closely related to this is also the question as to in what sense the sinc function is optimal, in other words, what is the performance function that the sinc function maximizes? Shinobu (talk) 22:11, 11 January 2008 (UTC)

I linked "optimal resampling filter" to the sinc filter article to help explain this. What's being optimized is aliasing, under the assumption of a band-limited underlying original that you have samples of, and handlimited reconstruction. It's not necessarily an accurate characterization of the image resampling problem in general, but it's the one that's mathematically tractable. The bigger question is in what sense is it true that "it more closely approximates" this. Relevant considerations are discussed and anayzed in the window function article, where the sinc window is categorized as a "high-resolution" window, as opposed to a high-dynamic-range window; for images, this is a good choice, but other windows in that class are equally good. Dicklyon (talk) 22:54, 11 January 2008 (UTC)

[edit] Selected radius

The article does not mention explain why one should choose a particular value for a, the radius in the Lanczos formula. Imagemagick uses the value of 3, so I have always used it in my own code, but I don't really know why one value would be better than some other. Is there an explanation somewhere? Could the article be improved by adding such explanation? --Bisqwit (talk) 09:10, 6 February 2008 (UTC)

It's a tradeoff between computational cost and accuracy (filter cutoff sharpness at Nyquist); 2 and 3 are reasonable values, depending on how accurate you're trying to be. For something like audio instead of images, larger n might make sense. Dicklyon (talk) 15:52, 6 February 2008 (UTC)

[edit] Negative values

The article points out the window function reaches negative values but doesn't point out the significance; negative values in the window function can cause values in the resulting signal that are outside of the bounds of the original signal; for example if you use the Lanczos filter on a rect function, the result will drop below 0 outside of the edges of the rectangle and can pop over 1 inside the edges. Put differently, when using a filter on a dirac delta function the filter's window will re-appear, complete with negative values. Bicubic interpolation has a similar problem. In terms of image processing, this may in some cases make the filter less suitable for images with sharp corners. 130.89.228.82 (talk) 01:35, 19 February 2008 (UTC)

Less suitable than what? All good interpolation filters have this property, because otherwise they're too soft. Dicklyon (talk) 01:49, 19 February 2008 (UTC)
Less suitable than a softer filter, perhaps. 130.89.228.82 (talk) 14:49, 19 February 2008 (UTC)
Perhaps, though at n=2 it's about like a soft cubic spline. For n=3 it's a bit sharper, which is usually judged to make it look better, not worse. Dicklyon (talk) 16:31, 19 February 2008 (UTC)