matlab提供的是interp2函数由于实现图像的插值,主要的五种插值的基本方法都在这里啦。
话不多说,其他详细可以help帮助文档,直接上代码
load flujet.mat %加载图像
colormap gray %颜色图灰色即为灰度图
V = single(X(200:300,1:25));
%隔离图像的一小部分并将其投射为单精度。
subplot(231);
imagesc(V);%显示原始图片
title('Original Image')
Vq2 = interp2(V,2);
%通过在每个维度中将精制网格的点之间的间隔重复划分两次来插入内插值。
subplot(232);
imagesc(Vq2);%显示插值后的图片
% 放大倍数为2
title('Linear Interpolation')
subplot(233);
Vq3= interp2(V,3);
imagesc(Vq3);%显示三次插值后的图片
title('Cubic linear interpolation')
subplot(234);
Vq4= interp2(V,2,'linear');
imagesc(Vq4);%显示双线性内插值后的图片
title('Bilinear interpolation')
subplot(235);
Vq5= interp2(V,2,'spline');
imagesc(Vq5);%显示三次样条插值的图片
title('Cubic spline interpolation');
subplot(236);
Vq6= interp2(V,2,'cubic');
imagesc(Vq6);%显示三次方插值法,当数据有均匀间隔适用,否则与spline等效
title('Cubic interpolation');
效果如下: