closest_point_transformclosest_point_transformClosestPointTransformClosestPointTransformclosest_point_transform最近点变换(算子)
名称
closest_point_transformclosest_point_transformClosestPointTransformClosestPointTransformclosest_point_transform — 计算区域的最近点变换。
签名
Herror closest_point_transform(const Hobject Region, Hobject* Distances, Hobject* ClosestPoints, const char* Metric, const char* Foreground, const char* ClosestPointMode, const Hlong Width, const Hlong Height)
Herror T_closest_point_transform(const Hobject Region, Hobject* Distances, Hobject* ClosestPoints, const Htuple Metric, const Htuple Foreground, const Htuple ClosestPointMode, const Htuple Width, const Htuple Height)
void ClosestPointTransform(const HObject& Region, HObject* Distances, HObject* ClosestPoints, const HTuple& Metric, const HTuple& Foreground, const HTuple& ClosestPointMode, const HTuple& Width, const HTuple& Height)
HImage HRegion::ClosestPointTransform(HImage* ClosestPoints, const HString& Metric, const HString& Foreground, const HString& ClosestPointMode, Hlong Width, Hlong Height) const
HImage HRegion::ClosestPointTransform(HImage* ClosestPoints, const char* Metric, const char* Foreground, const char* ClosestPointMode, Hlong Width, Hlong Height) const
HImage HRegion::ClosestPointTransform(HImage* ClosestPoints, const wchar_t* Metric, const wchar_t* Foreground, const wchar_t* ClosestPointMode, Hlong Width, Hlong Height) const
(
Windows only)
static void HOperatorSet.ClosestPointTransform(HObject region, out HObject distances, out HObject closestPoints, HTuple metric, HTuple foreground, HTuple closestPointMode, HTuple width, HTuple height)
HImage HRegion.ClosestPointTransform(out HImage closestPoints, string metric, string foreground, string closestPointMode, int width, int height)
描述
closest_point_transformclosest_point_transformClosestPointTransformClosestPointTransformClosestPointTransformclosest_point_transform 为输入区域 RegionRegionRegionRegionregionregion(或其补集)中的每个像素计算到区域外最近像素(即区域外部边界上的像素)的距离,并将该信息存储在
DistancesDistancesDistancesDistancesdistancesdistances 中。除距离外,对应的最近像素也会存储在 ClosestPointsClosestPointsClosestPointsClosestPointsclosestPointsclosest_points 中。
参数 ForegroundForegroundForegroundForegroundforegroundforeground 决定距离计算范围:若ForegroundForegroundForegroundForegroundforegroundforeground
= 'true'"true""true""true""true""true",则计算区域内所有点的距离;若 ForegroundForegroundForegroundForegroundforegroundforeground = 'false'"false""false""false""false""false",则计算区域外所有点的距离。对于输出图像 DistancesDistancesDistancesDistancesdistancesdistances 和 ClosestPointsClosestPointsClosestPointsClosestPointsclosestPointsclosest_points 的每个像素,都会计算其距离。图像尺寸由
WidthWidthWidthWidthwidthwidth 和 HeightHeightHeightHeightheightheight 指定。输入区域始终被裁剪至输出图像的范围。若需计算整个区域内的距离,应移动区域(参见 move_regionmove_regionMoveRegionMoveRegionMoveRegionmove_region)使其坐标均为正值,同时确保输出图像的宽度和高度足够容纳该区域。输入区域的范围可通过 smallest_rectangle1smallest_rectangle1SmallestRectangle1SmallestRectangle1SmallestRectangle1smallest_rectangle1 获取。
参数 MetricMetricMetricMetricmetricmetric 决定用于距离计算的度量标准。若 MetricMetricMetricMetricmetricmetric =
'city-block'"city-block""city-block""city-block""city-block""city-block",则距离基于点到区域边界的最短路径计算,仅允许水平与垂直方向的“移动”。它们的权重为 1。若 MetricMetricMetricMetricmetricmetric =
'chessboard'"chessboard""chessboard""chessboard""chessboard""chessboard",则距离基于到边界的最短路径计算,允许水平、垂直和对角线方向的“移动”。它们的权重为 1。若 MetricMetricMetricMetricmetricmetric = 'octagonal'"octagonal""octagonal""octagonal""octagonal""octagonal",则采用上述方法的组合,导致对角路径获得更高权重。若 MetricMetricMetricMetricmetricmetric = 'chamfer-3-4'"chamfer-3-4""chamfer-3-4""chamfer-3-4""chamfer-3-4""chamfer-3-4",则水平与垂直移动权重 3,而对角移动权重 4。为归一化距离,最终距离图像需除以 3。由于归一化步骤耗时较长,且通常关注点之间的相对距离,可通过设置 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" 禁用归一化。最后,若 MetricMetricMetricMetricmetricmetric =
'euclidean'"euclidean""euclidean""euclidean""euclidean""euclidean",则计算出的距离近似于欧几里得距离。
参数 ClosestPointModeClosestPointModeClosestPointModeClosestPointModeclosestPointModeclosest_point_mode 决定最近点的存储方式。当 ClosestPointModeClosestPointModeClosestPointModeClosestPointModeclosestPointModeclosest_point_mode =
'absolute'"absolute""absolute""absolute""absolute""absolute" 时,绝对坐标将存储于
ClosestPointsClosestPointsClosestPointsClosestPointsclosestPointsclosest_points 中。当 ClosestPointModeClosestPointModeClosestPointModeClosestPointModeclosestPointModeclosest_point_mode =
'relative'"relative""relative""relative""relative""relative" 时,则存储相应像素坐标的偏移量至 ClosestPointsClosestPointsClosestPointsClosestPointsclosestPointsclosest_points。
注意
需要注意的是,最近点通常并非唯一,即对于图像中每个像素 DistancesDistancesDistancesDistancesdistancesdistances,区域外边界上通常存在多个与该像素距离相等的点。例如,在选定度量标准下,区域骨架上的所有点到区域外边界上至少两个不同点的距离均相等。closest_point_transformclosest_point_transformClosestPointTransformClosestPointTransformClosestPointTransformclosest_point_transform 返回其中一个点,该点由算法实现决定。特别需要注意的是,不应期望该结果具有区域旋转或镜像的不变性。
此外,需要注意的是,当 ForegroundForegroundForegroundForegroundforegroundforeground =
'true'"true""true""true""true""true" 时,若输入区域 RegionRegionRegionRegionregionregion 触及图像边界,则会返回位于 WidthWidthWidthWidthwidthwidth 和 HeightHeightHeightHeightheightheight 定义的图像外部的点坐标——因为此时区域的外边界恰好超出图像范围一个像素。若需将返回的坐标用于直接访问图像,则必须实施适当的边界处理机制。
执行信息
- 多线程类型:可重入(与非独占算子并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 未采用并行化处理。
参数
RegionRegionRegionRegionregionregion (输入对象) region(-array) → objectHRegionHObjectHRegionHobject
用于计算与边界距离的区域。
DistancesDistancesDistancesDistancesdistancesdistances (输出对象) image → objectHImageHObjectHImageHobject * (int4)
包含距离信息的图像。
ClosestPointsClosestPointsClosestPointsClosestPointsclosestPointsclosest_points (输出对象) image → objectHImageHObjectHImageHobject * (vector_field)
包含最近点坐标的图像。
MetricMetricMetricMetricmetricmetric (输入控制) string → HTuplestrHTupleHtuple (string) (string) (HString) (char*)
用于最近点变换的度量类型。
默认值:
'city-block'
"city-block"
"city-block"
"city-block"
"city-block"
"city-block"
值列表:
'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"
ForegroundForegroundForegroundForegroundforegroundforeground (输入控制) string → HTuplestrHTupleHtuple (string) (string) (HString) (char*)
计算输入区域内部('true'"true""true""true""true""true")或外部('false'"false""false""false""false""false")像素的距离。
默认值:
'true'
"true"
"true"
"true"
"true"
"true"
值列表:
'false'"false""false""false""false""false", 'true'"true""true""true""true""true"
ClosestPointModeClosestPointModeClosestPointModeClosestPointModeclosestPointModeclosest_point_mode (输入控制) string → HTuplestrHTupleHtuple (string) (string) (HString) (char*)
返回最近点坐标的方式。
默认值:
'absolute'
"absolute"
"absolute"
"absolute"
"absolute"
"absolute"
值列表:
'absolute'"absolute""absolute""absolute""absolute""absolute", 'relative'"relative""relative""relative""relative""relative"
WidthWidthWidthWidthwidthwidth (输入控制) extent.x → HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
输出图像的宽度。
默认值:
640
建议值:
160, 192, 320, 384, 640, 768
值范围:
1
≤
Width
Width
Width
Width
width
width
HeightHeightHeightHeightheightheight (输入控制) extent.y → HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
输出图像的高度。
默认值:
480
建议值:
120, 144, 240, 288, 480, 576
值范围:
1
≤
Height
Height
Height
Height
height
height
复杂度
运行时间复杂度为 O(WidthWidthWidthWidthwidthwidth*HeightHeightHeightHeightheightheight)。
结果
closest_point_transformclosest_point_transformClosestPointTransformClosestPointTransformClosestPointTransformclosest_point_transform 在所有参数正确时返回 2 (H_MSG_TRUE)。
可能的前趋
thresholdthresholdThresholdThresholdThresholdthreshold,
dyn_thresholddyn_thresholdDynThresholdDynThresholdDynThresholddyn_threshold,
regiongrowingregiongrowingRegiongrowingRegiongrowingRegiongrowingregiongrowing
可能的后继
thresholdthresholdThresholdThresholdThresholdthreshold,
vector_field_to_realvector_field_to_realVectorFieldToRealVectorFieldToRealVectorFieldToRealvector_field_to_real
替代
distance_transformdistance_transformDistanceTransformDistanceTransformDistanceTransformdistance_transform
另见
skeletonskeletonSkeletonSkeletonSkeletonskeleton
参考文献
Y. Ge, C.R. Maurer, Jr., J.M. Fitzpatrick: “Surface-based 3-D image
registration using the Iterative Closest Point algorithm with a
closest point transform”; in: “Medical Imaging 1996: Image
Processing”, M.H. Loew, K.M. Hanson, Editors, Proc. SPIE 2710,
pages 358--367, 1996.
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.
模块
基础