如何使用 Lanczos 调整大小
我可以轻松计算 Lanczos 中使用的 sinc(x) 曲线的值,并且我已经阅读了之前有关 Lanczos 调整大小的解释,但作为这个领域的新手,我不明白如何实际应用它们。
用 lanczos 重新采样想象一下你 将输出和输入覆盖 彼此,用点表示 像素位置在哪里。为了 您采取的每个输出像素位置 box +- 3 输出像素 观点。对于每个输入像素 在该框中,计算 该位置的 lanczos 函数 与输出的距离 输出像素坐标中的位置 作为参数。然后你需要 将计算值归一化为 缩放它们,使它们加起来为 1。 之后乘以每个输入像素 具有相应缩放比例的值 值并将结果相加 获取输出像素的值。
- 例如,“叠加输入和输出”在编程术语中实际上意味着什么?
- 在给定的等式中 lanczos(x) = { 如果 abs(x) > 则为 0 3、 1 如果 x == 0, 否则 sin(x*pi)/x } x 是什么?
作为一个简单的例子,假设我有一个包含 14 个值的输入图像(即在地址 In0-In13 中): 20 25 30 35 40 45 50 45 40 35 30 25 20 15
我想将其放大2,即具有28个值的图像(即在地址Out0-Out27中)。
显然,地址 Out13 中的值将与地址 In7 中的值类似,但我实际上应该乘以哪些值来计算 Out13 的正确值? 算法中的x是什么?
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.
- For example, what does "overlay the input and output" actually mean in programming terms?
- 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果输入数据中的值位于 t 坐标 [0 1 2 3 ...],则输出(按比例放大 2)的 t 坐标位于 [0 .5 1 1.5 2 2.5 3 ...]。因此,要获得第一个输出值,请将过滤器以 0 为中心并乘以所有输入值。然后,为了获得第二个输出,您将滤波器置于 1/2 中心并乘以所有输入值。 ETC ...
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 ...