J= imread('RoadG1.jpg');
[x,y]=size(J);
I=double(J);
z0=max(max(I)); % 求出图象中最大的灰度
z1=min(min(I)); % 最小的灰度
T=(z0+z1)/2;
TT=0;
S0=0; n0=0;
S1=0; n1=0;
allow=0.5; % 新旧阈值的允许接近程度
d=abs(T-TT);
count=0; % 记录几次循环
while(d>=allow) % 迭代最佳阈值分割算法
count=count+1;
for i=1:x
for j=1:y
if (I(i,j)>=T)
S0=S0+I(i,j);
n0=n0+1;
end
if (I(i,j)<T)
S1=S1+I(i,j);
n1=n1+1;
end
end
end
T0=S0/n0;
T1=S1/n1;
TT=(T0+T1)/2;
d=abs(T-TT);
T=TT;
end
Seg=zeros(x,y);
for i=1:x
for j=1:y
if(I(i,j)>=T)
Seg(i,j)=1; % 阈值分割的图象
end
end
end
J0=Seg;
SE=strel('rectangle', [6 4]); % 结构定义
IM=imopen(J0,SE); % “开”运算
figure,imshow(J); % 图9-7(a)
figure,imhist(J); % 图9-7(b)
figure,imshow(Seg); % 图9-7(c)
figure,imshow(IM); % 图9-7(d)
road.rar_agv
版权申诉
56 浏览量
2022-07-13
18:26:51
上传
评论
收藏 87KB RAR 举报
小贝德罗
- 粉丝: 71
- 资源: 1万+
最新资源
- comment.block.documentation.rust
- there is no way to distinguish perfectly
- 数据库管理工具:dbeaver-ce-24.0.2-x86-64-setup.exe
- Objective-C.tmLanguage
- 数据库管理工具:dbeaver-ce-24.0.2-macos-x86-64.dmg
- Delphi 12 控件之StyleControls 5.77.7z
- 苹果CMSV10红色自适应网站模板
- 数据库管理工具:dbeaver-ce-23.3.5-stable.x86-64.rpm
- SAP 消息号C6013解决方案
- C#入门必看的实例程序100个,含全部源代码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈