Home > freetb4matlab > image > bwdist.m

bwdist

PURPOSE ^

%

SYNOPSIS ^

function [D, C] = bwdist(bw, method = 'euclidean')

DESCRIPTION ^

% -*- texinfo -*-
% @deftypefn {Function File} {@var{D} =} bwdist(@var{bw})
%
% Computes the distance transform of the image @var{bw}.
% @var{bw} should be a binary 2D array, either a Boolean array or a
% numeric array containing only the values 0 and 1.
% The return value @var{D} is a double matrix of the same size as @var{bw}.
% Elements with value 0 are considered background pixels, elements
% with value 1 are considered object pixels. The return value
% for each background pixel is the distance (according to the chosen
% metric) to the closest object pixel. For each object pixel the
% return value is 0.
% 
% @deftypefnx{Function File} {@var{D} =} bwdist(@var{bw}, @var{method})
% 
% @var{method} is a string to choose the distance metric. Currently
% available metrics are 'euclidean', 'chessboard', 'cityblock' and
% 'quasi-euclidean', which may each be abbreviated to any string
% starting with 'e', 'ch', 'ci' and 'q', respectively.
% If @var{method} is not specified, 'euclidean' is the default.
% 
% @deftypefnx {Function File} {[@var{D},@var{C}] =} bwdist(@var{bw}, @var{method})
% 
% If a second output argument is given, the linear index for the
% closest object pixel is returned for each pixel. (For object
% pixels, the index points to the pixel itself.) The return value
% @var{C} is a matrix the same size as @var{bw}.
% @end deftypefn

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Fri 22-May-2009 15:13:00 by m2html © 2003