|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
出现死循环,不知是哪出错了,怎样修改WHILE语句
I=imread('L2.BMP');
[W,H]=size(I);
for i=1+8:1:W-8
for j=1+8:1:H-8
Block=I(i-8:i+8,j-8:j+8);%%%%%%%%%%%%%%%%%%%分成17*17的平滑窗口
T=mean2(Block);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%求块均值
while 6,
Nh=sum(sum(histc(Block,T:256)));%%%%%%%%统计灰度值大于T的像素点数
Nl=17*17-Nh;%%%%%%%%%%%%%%%%%%%%%%%%%%%%统计灰度值小于T的像素点数
if abs(Nh-Nl)<=17*1.7
break;
elseif Nh>Nl
T=T+1;
elseif Nh<Nl
T=T-1;
end
end
if I(i,j)>=T
I1(i,j)=255;
else I1(i,j)=0;
end
end
end
figure,imshow(I1),title('binary image ');
高手帮帮忙,不胜感激!!!!! |
|