scipy.ndimage.distance_transform_bf¶

scipy.ndimage.
distance_transform_bf
(input, metric='euclidean', sampling=None, return_distances=True, return_indices=False, distances=None, indices=None)[source]¶ Distance transform function by a brute force algorithm.
This function calculates the distance transform of the input, by replacing each foreground (nonzero) element, with its shortest distance to the background (any zerovalued element).
In addition to the distance transform, the feature transform can be calculated. In this case the index of the closest background element is returned along the first axis of the result.
Parameters:  input : array_like
Input
 metric : str, optional
Three types of distance metric are supported: ‘euclidean’, ‘taxicab’ and ‘chessboard’.
 sampling : {int, sequence of ints}, optional
This parameter is only used in the case of the euclidean metric distance transform.
The sampling along each axis can be given by the sampling parameter which should be a sequence of length equal to the input rank, or a single number in which the sampling is assumed to be equal along all axes.
 return_distances : bool, optional
The return_distances flag can be used to indicate if the distance transform is returned.
The default is True.
 return_indices : bool, optional
The return_indices flags can be used to indicate if the feature transform is returned.
The default is False.
 distances : float64 ndarray, optional
Optional output array to hold distances (if return_distances is True).
 indices : int64 ndarray, optional
Optional output array to hold indices (if return_indices is True).
Returns:  distances : ndarray
Distance array if return_distances is True.
 indices : ndarray
Indices array if return_indices is True.
Notes
This function employs a slow brute force algorithm, see also the function distance_transform_cdt for more efficient taxicab and chessboard algorithms.