【Matlab】图像插值函数interp2了解
【Matlab】图像插值函数interp2理解
图像插值就是利用已知邻近像素点的灰度值(或rgb图像中的三色值)来产生未知像素点的灰度值,以便由原始图像再生出具有更高分辨率的图像。
通过例子来理解interp2函数:
[X,Y] = meshgrid(-3:3); %产生网格坐标
V = peaks(X,Y); %通过网格坐标计算函数值,产生三维凹凸面
figure
surf(X,Y,V)
title('Original Sampling');%原始面
进行插值
[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');
使用格式:
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 | vectorsV — 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