Tesi Robotica Un co-processore per Stereo-Matching: Architettura | Page 47
i
i
“LP_Tesi” — 2011/9/9 — 21:20 — page 47 — #47
i
3.3. IMPLEMENTAZIONE MATLAB
i
47
Algoritmo 3.7 Function Track
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function [path2,path5] = Track(gapWest, gapNorth, diag, row, col, path2,
path5)
if( ((row > 0)&&(col > 0)) && path2(row,col)==0)
path2(row,col) = 1;
if( gapNorth(row,col)==1 )
if( path5(1,1,2) == 0 )
idx = find(gapNorth(:,col) == 0);
last_idx = find(idx <= row);
next_row = idx(last_idx(end));
path5(next_row+1:row,col,3) = 1;
else next_row = row - 1;
end
path5(row,col,3) = 1;
[path2,path5]=Track(gapWest,gapNorth,diag,next_row,col,path2,path5);
end
15
if( diag(row,col)==1 )
path5(row,col,2) = 1;
[path2,path5]=Track(gapWest,gapNorth,diag,row-1,col-1,path2,path5);
end
16
17
18
19
20
if( gapWest(row,col)==1 )
if( path5(1,1,2) == 0 )
idx = find(gapWest(row,:) == 0);
last_idx = find(idx <= col);
next_col = idx(last_idx(end));
path5(row,next_col+1:col,1) = 1;
else next_col = col - 1;
end
path5(row,col,1) = 1;
[path2,path5]=Track(gapWest,gapNorth,diag,row,next_col,path2,path5);
end
21
22
23
24
25
26
27
28
29
30
31
32
end
1. Base: Se i valori degli indici row e col sono minori di 1 fermati e ritorna
[riga 2].
2. Induzione: Leggi le matrici delle direzioni nella cella di indice (row, col)
[righe 5,16,21], nel caso in cui sia presente il valore 1:
i
i
i
i