数字图像处理-函数矩阵
1 题目一
1.1 实验题目
1)随机生成一个 0-1 的 8 行 10 列的矩阵,将小于 0.5 的数赋值为 0,大于 0.5 的数赋值为 1
2)利用循环给数组赋值,并用 image 函数显示
1.2 程序源代码
A = rand(8,10);
B = A;
disp(A);
subplot(2,1,1);
image(A);
title('原始矩阵');
for count_i = 1:8
for count_j = 1:10
if A(count_i, count_j) < 0.5
B(count_i, count_j) = 0;
else
B(count_i, count_j) = 1;
end
end
end
disp(B);
subplot(2,1,2);
image(B);
title('处理结果');
1.3 运行结果
2 题目二
2.1 实验题目
阐述并配合必要的运行结果展示 imshow 和 image 区别与联系;
2.2 题目解答
image 是用来显示附标图像,即显示的图像上有 x,y 坐标轴的显示,可以看到图像 的像素大小。imshow 只是显示图像。
2.3 程序代码说明
A = imread('testjpg.jpg');
x1 = A(:,:,1);
x2 = A(:,:,2);
x3 = A(:,:,3);
figure(1)
subplot(2,2,1),imshow(A)
subplot(2,2,2),imshow(x1)
subplot(2,2,3),imshow(x2)
subplot(2,2,4),imshow(x3)
figure(2)
subplot(2,2,1),image(A)
subplot(2,2,2),image(x1)
subplot(2,2,3),image(x2)
subplot(2,2,4),image(x3)