D = bwdistgeodesic(BW,mask) D = bwdistgeodesic(BW,C,R) D = bwdistgeodesic(BW,ind) D = bwdistgeodesic(...,method)

Description

D = bwdistgeodesic(BW,mask) computes
the geodesic distance transform, given the binary image BW and
the seed locations specified by mask. Regions where BW is true represent
valid regions that can be traversed in the computation of the distance
transform. Regions where BW is false represent
constrained regions that cannot be traversed in the distance computation.
For each true pixel in BW, the
geodesic distance transform assigns a number that is the constrained
distance between that pixel and the nearest true pixel
in mask. Output matrix D contains
geodesic distances.

D = bwdistgeodesic(BW,C,R) computes
the geodesic distance transform of the binary image BW.
Vectors C and R contain the
column and row coordinates of the seed locations.

D = bwdistgeodesic(BW,ind) computes
the geodesic distance transform of the binary image BW. ind is
a vector of linear indices of seed locations.

D = bwdistgeodesic(...,method) specifies
an alternate distance metric.

Input Arguments

BW

Binary image.

mask

Logical image the same size as BW that specifies
seed locations.

C,R

Numeric vectors that contain the positive integer column and
row coordinates of the seed locations. Coordinate values are valid C,R subscripts
in BW.

ind

Numeric vector of positive integer, linear indices of seed locations.

method

Type of distance metric. method can have
any of these values.

Method

Description

'cityblock'

In 2-D, the cityblock distance between (x_{1},y_{1})
and (x_{2},y_{2}) is │x_{1} – x_{2}│
+ │y_{1} – y_{2}│.

'chessboard'

The chessboard distance is max(│x_{1} – x_{2}│,│y_{1} – y_{2}│).

Numeric array of class single, with the same
size as input BW, that contains geodesic distances.

Class Support

BW is a logical matrix. C, R,
and ind are numeric vectors that contain positive
integer values. D is a numeric array of class single that
has the same size as the input BW.

Examples

Compute the geodesic distance transformation of BW based
on the seed locations specified by vectors C and R.
Output pixels for which BW is false have undefined
geodesic distance and contain NaN values. Because there is no connected
path from the seed locations to element BW(10,5),
the output D(10,5) has a value of Inf.

bwdistgeodesic uses the geodesic distance
algorithm described in Soille, P., Morphological Image Analysis:
Principles and Applications, 2nd Edition, Secaucus, NJ,
Springer-Verlag, 2003, pp. 219–221.