Image 2x downsampling with Lanzos filter

I am trying to implement image downsampling using Lanczos2.

However, the kernel seems to have zeros everywhere (since sin (pi * x) = 0 if x is an integer) except for the center pixel .

Thus, if the downsampling ratio is an integer (for example, the output file size is 1/2 of the original size in each dimension), then Lanczos downsampling gives the same result as nearest neighbor interpolation (just taking all other pixels in 2X downsampling).

I believe this is not the case, so my question is: What am I missing?

How can I use lanczos2 filter for 2x downsampling and the result will be different than just taking any other pixel?

+3


source to share


1 answer


The kernel for 2x downsampling is given in "Decimating by 2 with Lanczos2 sinc" on page 10 of the link you linked , with the ratios:

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 with values x=0.5n

, where n

is the sample number (integer). This reflects the fact that the output rate is half the original sampling rate (this requires a half-band filter before decimating pixels to avoid anti-aliasing).

PS: a kernel with zeros everywhere but the center pixel you got will usually be used (although implementations will usually optimize this kernel as a simple copy of the pixel) in conjunction with a 1/2 phase kernel to interpolate by 2x.

+3


source







All Articles