# 高分求！！！双三次插值算法的实现代码

Angus_Li 2004-08-13 07:56:47

...全文
436 5 打赏 收藏 举报

5 条回复

allendragon 2005-03-07
ehom 牛人啊，四颗星阿，希望以后多交流，我的邮件是allenwjx@hotmail.com
• 打赏
• 举报

allendragon 2004-08-19

• 打赏
• 举报

ehom 2004-08-18

float b3spline(float value) {
if (value<0) value=-value;
float temp;
if (value<1) {
temp=sqr(value);
return 0.5*temp*value-temp+2/3;
}
else {
if (value<2) {
value=2-value;
return sqr(value)*value/6;
}
else return 0;
}
}
• 打赏
• 举报

allendragon 2004-08-17

float f_x, f_y, a, b, rr, gg, bb, r1, r2;
int i_x, i_y, xx, yy;
for(y=0; y<newimgh; y++)
{
f_y = (float) y * yScale;
i_y = (int) floor(f_y);
a = f_y - (float)floor(f_y);
for(x=0; x<newimgw; x++)
{
f_x = (float) x * xScale;
i_x = (int) floor(f_x);
b = f_x - (float)floor(f_x);

rr = gg = bb = 0.0F;
for(int m=-1; m<3; m++)
{
r1 = b3spline((float) m - a);
for(int n=-1; n<3; n++)
{
r2 = b3spline(-1.0F*((float)n - b));
xx = i_x+n+2;
yy = i_y+m+2;
if (xx<0) xx=0;
if (yy<0) yy=0;
if (xx>=pDoc->xdim) xx=pDoc->xdim - 1;
if (yy>=pDoc->ydim) yy=pDoc->ydim - 1;

pos = pDoc->CompPos(xx,yy,k);

voxnode = pDoc->myvoxarray[pos];
if(voxnode.flag != 255)
{
tmpt.x = (unsigned char) (255 * voxnode.matvalue[0]);
tmpt.y = (unsigned char) (255 * voxnode.matvalue[1]);
tmpt.z = (unsigned char) (255 * voxnode.matvalue[2]);

rr += (float)tmpt.x * r1 * r2;
gg += (float)tmpt.y * r1 * r2;
bb += (float)tmpt.z * r1 * r2;
}
}
}
resimg[y][x][0] = (unsigned char) rr;
resimg[y][x][1] = (unsigned char) gg;
resimg[y][x][2] = (unsigned char) bb;
}
}
• 打赏
• 举报

zzwu 2004-08-16

http://dev.csdn.net/Develop/article/15/15656.shtm
• 打赏
• 举报

4304

2004-08-13 07:56