資源簡介
8領(lǐng)域邊界跟蹤 圖像處理 matlab 完全原創(chuàng) 效果很好 歡迎下載
代碼片段和文件信息
function?edge_follow(I)
%edge_follow(I)用以跟蹤手的邊界
%I為輸入的二值圖像文件名
%im_edge.bmp是提取的邊沿圖像
imbw=imread(I);
[MN]=size(imbw);
Itemp=zeros(M+2N+2);?
im_edge=Itemp;?????????????????????????????????????????????????????
Itemp(2:(M+1)2:(N+1))=imbw;
%im_edge?=?im_edge?-?imerode(im_edge[0?1?0?;?1?1?1?;?0?1?0]);?%??????????????????
%im_edge?=?bwmorph(im_edge‘thin‘Inf);???????????????????????????????????????????????
[rowcol]=find(Itemp1);??????????????????????????????????????????????????????
x0=row;
y0=col;
ended=0;
MAJ=[6?6?0?0?2?2?4?4];?
direction=4;
while(ended==0)
????found_next=0;??????
?????while(found_next==0)
????????switch?mod(direction8)
????????????case?0
????????????????if?(Itemp(row?col+1)==1)
????????????????????row=row;
????????????????????col=col+1;
????????????????????im_edge(rowcol)=1;
????????????????????found_next=1;
????????????????end;
????????????case?1;
????????????????if?(Itemp(row+1?col+1)==1)
????????????????????row=row+1;
????????????????????col=col+1;
????????????????????im_edge(rowcol)=1;
????????????????????found_next=1;
????????????????end;
????????????case?2;
????????????????if?(Itemp(row+1?col)==1)
????????????????????row=row+1;
????????????????????col=col;
????????????????????im_edge(rowcol)=1;
????????????????????found_next=1;
????????????????end;
????????????case?3;
????????????????if?(Itemp(row+1?col-1)==1)
????????????????????row=row+1;
????????????????????col=col-1;
????????????????????im_edge(rowcol)=1;
????????????????????found_next=1;
????????????????end;
????????????case?4;
????????????????if?(Itemp(row?col-1)==1)
????????????????????row=row;
????????????????????col=col-1;
????????????????????im_edge(rowcol)=1;
????????????????????found_next=1;
????????????????end;
????????????case?5;
????????????????if?(Itemp(row-1?col-1)==1)
????????????????????row=row-1;
????????????????????col=col-1;
????????????????????im_edge(rowcol)=1;
????????????????????found_next=1;
????????????????end;
????????????case?6;
????????????????if?(Itemp(row-1?col)==1)
????????????????????row=row-1;
????????????????????col=col;
????????????????????im_edge(rowcol)=1;
????????????????????found_next=1;
????????????????end;
????????????case?7;
????????????????if?(Itemp(row-1?col+1)==1)
????????????????????row=row-1;
????????????????????col=col+1;
????????????????????im_edge(rowcol)=1;
????????????????????found_next=1;
????????????????end;
????????????????
????????end
????????if?(found_next==0)?direction=direction+1;?end;
????????
????end
????
????if(and((x0==row)(y0==col)))
????????ended=1;?
????end;
????%direction?=?mod((direction+3)8)+1;
????direction?=?MAJ((mod(direction8)+1));
end
imwrite(im_edge‘im_edge.bmp‘‘bmp‘);
figure;
imshow(im_edge);
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????2857??2010-04-16?13:35??edge_follow.m
-----------?---------??----------?-----??----
?????????????????2857????????????????????1
評論
共有 條評論