我需要在c代码中实现以下公式:resampling,因此我使用多维插值方法:

其中L(x-i)或L(y-i)是:

我使用ppm图像格式,通过一个小脚本获得rgb值。这是我现在实际的lanczos方法:
double _L(int param) {
/*
LANCZOS KERNEL
*/
int a = 2; // factor "a" from formula
if(param == 0) {
return 1;
}
if(abs(param) > 0 && abs(param) < a) {
return (a*sin(PI*param) * sin((PI*param)/a))/(PI*PI*param*param)
}
return 0;
}
void lanczos_interpolation(PPMImage *img) {
if(img) {
int start_i, start_j, limit_i, limit_j;
int a = 2; // factor "a" from formula
samples_ij = img->x*img->y; // "sij" from formula
for(x = 0;x < img->x;x++) {
for(y = 0;y = < img->y;y++) {
start_i = floor(x)-a+1:
limit_i = floor(x)+a;
for(i = start_i;i <= limit_i;i++) {
start_j = floor(y)-a+1:
limit_j = floor(y)+a;
for(i = start_i;i <= limit_i;i++) {
img->data[x+(W*y)].red = (int)(samples_ij * _L(x-i) * _L(y-j)) // "_L" represents "L(x-i)" from formula
img->data[x+(W*y)].green = (int)(samples_ij * _L(x-i) * _L(y-j)) // "_L" represents "L(x-i)" from formula
img->data[x+(W*y)].blue = (int)(samples_ij * _L(x-i) * _L(y-j)) // "_L" represents "L(x-i)" from formula
}
}
}
}
}
}代码的这一部分让我很困惑:
img->data[x+(W*y)].red = (int)(samples_ij * _L(x-i) * _L(y-j)) // "_L" represents "L(x-i)" from formula
img->data[x+(W*y)].green = (int)(samples_ij * _L(x-i) * _L(y-j)) // "_L" represents "L(x-i)" from formula
img->data[x+(W*y)].blue = (int)(samples_ij * _L(x-i) * _L(y-j)) // "_L" represents "L(x-i)" from formula有人能帮我处理c中的lanczos插值吗?这是我的完整C文件:
谢谢!
发布于 2015-12-11 18:40:30
请看,您是,没有在代码中进行任何形式的插值。
插值操作如下:
input pixels => Lanczos interpolation => output interpolated pixels
|
|
V
a sum operation in the neighbourhood
of the corresponding location
in the input image你的问题如下:
Lanczos interpolation technique。事实上,你似乎不知道什么是插值。input pixels和output pixels。summation。(您只是将Lanczos高效时间s_ij分配给img像素。同样,s_ij的像素值实际上是公式中的input像素值,但是将图像中像素总数的固定值分配给s_ij。floor(*)函数。我对你的建议是:
https://stackoverflow.com/questions/34198553
复制相似问题