[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

details Distance Transform VIGRA

Functions

template<... >
void distanceTransform (...)
 

Detailed Description

Perform a distance transform using either the Euclidean, Manhattan, or chessboard metrics.

See also: multi-dimensional distance transforms

Function Documentation

void vigra::distanceTransform (   ...)

For all background pixels, calculate the distance to the nearest object or contour. The label of the pixels to be considered background in the source image is passed in the parameter 'background'. Source pixels with other labels will be considered objects. In the destination image, all pixels corresponding to background will be assigned the their distance value, all pixels corresponding to objects will be assigned 0.

The parameter 'norm' gives the distance norm to be used:

  • norm == 0: use chessboard distance (L-infinity norm)
  • norm == 1: use Manhattan distance (L1 norm)
  • norm == 2: use Euclidean distance (L2 norm)

If you use the L2 norm, the destination pixels must be real valued to give correct results.

Declarations:

pass 2D array views:

namespace vigra {
template <class T1, class S1,
class T2, class S2,
class ValueType>
void
distanceTransform(MultiArrayView<2, T1, S1> const & src,
MultiArrayView<2, T2, S2> dest,
ValueType background, int norm);
}

show deprecated declarations

Usage:

#include <vigra/distancetransform.hxx>
Namespace: vigra

MultiArray<2, unsigned char> src(w,h), edges(w,h);
MultiArray<2, float> distance(w, h);
...
// detect edges in src image (edges will be marked 1, background 0)
differenceOfExponentialEdgeImage(src, edges, 0.8, 4.0);
// find distance of all pixels from nearest edge
distanceTransform(edges, distance, 0, 2);
// ^ background label ^ norm (Euclidean)

show deprecated examples

Examples:
voronoi.cxx.

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de)
Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany

html generated using doxygen and Python
vigra 1.10.0 (Mon Apr 28 2014)