麻烦高手给我解答一下这个程序的每一步什么意思,很着急,拜托了!!我没接触过matlab,拜托各位大侠了!!

clear;
close all;
flag=1;
while flag
file=input('Please Input File Name: ','s');
if file==' '
flag=0;
else
close all;
Data=imread(file);
range=size(Data);
proportion=4800/range(2);
imagesc(Data);
colormap(gray);
axis off;
%h=axes('position','default');
%set(h,'XTick',[0:range(2)/8:range(2)]);
[x1,y1]=ginput(2);
y=round(y1);
x=round(x1);
%line(x1(1:2),y1(1:2),'color',[0.7,0.7,0.7],'linestyle',':');
a=x(1);
b=y(1);
w=x(2)-x(1);
h=y(2)-y(1);
rectangle('position',[a,b,w,h],'Curvature',[0,0]);
s=x(1):x(2);
%xaxeslength=(x(2)-x(1))*proportion;
newarea=Data(y(1):y(2),s);
grayscale=mean(newarea);
aver=mean(grayscale);
figure(2);
plot(s*proportion,grayscale);
end;
end;

clear;
close all;
flag=1;
while flag
file=input('Please Input File Name: ','s'); %输入图像文件名
if file==' '%如果文件名为空格,就退出,否则读入文件
flag=0;
else
close all;%关闭所有图像
Data=imread(file);%读入图像文件
range=size(Data);%range为图像大小
proportion=4800/range(2);%得到图像比例
imagesc(Data);%显示图像
colormap(gray);%按灰度显示
axis off;%不显示坐标轴
%h=axes('position','default');
%set(h,'XTick',[0:range(2)/8:range(2)]);
[x1,y1]=ginput(2);%通过鼠标点击输入x1,y1坐标值,得到矩形的对角顶点
y=round(y1);%x1,y1取整
x=round(x1);
%line(x1(1:2),y1(1:2),'color',[0.7,0.7,0.7],'linestyle',':');
a=x(1);
b=y(1);
w=x(2)-x(1);%鼠标点击所得矩形的宽
h=y(2)-y(1);%%鼠标点击所得矩形的高
rectangle('position',[a,b,w,h],'Curvature',[0,0]);%画矩形
s=x(1):x(2);%s是x(1)到x(2)的矢量
%xaxeslength=(x(2)-x(1))*proportion;
newarea=Data(y(1):y(2),s);%newarea就是所选的矩形区域在图像矩阵中对应的新矩阵
grayscale=mean(newarea);%新矩阵按列取平均,得每列的灰度值
aver=mean(grayscale);%取灰度值的平均值
figure(2);
plot(s*proportion,grayscale);%画出灰度值与横坐标关系的图像
end;
end;
温馨提示:答案为网友推荐,仅供参考
相似回答