主题:高手帮帮忙,关于图像二值化
I=imread('L2.BMP');
I=double(I);
[W,H]=size(I);
I1=ones(W,H);
for i=1+8:1:W-8
for j=1+8:1:H-8
Block=I(i-8:i+8,j-8:j+8);
T=mean2(Block);
while 6,
Nh=sum(sum(histc(Block,T:256)));%%%%%%%%统计灰度值大于T的像素点数
Nl=17*17-Nh;
if abs(Nh-Nl)<=17*1.7
break;
else if Nh>Nl
T=T+3;
else if Nh<Nl
T=T-3;
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 ')
不知道是什么问题就是出不来图像。高手帮帮忙
I=double(I);
[W,H]=size(I);
I1=ones(W,H);
for i=1+8:1:W-8
for j=1+8:1:H-8
Block=I(i-8:i+8,j-8:j+8);
T=mean2(Block);
while 6,
Nh=sum(sum(histc(Block,T:256)));%%%%%%%%统计灰度值大于T的像素点数
Nl=17*17-Nh;
if abs(Nh-Nl)<=17*1.7
break;
else if Nh>Nl
T=T+3;
else if Nh<Nl
T=T-3;
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 ')
不知道是什么问题就是出不来图像。高手帮帮忙