Name
distance_transformdistance_transformDistanceTransformdistance_transformDistanceTransformDistanceTransform — Compute the distance transformation of a region.
Herror distance_transform(const Hobject Region, Hobject* DistanceImage, const char* Metric, const char* Foreground, const Hlong Width, const Hlong Height)
Herror T_distance_transform(const Hobject Region, Hobject* DistanceImage, const Htuple Metric, const Htuple Foreground, const Htuple Width, const Htuple Height)
Herror distance_transform(Hobject Region, Hobject* DistanceImage, const HTuple& Metric, const HTuple& Foreground, const HTuple& Width, const HTuple& Height)
HImage HRegion::DistanceTransform(const HTuple& Metric, const HTuple& Foreground, const HTuple& Width, const HTuple& Height) const
HImage HRegionArray::DistanceTransform(const HTuple& Metric, const HTuple& Foreground, const HTuple& Width, const HTuple& Height) const
void DistanceTransform(const HObject& Region, HObject* DistanceImage, const HTuple& Metric, const HTuple& Foreground, const HTuple& Width, const HTuple& Height)
HImage HRegion::DistanceTransform(const HString& Metric, const HString& Foreground, Hlong Width, Hlong Height) const
HImage HRegion::DistanceTransform(const char* Metric, const char* Foreground, Hlong Width, Hlong Height) const
distance_transformdistance_transformDistanceTransformdistance_transformDistanceTransformDistanceTransform computes for every point of the input
region RegionRegionRegionRegionRegionregion (or its complement, respectively) the
distance of the point to the border of the region. The parameter
ForegroundForegroundForegroundForegroundForegroundforeground determines whether the distances are calculated
for all points within the region (ForegroundForegroundForegroundForegroundForegroundforeground =
'true'"true""true""true""true""true") or for all points outside the region
(ForegroundForegroundForegroundForegroundForegroundforeground = 'false'"false""false""false""false""false"). The distance is computed
for every point of the output image DistanceImageDistanceImageDistanceImageDistanceImageDistanceImagedistanceImage, which
has the specified dimensions WidthWidthWidthWidthWidthwidth and HeightHeightHeightHeightHeightheight.
The input region is always clipped to the extent of the output
image. If it is important that the distances within the entire
region should be computed, the region should be moved (see
move_regionmove_regionMoveRegionmove_regionMoveRegionMoveRegion) so that it has only positive coordinates and
the width and height of the output image should be large enough to
contain the region. The extent of the input region can be obtained
with smallest_rectangle1smallest_rectangle1SmallestRectangle1smallest_rectangle1SmallestRectangle1SmallestRectangle1.
The parameter MetricMetricMetricMetricMetricmetric determines which metric is used for
the calculation of the distances. If MetricMetricMetricMetricMetricmetric =
'city-block'"city-block""city-block""city-block""city-block""city-block", the distance is calculated from the shortest
path from the point to the border of the region, where only
horizontal and vertical “movements” are allowed. They are
weighted with a weight of 1. If MetricMetricMetricMetricMetricmetric =
'chessboard'"chessboard""chessboard""chessboard""chessboard""chessboard", the distance is calculated from the shortest
path to the border, where horizontal, vertical, and diagonal
“movements” are allowed. They are weighted with a weight of 1.
If MetricMetricMetricMetricMetricmetric = 'octagonal'"octagonal""octagonal""octagonal""octagonal""octagonal", a combination of these
approaches is used, which leads to diagonal paths receiving a higher
weight. If MetricMetricMetricMetricMetricmetric = 'chamfer-3-4'"chamfer-3-4""chamfer-3-4""chamfer-3-4""chamfer-3-4""chamfer-3-4", horizontal and
vertical movements are weighted with a weight of 3, while diagonal
movements are weighted with a weight of 4. To normalize the
distances, the resulting distance image is divided by 3. Since this
normalization step takes some time, and one usually is interested in
the relative distances of the points, the normalization can be
suppressed with MetricMetricMetricMetricMetricmetric =
'chamfer-3-4-unnormalized'"chamfer-3-4-unnormalized""chamfer-3-4-unnormalized""chamfer-3-4-unnormalized""chamfer-3-4-unnormalized""chamfer-3-4-unnormalized". Finally, if MetricMetricMetricMetricMetricmetric =
'euclidean'"euclidean""euclidean""euclidean""euclidean""euclidean", the computed distance is approximately
Euclidean.
- Multithreading type: reentrant (runs in parallel with non-exclusive operators).
- Multithreading scope: global (may be called from any thread).
- Processed without parallelization.
Region for which the distance to the border is
computed.
Image containing the distance information.
Type of metric to be used for the distance
transformation.
Default value:
'city-block'
"city-block"
"city-block"
"city-block"
"city-block"
"city-block"
List of values: 'chamfer-3-4'"chamfer-3-4""chamfer-3-4""chamfer-3-4""chamfer-3-4""chamfer-3-4", 'chamfer-3-4-unnormalized'"chamfer-3-4-unnormalized""chamfer-3-4-unnormalized""chamfer-3-4-unnormalized""chamfer-3-4-unnormalized""chamfer-3-4-unnormalized", 'chessboard'"chessboard""chessboard""chessboard""chessboard""chessboard", 'city-block'"city-block""city-block""city-block""city-block""city-block", 'euclidean'"euclidean""euclidean""euclidean""euclidean""euclidean", 'octagonal'"octagonal""octagonal""octagonal""octagonal""octagonal"
Compute the distance for pixels
inside ('true'"true""true""true""true""true") or outside
('false'"false""false""false""false""false") the input region.
Default value:
'true'
"true"
"true"
"true"
"true"
"true"
List of values: 'false'"false""false""false""false""false", 'true'"true""true""true""true""true"
Width of the output image.
Default value: 640
Suggested values: 160, 192, 320, 384, 640, 768
Typical range of values: 1
≤
Width
Width
Width
Width
Width
width
Height of the output image.
Default value: 480
Suggested values: 120, 144, 240, 288, 480, 576
Typical range of values: 1
≤
Height
Height
Height
Height
Height
height
* Step towards extracting the medial axis of a shape:
gen_rectangle1 (Rectangle1, 0, 0, 200, 400)
gen_rectangle1 (Rectangle2, 200, 0, 400, 200)
union2 (Rectangle1, Rectangle2, Shape)
distance_transform (Shape, DistanceImage, 'chessboard', 'true', 640, 480)
The runtime complexity is O(WidthWidthWidthWidthWidthwidth*HeightHeightHeightHeightHeightheight).
distance_transformdistance_transformDistanceTransformdistance_transformDistanceTransformDistanceTransform returns 2 (H_MSG_TRUE) if all parameters are
correct.
thresholdthresholdThresholdthresholdThresholdThreshold,
dyn_thresholddyn_thresholdDynThresholddyn_thresholdDynThresholdDynThreshold,
regiongrowingregiongrowingRegiongrowingregiongrowingRegiongrowingRegiongrowing
thresholdthresholdThresholdthresholdThresholdThreshold
closest_point_transformclosest_point_transformClosestPointTransformclosest_point_transformClosestPointTransformClosestPointTransform
skeletonskeletonSkeletonskeletonSkeletonSkeleton
P. Soille: “Morphological Image Analysis, Principles and
Applications”; Springer Verlag Berlin Heidelberg New York,
1999.
G. Borgefors: “Distance Transformations in Arbitrary Dimensions”;
Computer Vision, Graphics, and Image Processing, Vol. 27, pages
321--345, 1984.
P.E. Danielsson: “Euclidean Distance Mapping”; Computer Graphics
and Image Processing, Vol. 14, pages 227--248, 1980.
Foundation