主题:求助!!
帮忙看一下下面代码的意思
I_edge=zeros(height,width);
for i=1:width-1
I_edge(:,i)=abs(I(:,i+1)-I(:,i));
end
I_edge=(255/(max(max(I_edge))-min(min(I_edge))))*(I_edge-min(min(I_edge)));
[I_edge,y1]=select(I_edge,height,width); %%%%%%调用select函数
function [y,y1]=select(ImageData,h,w)
thr=0.5;delta=0.05;
%
y=(ImageData>=thr*mean(max(ImageData)));
BW2=bwareaopen(y,10);SE=strel('square',15);
IM2=imdilate(BW2,SE);
IM3=imerode(IM2,SE);
%
average=sum(sum(IM3))/(h*w);
while(average<0.03||average>0.08)%参数可能需要自己调整
% if(average<=0.005||average>=1)
% break;
%end
if(average<0.03)
thr=thr-delta;
else
thr=thr+delta;
end
y=(ImageData>=thr*mean(max(ImageData)));
BW2=bwareaopen(y,10);
IM2=imdilate(BW2,SE);
IM3=imerode(IM2,SE);
average=sum(sum(IM3))/(h*w);
end
y1=y;
y=IM3;
I_edge=zeros(height,width);
for i=1:width-1
I_edge(:,i)=abs(I(:,i+1)-I(:,i));
end
I_edge=(255/(max(max(I_edge))-min(min(I_edge))))*(I_edge-min(min(I_edge)));
[I_edge,y1]=select(I_edge,height,width); %%%%%%调用select函数
function [y,y1]=select(ImageData,h,w)
thr=0.5;delta=0.05;
%
y=(ImageData>=thr*mean(max(ImageData)));
BW2=bwareaopen(y,10);SE=strel('square',15);
IM2=imdilate(BW2,SE);
IM3=imerode(IM2,SE);
%
average=sum(sum(IM3))/(h*w);
while(average<0.03||average>0.08)%参数可能需要自己调整
% if(average<=0.005||average>=1)
% break;
%end
if(average<0.03)
thr=thr-delta;
else
thr=thr+delta;
end
y=(ImageData>=thr*mean(max(ImageData)));
BW2=bwareaopen(y,10);
IM2=imdilate(BW2,SE);
IM3=imerode(IM2,SE);
average=sum(sum(IM3))/(h*w);
end
y1=y;
y=IM3;