Expand description
Distance transforms: for every foreground pixel, the distance to the nearest background pixel.
The exact Euclidean transform uses the separable algorithm of Felzenszwalb and Huttenlocher (2004): the squared distance in two dimensions is a one-dimensional problem along the rows of a one-dimensional answer along the columns, and each one-dimensional problem is the lower envelope of parabolas, found in linear time. The chamfer transforms (city-block and chessboard) need only two raster sweeps.
See the book entry Morphology, distance transforms and labelling.
Structs§
- Distance
Transform - The exact Euclidean distance transform with its feature transform.
Enums§
- Chamfer
Metric - The metric of a chamfer distance transform.
Functions§
- distance_
transform_ cdt - The chamfer distance transform (SciPy’s
distance_transform_cdt), in integer steps: a forward raster sweep takes each pixel’s distance from its already visited neighbours (up and left), and a backward sweep from the others. Background pixels get 0. Images without background giveNonefor every pixel. - distance_
transform_ edt - The exact Euclidean distance transform of a binary image (SciPy’s
distance_transform_edt): for each foreground (true) pixel, the distance to the nearest background (false) pixel, with pixel spacingsampling = (row spacing, column spacing)(default(1, 1)). Background pixels get 0. The image must contain at least one background pixel.