Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Data Manipulation > Image Processing & Analysis > Mathematical Morphology >

DistanceTransform

DistanceTransform[image]
gives the distance transform of image, in which the value of each pixel is replaced by its distance to the nearest background pixel.
DistanceTransform[image, t]
treats values above t as foreground.
  • DistanceTransform gives an Image object in which the value of each pixel is the absolute Euclidean distance in pixels to the nearest pixel of background.
  • For multichannel images, DistanceTransform operates on the intensity averaged over all channels.
  • The following option can be given:
DistanceFunctionEuclideanDistancedistance metric function
Create a binary image:
Compute its distance transform and normalize the result:
Distance transform of random disks:
Create a binary image:
In[1]:=
Click for copyable input
Out[1]=
Compute its distance transform and normalize the result:
In[2]:=
Click for copyable input
Out[2]=
 
Distance transform of random disks:
In[1]:=
Click for copyable input
Out[1]=
Apply a LoG filter to the output of a distance transform:
New in 7
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team