Rev | Line | |
---|
[14520] | 1 | function mask=dilation(mask,neighboorhood)
|
---|
| 2 | %deletion algorithm using 4 pixel neighboors.
|
---|
| 3 |
|
---|
| 4 | %convolve:
|
---|
| 5 |
|
---|
| 6 | matrix=ones(3,3);
|
---|
| 7 |
|
---|
| 8 | %4 neighboorhood:
|
---|
| 9 | %corners
|
---|
| 10 | if neighboorhood==4,
|
---|
| 11 | matrix(1,1)=0;
|
---|
| 12 | matrix(1,3)=0;
|
---|
| 13 | matrix(3,1)=0;
|
---|
| 14 | matrix(3,3)=0;
|
---|
| 15 | end
|
---|
| 16 | %center
|
---|
| 17 | matrix(2,2)=0;
|
---|
| 18 |
|
---|
| 19 | %convolve mask:
|
---|
[14525] | 20 | convol=filter2(matrix,mask,'same');
|
---|
[14520] | 21 |
|
---|
[14525] | 22 | pos=find(mask==0);
|
---|
| 23 | pos2=find(convol(pos)~=0);
|
---|
| 24 |
|
---|
| 25 | mask(pos(pos2))=1;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.