实验二 图像几何变换与插值
一、实验目的
巩固图像处理编程的步骤格式,理解数据插值及图像几何变换的原理,掌握图像几何变换的实现方法。
二、实验内容
1、 理解反向变换的实现思路
2、 图像缩放及插值 Matlab 取整命令:floor, ceil, round
分别实验最近邻插值和双线性插值
f=imread('lena.bmp');
beishu=0.5;
[row,col]=size(f);
r1=round(row*beishu);
c1=round(col*beishu);
b=zeros(r1,c1);
for i=1:r1
for j=1:c1
i1=round(i/beishu);
j1=round(j/beishu);
if i1<1
i1=1;
end
if j1<1
j1=1;
end
b(i,j)=f(i1,j1);
end
end
b=uint8(b);
figure;
imshow(f);
figure
imshow(b);
3、 图像旋转及插值
以图像中心为轴实现任意角度(逆时针为正)的图像旋转,分别实验两种插值算法
f=imread('lena.bmp');
B=imrotate(f,45,'nearest','crop');
C=imrotate(f,45,'bilinear','crop');
figure;
subplot(121);
imshow(f);
title('原图像');
subplot(122);
imshow(B);
title('最近邻插值');
figure;
subplot(121);
imshow(f);
title('原图像');
- 1
- 2
前往页