没有合适的资源?快使用搜索试试~ 我知道了~
C# 双线性和双立方卷积插值
5星 · 超过95%的资源 需积分: 16 89 下载量 35 浏览量
2010-05-12
14:22:27
上传
评论
收藏 7KB TXT 举报
温馨提示
试读
6页
C#写的采用双线性和双立方卷积插值放大二维数组
资源推荐
资源详情
资源评论
/*
输入:float[,] dem_in:二维数字高程数组
float scaleX:宽度放大倍数
float scaleY:高度放大倍数
int interp_type:选择内插算法 0:双线性内插,1:双立方卷积内插
输出:float[,] dem_out:放大后的二维数字高程数组
例:
float[,] dem_out;
Zoom(dem_in, dem_out, 5, 10, 0); //采用双线性内插算法将dem_in的宽度放大5倍,高度放大10倍后存入dem_out中
或Zoom(dem_in, dem_out, 5, 1); //采用双立方卷积内插算法将dem_in放大5倍后存入dem_out中
附:
采用立方卷积内插算法时针对不同模型可调整参数a的值以实现最佳效果,a的典型值为-1, -0.5, -0.75, 0.5, 0.75, 1,默认值为-0.75
*/
public void Zoom(ref float[,] dem_in, out float[,] dem_out, float scaleX, float scaleY, int interp_type)
{
try
{
if (interp_type == 0)
{
Zoom_bilinear_interp(ref dem_in, out dem_out, scaleX, scaleY);
}
else if (interp_type == 1)
{
Zoom_cubic_interp(ref dem_in, out dem_out, scaleX, scaleY);
}
else
{
输入:float[,] dem_in:二维数字高程数组
float scaleX:宽度放大倍数
float scaleY:高度放大倍数
int interp_type:选择内插算法 0:双线性内插,1:双立方卷积内插
输出:float[,] dem_out:放大后的二维数字高程数组
例:
float[,] dem_out;
Zoom(dem_in, dem_out, 5, 10, 0); //采用双线性内插算法将dem_in的宽度放大5倍,高度放大10倍后存入dem_out中
或Zoom(dem_in, dem_out, 5, 1); //采用双立方卷积内插算法将dem_in放大5倍后存入dem_out中
附:
采用立方卷积内插算法时针对不同模型可调整参数a的值以实现最佳效果,a的典型值为-1, -0.5, -0.75, 0.5, 0.75, 1,默认值为-0.75
*/
public void Zoom(ref float[,] dem_in, out float[,] dem_out, float scaleX, float scaleY, int interp_type)
{
try
{
if (interp_type == 0)
{
Zoom_bilinear_interp(ref dem_in, out dem_out, scaleX, scaleY);
}
else if (interp_type == 1)
{
Zoom_cubic_interp(ref dem_in, out dem_out, scaleX, scaleY);
}
else
{
dem_out = new float[0, 0];
return;
}
}
catch(Exception e)
{
MessageBox.Show(e.Message.ToString());
dem_out = new float[0, 0];
return;
}
}
public void Zoom(ref float[,] dem_in, out float[,] dem_out, float scale, int interp_type)
{
Zoom(ref dem_in, out dem_out, scale, scale, interp_type);
}
private void Zoom_bilinear_interp(ref float[,] dem_in, out float[,] dem_out, float scaleX, float scaleY)
{
int originalHeight = dem_in.GetLength(0);
int originalWidth = dem_in.GetLength(1);
int newHeight = (int)(originalHeight * scaleY);
int newWidth = (int)(originalWidth * scaleX);
dem_out = new float[newHeight, newWidth];
float u = 0f, v = 0f, x = 0f, y = 0f;
int m = 0, n = 0;
for (int i = 0; i < newHeight; ++i)
{
return;
}
}
catch(Exception e)
{
MessageBox.Show(e.Message.ToString());
dem_out = new float[0, 0];
return;
}
}
public void Zoom(ref float[,] dem_in, out float[,] dem_out, float scale, int interp_type)
{
Zoom(ref dem_in, out dem_out, scale, scale, interp_type);
}
private void Zoom_bilinear_interp(ref float[,] dem_in, out float[,] dem_out, float scaleX, float scaleY)
{
int originalHeight = dem_in.GetLength(0);
int originalWidth = dem_in.GetLength(1);
int newHeight = (int)(originalHeight * scaleY);
int newWidth = (int)(originalWidth * scaleX);
dem_out = new float[newHeight, newWidth];
float u = 0f, v = 0f, x = 0f, y = 0f;
int m = 0, n = 0;
for (int i = 0; i < newHeight; ++i)
{
剩余5页未读,继续阅读
xiaobo_hg
- 粉丝: 6
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页