请高手指点下这MATLAB程序讲什么?

来源:百度知道 编辑:UC知道 时间:2024/06/05 16:19:37
clear all;
close all;
example=1; %This is the first image
A=load('testData.txt');
im=zeros(36,18);
for i=1:36
for j=1:18
im(i,j)=A(example,(i-1)*18+(j));
end
end
imagesc(im);
colormap gray;

请高手指点下这MATLAB程序讲什么?

clear all;
close all;
example=1; %This is the first image
A=load('testData.txt');
im=zeros(36,18);
for i=1:36
for j=1:18
im(i,j)=A(example,(i-1)*18+(j));
end
end
imagesc(im);
colormap gray;
回答:
clear all; %清除变量空间其他非常驻系统变量
close all; %关闭其他所有IMAGE
example=1; %This is the first image%初始化变量
A=load('testData.txt'); %装载某文本文件内的数据并保存到数组A中
im=zeros(36,18); %生成一个36*18的零矩阵
for i=1:36
for j=1:18
im(i,j)=A(example,(i-1)*18+(j)); %对生成的零矩阵赋值,按照指定规则
end
end
imagesc(im);
%使用imagesc绘制图像时,发现它的纵坐标值是从上至下一直增加的,
%与我们通常的习惯正好相反,
colormap gray;
%可以拖动上面的颜色块控制条改变位图颜色(双击)。
%一般是函数image()画出%的连续的灰度图使用。
%比如x为一个100*100阶数字矩阵,则image(x)可画出色彩连续的灰度图。

读入一个图像文件
然后显示出来