区域增长——初步学习
生活随笔
收集整理的這篇文章主要介紹了
区域增长——初步学习
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?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
上述代碼不太正確,重新弄個簡單的
轉載于:https://www.cnblogs.com/natalie/p/4933912.html
總結
以上是生活随笔為你收集整理的区域增长——初步学习的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: (王道408考研操作系统)第三章内存管理
- 下一篇: (王道408考研操作系统)第四章文件管理