Line | |
---|
1 | % C = bord(A,n,m) |
---|
2 | % Puts a border of width m (default m=1) around image A |
---|
3 | % and gives it value n. If n = NaN: mirror image values. |
---|
4 | function C = bord(A,n,m); |
---|
5 | if nargin == 2; m=1; end |
---|
6 | [x,y] = size(A); |
---|
7 | if m > min(x,y) |
---|
8 | mm = min(x,y); |
---|
9 | C = bord(A,n,mm); |
---|
10 | C = bord(C,n,m-mm); |
---|
11 | return |
---|
12 | end |
---|
13 | if isnan(n) |
---|
14 | C = [A(:,m:-1:1),A,A(:,y:-1:y-m+1)]; |
---|
15 | C = [C(m:-1:1,:);C;C(x:-1:x-m+1,:)]; |
---|
16 | else |
---|
17 | bx = ones(x,m)*n; |
---|
18 | by = ones(m,y+2*m)*n; |
---|
19 | C = [by;[bx,A,bx];by]; |
---|
20 | end |
---|
21 | return |
---|
22 | |
---|
Note: See
TracBrowser
for help on using the repository browser.