申明:本文非笔者原创,原文转载自:http://blog.youkuaiyun.com/dakistudio/article/details/1767962
在Wikipedia (http://en.wikipedia.org/wiki/Bicubic_interpolation) 上找到了bicubic的描述,不过它只给出了知道导数情况下的公式。后来在优快云上找到了C语言的算法描述(http://topic.youkuaiyun.com/t/20021118/15/1186136.html),改造了一下做了个测试。他没有给出插值样条,通常使用sin(x
* PI) / x的逼近。
span::real Tessellation::sinxx(span::real value) {
if (value < 0) value = -value;
if (value < 1.0) {
span::real temp = value * value;
return 0.5 * temp * value - temp + 2.0 / 3.0;
}
else if (value < 2.0) {
value = 2.0 - value;
value *= value * value;
return value / 6.0;
}
else {
return 0.0;
}
}
if (value < 0) value = -value;
if (value < 1.0) {
span::real temp = value * value;
return 0.5 * temp * value - temp + 2.0 / 3.0;
}
else if (value < 2.0) {
value = 2.0 - value;
value *= value * value;
return value / 6.0;
}
else {
return 0.0;
}
}
以下是测试结果。
Nearest:

Bilinear:

Bicubic:

本文介绍了一种图像缩放算法——Bicubic插值,并提供了C语言实现的示例代码。文中还探讨了在不同情况下如何选择合适的插值方法,并给出了sin(x * PI)/x的近似公式。
995

被折叠的 条评论
为什么被折叠?



