source: issm/trunk-jpl/src/m/morphological/dilation.m@ 14520

Last change on this file since 14520 was 14520, checked in by Eric.Larour, 12 years ago

NEW: morphological operations

File size: 399 bytes
Line 
1function mask=dilation(mask,neighboorhood)
2%deletion algorithm using 4 pixel neighboors.
3
4%convolve:
5
6matrix=ones(3,3);
7
8%4 neighboorhood:
9%corners
10if neighboorhood==4,
11 matrix(1,1)=0;
12 matrix(1,3)=0;
13 matrix(3,1)=0;
14 matrix(3,3)=0;
15end
16%center
17matrix(2,2)=0;
18
19%convolve mask:
20mask=filter2(matrix,~mask,'same');
21pos=find(mask~=0); mask(pos)=1;
22
23%opposite to recover the foreground:
24mask=~mask;
Note: See TracBrowser for help on using the repository browser.