views:

378

answers:

1

I can easily calculate the values for sinc(x) curve used in Lanczos, and I have read the previous explanations about Lanczos resize, but being new to this area I do not understand how to actually apply them.

To resample with lanczos imagine you overlay the output and input over eachother, with points signifying where the pixel locations are. For each output pixel location you take a box +- 3 output pixels from that point. For every input pixel that lies in that box, calculate the value of the lanczos function at that location with the distance from the output location in output pixel coordinates as the parameter. You then need to normalize the calculated values by scaling them so that they add up to 1. After that multiply each input pixel value with the corresponding scaling value and add the results together to get the value of the output pixel.

  1. For example, what does "overlay the input and output" actually mean in programming terms?
  2. In the equation given lanczos(x) = { 0 if abs(x) > 3, 1 if x == 0, else sin(x*pi)/x } what is x?


As a simple example, suppose I have an input image with 14 values (i.e. in addresses In0-In13): 20 25 30 35 40 45 50 45 40 35 30 25 20 15

and I want to scale this up by 2, i.e. to an image with 28 values (i.e. in addresses Out0-Out27).

Clearly, the value in address Out13 is going to be similar to the value in address In7, but which values do I actually multiply to calculate the correct value for Out13? What is x in the algorithm?

A: 

If the values in your input data is at t coordinates [0 1 2 3 ...], then your output (which is scaled up by 2) has t coordinates at [0 .5 1 1.5 2 2.5 3 ...]. So to get the first output value, you center your filter at 0 and multiply by all of the input values. Then to get the second output, you center your filter at 1/2 and multiply by all of the input values. Etc ...

MPG
Great, thanks!So when multiplying by the input values, you take the input value and multiply by the value of the Lanzcos filter at that point, sum them and normalise (based upon the the total value of the Lanczos filter coefficients used).So how many inputs do you use? All that lie within the +/-3 of the Lanczos filter presumably?
Tom