我需要在 c 代码中实现以下公式: https ://en.wikipedia.org/wiki/Lanczos_resampling 因此我使用多维插值方法:
其中 L(xi) 或 L(yi) 是:
我正在使用 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 文件:
谢谢!