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:
Currently, only 2D images are supported.
Note: This implementation of bwdist follows the algorithm of Per-Erik Danielsson from 1980 (see source code for details). It gives fast and good results, but they can slightly differ from the theoretically correct result and from the Matlab result. Distance deviations are much smaller than a fraction of a single pixel.
Package: image