【Matlab】图像插值函数interp2理解

转自 点击打开链接

图像插值就是利用已知邻近像素点的灰度值(或rgb图像中的三色值)来产生未知像素点的灰度值,以便由原始图像再生出具有更高分辨率的图像。

通过例子来理解interp2函数:

[X,Y] = meshgrid(-3:3); %产生网格坐标
V = peaks(X,Y);         %通过网格坐标计算函数值,产生三维凹凸面
figure
surf(X,Y,V)
title('Original Sampling');%原始面

 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

原始面

进行插值

[Xq,Yq] = meshgrid(-3:0.25:3);  %产生插值所需要的网格
Vq = interp2(X,Y,V,Xq,Yq);      %通过对V线性插值(默认的)得到新的面Vq
figure
surf(Xq,Yq,Vq);
title('Linear Interpolation Using Finer Grid');

 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

插值结果

使用格式: 
Vq = interp2(X,Y,V,Xq,Yq) 
Vq = interp2(V,Xq,Yq) 
Vq = interp2(V) 
Vq = interp2(V,k) 
Vq = interp2(_,method) 
Vq = interp2(_,method,extrapval)

输入:

  • X,Y — Sample grid points 
    matrices | vectors

  • V — Sample values 
    matrix

  • Xq,Yq — Query points 
    scalars | vectors | matrices | arrays
  • k — Refinement factor 
    1 (default) | real, nonnegative, integer scalar
  • method — Interpolation method 
    ‘linear’ (default) | ‘nearest’ | ‘cubic’ | ‘spline’
  • extrapval — Function value outside domain of X and Y 
    scalar

输出:

  • Vq — Interpolated values 
    scalar | vector | matrix

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值