[FileName,PathName] = uigetfile('*.mat','Select the MAT-file','MultiSelect', 'on');
len=length(FileName); %图的个数
image=cell(1,len);
imagefilename=cell(1,len);
for k=1:len
imagefilename{k}=strcat(PathName,FileName{k});%读取多幅图
image{k}=load(imagefilename{k});
end
a=cell2mat(image{1});
num = 0;
a=cell2mat(image)
for k=1:len
tmp{k}=a(k).chl
end
[height,width]=size(tmp{k});%得到图的大小
imagearray=cell2mat(tmp);
for i=1:height %列
for j=1:width %行
for k=1:len %几幅图像
tempchl(k)=imagearray(i,width*(k-1)+j); %取几幅图同一个点
end
x=find(tempchl>=80|tempchl==0|isnan(tempchl)==true);%找到满足上述条件的值
m=length(x); %找到满足上述条件的值的个数
if m==len %是否和选中图片个数相等(是否所有图的此点都不可用)
chl(i,j)=0;%如果每张图的这个点都不可用,就给该点赋值为0
else tempchl(x)=[]; %满足上述条件的值变成空矩阵
h=tempchl; % 取剩下的数据
c=mean(h); %取剩下的数据的平均值
x=find(tempchl<=4*c);%找到小于等于4倍平均值的数据
m=tempchl(x);% 引用小于等于4倍平均值的数据
a=mean(h); %取剩下的数据平均值
chl(i,j)=a; %此值即为叶绿素浓度
end
end
end
save matfile chl
评论0