[mmopen] [Up] [mmgdist] Image Transforms

mmdist
Distance transform.

Synopsis

y = mmdist ( f , Bc = NullStrel, METRIC = Null )

Input

f Image Binary image

Bc Structuring Element

(connectivity)

Default: NullStrel (3x3 elementary cross)

METRIC String

'EUCLIDEAN', or 'EUC2' for squared Euclidean.

Default: Null

Output

y Image

distance image in uint16, or in int32 datatype with EUC2 option.

Description

mmdist creates the distance image y of the binary image f. The value of y at the pixel x is the distance of x to the complement of f, that is, the distance of x to nearest point in the complement of f. The distances available are based on the Euclidean metrics and on metrics generated by a a regular graph, that is characterized by a connectivity rule defined by the structuring element Bc. The implementation of the Euclidean algorithm is based on [LZ01].

Examples

Simple numeric example
a = mmframe(mmbinary(ones((5,9))),2,4)
Warning: downcasting image from double to int32 (may lose precision)
f4=mmdist(a)
f8=mmdist(a,mmsebox())
fe=mmdist(a,mmsebox(),'EUCLIDEAN')
Image example
f = mmreadgray('gear.tif')
f = mmneg(mmgradm(f))
d4=mmdist(f)
d8=mmdist(f,mmsebox())
de=mmdist(f,mmsebox(),'EUCLIDEAN')
mmshow(f)
mmshow(d4%8)
mmshow(d8%8)
mmshow(de%8)
f d4%8 d8%8 de%8

Equation

distance of a point x to a set X:
distance function:
distance function using structuring element:
Relationship between erosion and distance transform:

Limitations

To generate useful Distance transforms, the structuring elements must be symmetric and have the origin included. The Euclidean distance transform is rounded to the nearest integer, since it is represented as an unsigned integer image. Use the option EUC2 to compute exact squared Euclidean distance transform.

See also

mmfreedom Control automatic data type conversion.
mmdtshow Display a distance transform image with an iso-line color table.
mmero Erode an image by a structuring element.
mmgdist Geodesic Distance Transform.
mmsebox Create a box structuring element.
mmsecross Diamond structuring element and elementary 3x3 cross.
[mmopen] [Up] [mmgdist]