实验项目03 图像基本运算

文章详细描述了如何在Matlab中对lena.jpg和cameraman.tif图像进行线性点运算、比例缩放(包括非比例)以及不同角度的旋转实验。实验内容涉及图像处理的基本原理和具体操作步骤,要求读者理解和实践相关技术。
摘要由CSDN通过智能技术生成

1. 实验内容

1)对图像进行线性点运算。

2)对图像比例放大1.5倍,比例缩小0.7倍,非比例放大到600x700像素,非比例缩小到300x400像素。

3)对图像旋转30度、60度、90度、135度和180度。

2. 基本要求

理解图像线性点运算、图像缩放和旋转原理,掌握对图像进行线性点运算、图像缩放和旋转的实现方法,对实验结果进行分析,得出实验结论并撰写实验报告。

备注:(1)以lenagray.jpg图像为例,设置输入/输出变换的灰度范围,a=1.5,b=50,a=0.3,b=50,a=-1,b=50,分别图像进行线性点运算。参考课本30-31做实验写实验报告

(2)以lenagray.jpg图像为例对图像比例放大1.5倍,比例缩小0.7倍,非比例放大到600x700像素,非比例缩小到300x400像素。参考课本47-48做实验写实验报告

(3)cameraman.tif图像为例对图像旋转30度、60度、90度、135度和180度。参考课本43-44做实验写实验报告

(4)用title在图像上方标明实验人,用xlabel在图像下方表明图像所对应的操作(参数),用subplot把每一个实验的图像放到同一个figure下

% 读取图像
originalImage = imread('lenagray.jpg');

% 定义不同的a和b值
a1 = 1.5;
b1 = 50;

a2 = 0.3;
b2 = 50;

a3 = -1;
b3 = 255;

% 对图像进行线性点运算
outputImage1 = a1 * double(originalImage) + b1;
outputImage2 = a2 * double(originalImage) + b2;
outputImage3 = a3 * double(originalImage) + b3;

% 将灰度值裁剪到[0, 255]范围内
outputImage1(outputImage1 < 0) = 0;
outputImage1(outputImage1 > 255) = 255;

outputImage2(outputImage2 < 0) = 0;
outputImage2(outputImage2 > 255) = 255;

outputImage3(outputImage3 < 0) = 0;
outputImage3(outputImage3 > 255) = 255;

% 将结果转换回uint8类型
outputImage1 = uint8(outputImage1);
outputImage2 = uint8(outputImage2);
outputImage3 = uint8(outputImage3);

% 显示原始图像和处理后的图像
subplot(2, 2, 1);
imshow(originalImage);
xlabel('原始图像');

subplot(2, 2, 2);
imshow(outputImage1);
xlabel('a=1.5, b=50');

subplot(2, 2, 3);
imshow(outputImage2);
xlabel('a=0.3, b=50');

subplot(2, 2, 4);
imshow(outputImage3);
xlabel('a=-1, b=255');
% 读取图像
originalImage = imread('lenagray.jpg');

% 比例放大1.5倍
scaledUpImage = imresize(originalImage, 1.5);

% 比例缩小0.7倍
scaledDownImage = imresize(originalImage, 0.7);

% 非比例放大到600x700像素
nonProportionalScaledUpImage = imresize(originalImage, [700 600]);

% 非比例缩小到300x400像素
nonProportionalScaledDownImage = imresize(originalImage, [400 300]);

% 显示原始图像和处理后的图像
subplot(2, 3, 1); 
imshow(originalImage); 
xlabel('原始图像');

subplot(2, 3, 2); 
imshow(scaledUpImage); 
xlabel('比例放大1.5倍');

subplot(2, 3, 3); 
imshow(scaledDownImage); 
xlabel('比例缩小0.7倍');

subplot(2, 3, 4); 
imshow(nonProportionalScaledUpImage); 
xlabel('非比例放大(600x700)');

subplot(2, 3, 5); 
imshow(nonProportionalScaledDownImage); 
xlabel('非比例缩小(300x400)');
% 读取图像
originalImage = imread('cameraman.tif');

% 旋转图像并显示
rotated30 = imrotate(originalImage, 30, 'bilinear', 'crop');
rotated60 = imrotate(originalImage, 60, 'bilinear', 'crop');
rotated90 = imrotate(originalImage, 90, 'bilinear', 'crop');
rotated135 = imrotate(originalImage, 135, 'bilinear', 'crop');
rotated180 = imrotate(originalImage, 180, 'bilinear', 'crop');

figure;

% 显示原始图像和旋转后的图像
subplot(2, 3, 1); 
imshow(originalImage);
xlabel('原始图像');

subplot(2, 3, 2);
imshow(rotated30);
xlabel('旋转30度');

subplot(2, 3, 3);
imshow(rotated60);
xlabel('旋转60度');

subplot(2, 3, 4);
imshow(rotated90);
xlabel('旋转90度');

subplot(2, 3, 5);
imshow(rotated135); 
xlabel('旋转135度');

subplot(2, 3, 6); 
imshow(rotated180); 
xlabel('旋转180度');

作者:henu 计算机与信息工程学院 空午

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值