首页 > 其他 > 详细

区域增长——初步学习

时间:2015-11-03 19:25:59      阅读:472      评论:0      收藏:0      [点我收藏+]

 Matlab中开发一个名为regiongrow的M函数来完成基本的区域生长

该函数为 [g,NR,SI,TI]=regiongrow(f,S,T) 输入中:f为输入图像,S为种子,T为阈值(标量时为全 局阈值) 输出中:g为分割后的图像,NR为连通区域的数目,SI为一幅 包含有种子点的图像。SI也为一幅图像,包含在连通性处理前, 通过阈值检测的像素。 

 

Matlab程序举例如下:(程序使用时候,regiongrow一定要先定义,这个我不用交吧?)

i=imread(‘eight.tif‘);

figure(1);imshow(i);

% i=doulbe(i);

[m,n]=size(i);

[y1,x1]=getpts;

x1=round(x1);y1=round(y1);

seed=[x1,y1];

th_mean=40;

yout=regiongrow(i,seed,th_mean);

figure(2);imshow(yout);title(‘区域增长‘);

%原图:

技术分享

%增长之后的:

技术分享


%%%%%%%%%%%%%%regiongrow区域增长
function yout=regiongrow(I,seed,th_mean)
[m,n]=size(I);
[I h]=size(seed);
yout=zeros(m,n);
for i=1:I
yout(seed(i,1),seed(i,2))=1;
end
for i=1:I
sum(seed(i,1),seed(i,2));
end
seed_mean=mean(sum);
ok=true;
s_star=1;
s_end=1;
while ok
ok=false;
for i=s_star:s_end
x=seed(i,1);
y=seed(i,2);
if x>2&&(x+1)<m&&y>2&&(y+1)<n
for u=-1:1
for v=-1:1
if yout(x+u,y+v)==0
avs(I(x+u,y+v)-seed_mean)<=th_mean
yout(x+u,y+v)=I
ok=true;
seed=[seed;[x+u,y+v]];
end
end
end
end
end
s_star=s_end+1;
[I h]=size(seed);
s_end=1
end

区域增长——初步学习

原文:http://www.cnblogs.com/natalie/p/4933912.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!