Image Processing Toolbox User's Guide Previous page   Next Page

Distance Transform

The distance transform provides a metric or measure of the separation of points in the image. The Image Processing Toolbox provides a function, bwdist, that calculates the distance between each pixel that is set to off (0) and the nearest nonzero pixel for binary images.

The bwdist function supports several distance metrics, listed in the following table.

Distance Metrics 
Distance Metric
The Euclidean distance is the straight-line distance between two pixels.

City Block
The city block distance metric measures the path between the pixels based on a 4-connected neighborhood. Pixels whose edges touch are 1 unit apart; pixels diagonally touching are 2 units apart.

The chessboard distance metric measures the path between the pixels based on an 8-connected neighborhood. Pixels whose edges or corners touch are 1 unit apart.

The quasi-Euclidean metric measures the total Euclidean distance along a set of horizontal, vertical, and diagonal line segments.

This example creates a binary image containing two intersecting circular objects.

To compute the distance transform of the complement of the binary image, use the bwdist function. In the image of the distance transform, note how the centers of the two circular areas are white.

Previous page  Finding Peaks and Valleys Objects, Regions, and Feature Measurement Next page

© 1994-2005 The MathWorks, Inc.