資源簡(jiǎn)介
matlab(邊界提取,鏈碼生成,差分鏈碼生成及頻率向量生成程序)具有旋轉(zhuǎn)不變性了的鏈碼

代碼片段和文件信息
function?B=boundaries(BWconndir)
%BOUNDARIES?Trace?object?boundaries.
%B=BOUNDARIES(BW)?traces?the?exterior?boundaries?of?objects?in?the?binary
%image?BW.B?is?a?p_by_1?cell?arraywhere?p?is?the?number?of?objects?in?the
%image.Each?cell?contains?a?Q_by_2?matrixeach?row?of?which?contains?the
%row?and?column?coordinates?of?a?boundary?pixel.Q?is?the?number?of?boundary
%pixels?for?the?corresponding?object.object?boundaries?are?traced?in?the
%clockwise?direction.
%
%B=BOUNDARIES(BWCONN)?specifies?the?connectivity?to?use?when?tracing?
%boundaries.CONN?may?be?either?8?or?4.The?default?value?for?CONN?is?8.
%
%B=BOUNDARIES(BWCONNDIR)?specifies?the?direction?used?for?tracing?
%boundaries.DIR?should?be?either?‘cw‘(trace?boundaries?clockwise)?or?
%‘ccw‘(trace?boundaries?counterclockwise).If?DIR?is?omitted?BOUNDARIES
%traces?in?the?clockwise?direction.
if?nargin<3???%nargin定義在用戶自定義函數(shù)體內(nèi),nargin返回
??????????????%用來調(diào)用函數(shù)的變量的個(gè)數(shù)。
????dir=‘cw‘;
end
if?nargin<2
????conn=8;
end
L=bwlabel(BWconn);?%返回值是矩陣L,大小同BW,包含了BW中的連通部分的標(biāo)記
%The?number?of?objects?is?the?maximum?value?of?L.Initialize?the?cell
%array(元包數(shù)組)B?so?that?each?cell?initially?contains?a?0_by_2?matrix.
numobjects=max(L(:));%尋找L中所作標(biāo)記中的最大值,這個(gè)最大值實(shí)際上就對(duì)應(yīng)著L中
%?包含的最多的連通部分的數(shù)目。
if?numobjects>0
????B={zeros(02)};%元包數(shù)組中僅包含一個(gè)元素。
????B=repmat(Bnumobjects1);%將B進(jìn)行numobjects*1個(gè)復(fù)制構(gòu)成新的B。
else
????B={};
end
%Pad?label?matrix?with?zeros.This?lets?us?write?the?boundary_following?loop
%without?worrying?about?going?off?the?edge?of?the?image.
Lp=padarray(L[1?1]0‘both‘);
%Compute?the?linear?indexing?offsets?to?take?us?from?a?pixel?to?its
%neighbors.
M=size(Lp1);%SIZE(X1)?returns?the?number?of?rows.?
?????????????
if?conn==8
????%Order?is?N?NE?E?SE?S?SW?W?NW.
????offsets=[-1M-1MM+11-M+1-M-M-1];
else
????%Order?is?N?E?S?W.
????offsets=[-1M1-M];
end
%next_search_direction_lut?is?a?lookup?table.Given?the?direction?from?pixel
%k?to?pixel?k+1what?is?the?direction?to?start?with?when?examining?the
%neighborhood?of?pixel?k+1?
if?conn==8
????next_search_direction_lut=[8?8?2?2?4?4?6?6];
else
????next_search_direction_lut=[4?1?2?3];
end
%next_direction_lut?is?a?lookup?table.Given?that?we?just?looked?at?neighbor
%in?a?given?directionwhich?neighbor?do?we?look?at?next?
if?conn==8
??next_direction_lut=[2?3?4?5?6?7?8?1];
else
??next_direction_lut=[2?3?4?1];
end
%Values?used?for?marking?the?starting?and?boundary?pixels.
START=-1;
BOUNDARY=-2;
%Initialize?scratch?space?in?which?to?record?the?boundary?pixels?as?well?as
%follow?the?boundary.
scratch=zeros(1001);
%Find?candidate?starting?locations?for?boundaries.
[rrcc]=find((Lp(2:end-1:)>0)&(Lp(1:end-2:)==0));
rr=rr+1;
for?k=1:length(rr)
????r=rr(k);
????c=cc(k);
????if?(Lp(rc)>0)&(Lp(r-1c)==0)&isempty(B{Lp(rc)})
????????%We‘ve?found?the?start?of?the?next?boundary.Compute?its?linear
????????%offsetrecord?which?boundary?it?ismark?itand?initialize?the
????????%counter?for?the?number?of?boundary?p
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????5689??2007-05-07?16:40??matlab(邊界提取鏈碼生成差分鏈碼生成及頻率向量生成程序)具有旋轉(zhuǎn)不變性了的鏈碼\boundaries.m
?????文件????????798??2007-05-10?10:12??matlab(邊界提取鏈碼生成差分鏈碼生成及頻率向量生成程序)具有旋轉(zhuǎn)不變性了的鏈碼\creatcode.m
?????文件????????886??2007-05-10?10:42??matlab(邊界提取鏈碼生成差分鏈碼生成及頻率向量生成程序)具有旋轉(zhuǎn)不變性了的鏈碼\creatfrequence.m
?????文件????????455??2007-05-10?10:41??matlab(邊界提取鏈碼生成差分鏈碼生成及頻率向量生成程序)具有旋轉(zhuǎn)不變性了的鏈碼\creatsubcode.m
?????文件???????1724??2007-05-10?16:30??matlab(邊界提取鏈碼生成差分鏈碼生成及頻率向量生成程序)具有旋轉(zhuǎn)不變性了的鏈碼\main.m
?????文件???????1819??2007-05-10?10:30??matlab(邊界提取鏈碼生成差分鏈碼生成及頻率向量生成程序)具有旋轉(zhuǎn)不變性了的鏈碼\singleimagecode.m
?????目錄??????????0??2007-05-15?15:29??matlab(邊界提取鏈碼生成差分鏈碼生成及頻率向量生成程序)具有旋轉(zhuǎn)不變性了的鏈碼
-----------?---------??----------?-----??----
????????????????11371????????????????????7
評(píng)論
共有 條評(píng)論