Function Index
DistanceTransform
DistanceTransform[
img
]
returns the distance transform of
img
.
DistanceTransform[
img
,
neigh
]
returns the distance transform of
img
using a custom neighborhood definition via the list of offsets
neigh
.
The distance transform of a binary-valued image img associates with each pixel of value one the minimum distance to a zero-valued pixel.
DistanceTransform
implements the two-pass algorithm due to Rosenfeld and Pfaltz [
Ros66
] extended to support arrays of arbitrary rank and arbitrary neighborhoods.
The default connectivity settings are
ConnectivityNumber→
8 for 2D arrays and
ConnectivityNumber→
26 for 3D arrays.
The argument
img
may be a binary array or
ImageData
expression.
See also User's Guide
6.5
,
NeighborOffsets
.
New in Version 2.
Example
Here we load the package.
In[1]:=
This defines a binary array.
In[2]:=
Out[2]//MatrixForm=
This returns the distance transform.
In[3]:=
Out[3]//MatrixForm=
Here is the result using a different connectivity setting.
In[4]:=
Out[4]//MatrixForm=
© 2009 Wolfram Research, Inc.
•
Terms of Use
•
Privacy Policy
Sign up for our newsletter: