source: distools/private/bord.m @ 48

Last change on this file since 48 was 13, checked in by bduin, 14 years ago
File size: 492 bytes
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.
4function C = bord(A,n,m);
5if nargin == 2; m=1; end
6[x,y] = size(A);
7if m > min(x,y)
8        mm = min(x,y);
9        C = bord(A,n,mm);
10        C = bord(C,n,m-mm);
11        return
12end
13if 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,:)];
16else
17   bx = ones(x,m)*n;
18   by = ones(m,y+2*m)*n;
19   C = [by;[bx,A,bx];by];
20end
21return
22
Note: See TracBrowser for help on using the repository browser.