Loadable Function: dist = bwdist (bw)
Loadable Function: dist = bwdist (bw, method)
Loadable Function: [dist, idx] = bwdist (…)

Compute distance transform in binary image.

The image bw must be a binary matrix For MATLAB compatibility, no check is performed, all non-zero values are considered object pixels. The return value dist, is the distance of each background pixel to the closest object pixel in a matrix of class single.

idx is the linear index for the closest object, used to calculate the distance for each of the pixels. Its class is dependent on the number of elements in bw, uint64 if less than 2^32 elements, uint32 otherwise.

The distance can be measured through different methods:

euclidean (default)
chessboard
cityblock
quasi-euclidean

Currently, only 2D images are supported.

Package: image