Hacker News new | ask | show | jobs
by dietrichepp 4862 days ago
I'd like to add that the reason we use windowed sinc is because we're lazy and it works well. There are techniques for making better FIR filters, e.g., Parks-McClellan/Remez for small filters or other techniques for larger ones.

Also, there is no inherent difference between upsampling and downsampling. Lowering the pitch of an audio sample is no harder than raising it, and in both cases you make the same tradeoff when designing the filter (aliasing, bandwidth, impulse response, and processing time).

The problem is with resizing images, because using the windowed sinc function makes the (incorrect) assumption that the desired result can be directly sampled from the band-limited input. The fact that we use Lanczos interpolation as the standard "high-quality" image interpolation algorithm shows that this assumption is false. (I should elaborate: Lanczos is still windowed sinc, but is subjectively better even though it has demonstrably higher amounts of aliasing than competing windows. Or rather, the assumption that is false is the assumption that the same priorities we use for designing filters for signal analysis can be used for resampling images.)

1 comments

I'm referring more specifically to mipmaps. They let you cheat when downsampling.
Well, yes and no. Mipmaps just make the process faster for a given level of quality by making the resampling ratios closer to 1.0. The closer the ratio gets to 1.0, the fewer filter coefficients you need.

The same thing is done in audio. If you want to upsample 64x, you can do it faster by upsampling 8x twice. Since the signal given to the second upsampler is already bandlimited, the filter can have a much longer falloff and use fewer coefficients.

This is exactly why you want to use a nice filter create the mipmapms but it's okay to use a simple bilinear filter for the final render.

(So what I'm saying is that you can also use mipmaps for upsampling, but nobody likes the storage requirements.)