我在哪里可以找到有关双立方插值和兰克泽斯重采样很好看的?我在、立方、可以找到、很好看

2023-09-11 02:07:09 作者:念旧情都是二百五 °

我要实现上述两个图像重采样算法(双三次和兰克泽斯)在C ++中。我知道,有几十个现有实现的在那里,但我还是想使自己的。我希望把它部分是因为我想了解他们的工作,部分原因是因为我想给他们主流的实现不是发现了一些功能(如可配置的多CPU的支持和进度报告)。

I want to implement the two above mentioned image resampling algorithms (bicubic and Lanczos) in C++. I know that there are dozens of existing implementations out there, but I still want to make my own. I want to make it partly because I want to understand how they work, and partly because I want to give them some capabilities not found in mainstream implementations (like configurable multi-CPU support and progress reporting).

我试过阅读维基百科,但东西是有点太干我。也许还有这些算法的一些更好的解释吗?我找不到对SO或谷歌。

I tried reading Wikipedia, but the stuff is a bit too dry for me. Perhaps there are some nicer explanations of these algorithms? I couldn't find anything either on SO or Google.

补充:好像没有人可以给我更多有关这些主题一个很好的链接。任何人都可以至少试着在这里解释一下呢?

Added: Seems like nobody can give me a good link about these topics. Can anyone at least try to explain them here?

推荐答案

这两种算法的基本工作原理是pretty的简单。他们都卷积过滤器。甲,对于每个输出值移动卷积函数原点上的输出为中心,然后卷积滤波器相乘在输入与在该位置的卷积函数的值的所有值并将它们相加。

The basic operation principle of both algorithms is pretty simple. They're both convolution filters. A convolution filter that for each output value moves the convolution functions point of origin to be centered on the output and then multiplies all the values in the input with the value of the convolution function at that location and adds them together.

卷积的一个特性是,输出的积分的两个输入函数的积分的乘积。如果考虑输入和输出的图像,然后将积分装置平均亮度,如果你想的亮度保持不变卷积函数的积分需要加起来之一。

One property of convolution is that the integral of the output is the product of the integrals of the two input functions. If you consider the input and output images, then the integral means average brightness and if you want the brightness to remain the same the integral of the convolution function needs to add up to one.

如何理解它们的一种方式是考虑卷积函数作为东西,显示多输入像素是如何影响输出像素根据它们的距离的

One way how to understand them is to think of the convolution function as something that shows how much input pixels influence the output pixel depending on their distance.

卷积功能通常被定义,使他们都为零时的距离小于一定值时,这样你就不用考虑每一个输出值每个输入值。

Convolution functions are usually defined so that they are zero when the distance is larger than some value so that you don't have to consider every input value for every output value.

有关的Lanczos插值卷积函数基于所述的的sinc(x)的=的sin(x 的圆周率)/ X_函数,但只能前几个裂片会被执行。通常3:

For lanczos interpolation the convolution function is based on the sinc(x) = sin(xpi)/x_ function, but only the first few lobes are taken. Usually 3:

lanczos(x) = {
    0 if abs(x) > 3,
    1 if x == 0,
    else sin(x*pi)/x
}

这个函数被调用过滤器内核。

This function is called the filter kernel.

要重新取样与兰克泽斯想象你覆盖的输出和输入过海誓山盟,配穴足见那里的像素位置的。对于每个输出像素位置,你拿一箱+ - 从3点输出像素。对于在于,盒子的每个输入像素,计算在与从输出像素的输出位置的距离该位置兰克泽斯函数的值坐标作为参数。然后,需要通过按比例缩放以便它们加起来1。之后乘以每个输入像素值与对应的缩放值正常化的计算值,然后将结果一起,以获得输出像素的值。

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.

由于lanzos功能具有可分性,如果您正在调整,电网正常,则可以通过水平做卷积优化这个和垂直方向分别和precalculate垂直过滤器为每个行和水平滤波器每个列。

Because lanzos function has the separability property and, if you are resizing, the grid is regular, you can optimize this by doing the convolution horizontally and vertically separately and precalculate the vertical filters for each row and horizontal filters for each column.

双三次卷积是基本相同的,不同的过滤器内核的功能。

Bicubic convolution is basically the same, with a different filter kernel function.

要获得更详细的,有一个pretty的书中数字图像处理好和彻底的解释 ,第16.3节。

To get more detail, there's a pretty good and thorough explanation in the book Digital Image Processing, section 16.3.

此外, image_operations.cc 和的