有没有MATLAB大神帮我把这条程序逐句的翻译一下 20
C=imread('bule.png');figure,imshow(C);title('原始灰度图像');count=imshow(C);%直方图统计[r,t]=siz...
C=imread('bule.png');
figure,imshow(C);title('原始灰度图像');
count=imshow(C); %直方图统计
[r,t]=size(C);
N=r*t;
L=256;
count=count/N;
for i=2:L
if count(i)~=1;
st=i-1;
break
end
end
for i=L:-1:1
if count(i)~=0;
nd=i-1;
break
end
end
f=count(st+1:nd+1);
p=st;q=nd-st;
u=0;
for i=1:q;
u=u+f(i)*(p+i-1);
ua(i)=u;
end
for i=1:q;
w(i)=sum(f(1:i));
end
d=(u*w-ua).^2./(w.*(1-w));
[y,tp]=max(d);
th=tp+p;
if th<=160
th=tp+p;
else
th=160;
end
Y1=zeros(r,t);
for i=1:r
for j=1:t
X1(i,j)=double(C(i,j));
end
end
for i=1:r
for j=1:t
if (X1(i,j)>=th)
Y1(i,j)=X1(i,j);
else
Y1(i,j)=0;
end
end
end
figure,imshow(Y1);title('灰度门限分割的图像') 展开
figure,imshow(C);title('原始灰度图像');
count=imshow(C); %直方图统计
[r,t]=size(C);
N=r*t;
L=256;
count=count/N;
for i=2:L
if count(i)~=1;
st=i-1;
break
end
end
for i=L:-1:1
if count(i)~=0;
nd=i-1;
break
end
end
f=count(st+1:nd+1);
p=st;q=nd-st;
u=0;
for i=1:q;
u=u+f(i)*(p+i-1);
ua(i)=u;
end
for i=1:q;
w(i)=sum(f(1:i));
end
d=(u*w-ua).^2./(w.*(1-w));
[y,tp]=max(d);
th=tp+p;
if th<=160
th=tp+p;
else
th=160;
end
Y1=zeros(r,t);
for i=1:r
for j=1:t
X1(i,j)=double(C(i,j));
end
end
for i=1:r
for j=1:t
if (X1(i,j)>=th)
Y1(i,j)=X1(i,j);
else
Y1(i,j)=0;
end
end
end
figure,imshow(Y1);title('灰度门限分割的图像') 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询