开发者

How to Resize using Lanczos

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?


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 ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜