FUNCTION REFERENCE

bwdist

Distance to the nearest nonzero image pixel.

Distance to the nearest nonzero image pixel.

Syntax

[D, idx] = bwdist(BW, method)

BW is a real numeric or logical 2-D image. method defaults to 'euclidean'; 'cityblock', 'chessboard' and 'quasi-euclidean' are also supported. D is single and idx is uint32, with one-based column-major nearest-pixel indices. Any nearest pixel may resolve a tie. Without foreground, distances are Inf and indices are zero. Euclidean distance is exact before conversion to single and takes linear time.

Example

[D, idx] = bwdist(logical([0 0 0; 0 1 0; 0 0 0]))

Differences from MATLAB: 2-D only; segmentation workspace is limited to 2097152 samples.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.