# Synopse

Geodesic Distance Transform.

• y = iagdist(f, g, Bc=ia_secross(NULL), METRIC=NULL)
• y: Image
• f: Image
• g: Image Marker image
• Bc: Structuring Element (metric for distance).
• METRIC: String 'EUCLIDEAN' if specified.
```01. from numpy import *
02. from iasecross import iasecross
03.
04. def iagdist(f, g, Bc=iasecross(), METRIC=None):
05.     from ianeg import ianeg
06.     from iagray import iagray
07.     from iaintersec import iaintersec
08.     from iaisequal import iaisequal
09.     from iacero import iacero
11.     from iaunion import iaunion
12.
13.     assert METRIC is None,'Does not support EUCLIDEAN'
14.     fneg,gneg = ianeg(f),ianeg(g)
15.     y = iagray(gneg,'uint16',1)
16.     ero = iaintersec(y,0)
17.     aux = y
18.     i = 1
19.     while (ero != aux).any():
20.         aux = ero
21.         ero = iacero(gneg,fneg,Bc,i)
23.         i   = i + 1
24.     y = iaunion(y,iagray(ero,'uint16'))
25.
26.     return y```

# Description

iagdist creates the geodesic distance image y of the binary image f relative to the binary image g. The value of y at the pixel x is the length of the smallest path between x and f. The distances available are based on the Euclidean metrics and on metrics generated by a neighbourhood graph, that is characterized by a connectivity rule defined by the structuring element Bc. The connectivity for defining the paths is consistent with the metrics adopted to measure their length. In the case of the Euclidean distance, the space is considered continuos and, in the other cases, the connectivity is the one defined by Bc.

# Examples

## Example 1

```01. from ia870 import iagdist
02. from ia870 import iabinary
03. from ia870 import iasecross
04.
05. f=iabinary([
06.  [1,1,1,1,1,1],
07.  [1,1,1,0,0,1],
08.  [1,0,1,0,0,1],
09.  [1,0,1,1,0,0],
10.  [0,0,1,1,1,1],
11.  [0,0,0,1,1,1]])
12. g=iabinary([
13.  [0,0,0,0,0,0],
14.  [1,1,0,0,0,0],
15.  [0,0,0,0,0,0],
16.  [0,0,0,0,0,0],
17.  [0,0,0,0,0,0],
18.  [0,0,0,0,0,1]])
19. y=iagdist(f,g,iasecross())
20. print y```
```[[    1     1     2     3     4     5]
[    0     0     1 65535 65535     6]
[    1 65535     2 65535 65535     7]
[    2 65535     3     4 65535 65535]
[65535 65535     4     3     2     1]
[65535 65535 65535     2     1     0]]
```

## Example 2

```01. from ia870 import iaintersec
03. from ia870 import iasebox
05. from ia870 import iagshow
06.
08. g=iaintersec(f,0)
```*** Exception while evaluating code: