I'm trying to implement image downsampling with Lanczos2.
However, the kernel seems to have zeros everywhere (since sin(pi*x)=0 if x is integer) except at the center pixel.
Thus, if the downsampling factor is an integer number (e.g. the output size is 1/2 of the original size at each dimension), then the Lanczos downsampling yields the exact same result as nearest neighbor interpolation (just taking every other pixel in 2X downsampling).
I believe that this is not intended to be the case, so my question is: What am I missing?
How to use lanczos2 filter for 2x downsampling and is the result expected to be different than simply take every other pixel?
The kernel for 2x downsampling is given in section "Decimation by factor of 2 with the Lanczos2 sinc function" on page 10 of the reference you linked, with the coefficients:
0, -0.032, 0, 0.284, 0.496, 0.284, 0, -0.032, 0
This kernel is obtained by evaluating the given lanczos2(x) function at values of x=0.5n
where n
is the sample number (an integer). This reflect the fact that the output rate is half the original sampling rate (thus requires a half-band filter before pixel decimation to avoid aliasing).
P.S.: the kernel with zeros everywhere except at the center pixel that you have obtained, would typically be used (although implementations would usually optimize this kernel out as a simple pixel copy) in conjunction with a phase 1/2 kernel for interpolation by a factor 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With