- 实验内容
(1)对图像进行线性点运算。
(2)对图像比例放大1.5倍,比例缩小0.7倍,非比例放大到600x700像素,非比例缩小到300x400像素。
(3)对图像旋转30度、60度、90度、135度和180度。 - 基本要求
理解图像线性点运算、图像缩放和旋转原理,掌握对图像进行线性点运算、图像缩放和旋转的实现方法,对实验结果进行分析,得出实验结论并撰写实验报告。
(1)代码:
picture=imread('lenagray.jpg'); %读取图像
picture=im2double(picture); %数据类型转换为double类型
figure;
subplot(2,2,1);
imshow(picture);
xlabel("原图");
a=1.5;b=50;
picture1=a .* picture + b/255;
subplot(2,2,2);
imshow(picture1);
xlabel("a=1.5 b=50");
a=0.3;b=50;
picture2=a .* picture + b/255;
subplot(2,2,3);
imshow(picture2);
xlabel("a=0.3 b=50");
a=-1;b=50;
picture3=a .* picture + b/255;
subplot(2,2,4);
imshow(picture3);
xlabel("a=-1 b=50");
结果
(2)代码:
picture=imread('lenagray.jpg');
picture=im2double(picture);
picture1=imresize(picture,1.5,'bicubic'); %三次内插法
picture2=imresize(picture,0.7,'bicubic');
picture3=imresize(picture,[600,700],'bicubic');
picture4=imresize(picture,[300,400],'bicubic');
figure;
subplot(3,2,1);
imshow(picture);
xlabel('原图');
subplot(3,2,3);
imshow(picture1);
xlabel('放大1.5倍');
subplot(3,2,4);
imshow(picture2);
xlabel('缩小0.7倍');
subplot(3,2,5);
imshow(picture3);
xlabel('放大到600x700像素');
subplot(3,2,6);
imshow(picture4);
xlabel('缩小到300x400像素');
结果:
(3)代码:
picture=imread('cameraman.tif');
picture=im2double(picture);
picture1=imrotate(picture,30,'bicubic');
picture2=imrotate(picture,60,'bicubic');
picture3=imrotate(picture,90,'bicubic');
picture4=imrotate(picture,135,'bicubic');
picture5=imrotate(picture,180,'bicubic');
figure;
subplot(3,2,1);
imshow(picture);
xlabel('原图像');
subplot(3,2,2);
imshow(picture1);
xlabel('旋转30度');
subplot(3,2,3);
imshow(picture2);
xlabel('旋转60度');
subplot(3,2,4);
imshow(picture3);
xlabel('旋转90度');
subplot(3,2,5);
imshow(picture4);
xlabel('旋转135度');
subplot(3,2,6);
imshow(picture5);
xlabel('旋转180度');