Skip to content

distance_transformDistanceTransformDistanceTransformdistance_transformdistance_transform🔗

説明🔗

distance_transformDistanceTransformDistanceTransformdistance_transformdistance_transform — 領域の距離変換を計算する。

書式🔗

distance_transform( region Region, out image DistanceImage, string Metric, string Foreground, extent.x Width, extent.y Height )void DistanceTransform( const HObject& Region, HObject* DistanceImage, const HTuple& Metric, const HTuple& Foreground, const HTuple& Width, const HTuple& Height )static void HOperatorSet.DistanceTransform( HObject region, out HObject distanceImage, HTuple metric, HTuple foreground, HTuple width, HTuple height )def distance_transform( region: HObject, metric: str, foreground: str, width: int, height: int ) -> HObject

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 )

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

HImage HRegion::DistanceTransform( const wchar_t* Metric, const wchar_t* Foreground, Hlong Width, Hlong Height ) const (Windows only)

HImage HRegion.DistanceTransform( string metric, string foreground, int width, int height )

説明🔗

distance_transformDistanceTransform は入力領域 Regionregionregion (もしくはそ のそれぞれの構成要素)全ての点に対し、領域の境界と点との距離を計算 します。パラメーター Foregroundforegroundforeground は、距離を領域内のすべて の点に対して計算するか(Foregroundforegroundforeground = 'true'"true")、 領域外のすべての点に対して計算するか(Foregroundforegroundforeground = 'false'"false")を決定します。距離は Widthwidthwidth と Heightheightheight で指定された出力画像 DistanceImagedistanceImagedistance_image の全て の点に対して計算されます。 入力領域は、常に出力画像の範囲にクリップされます。全領域内の距離を 計算することが重要な場合、領域を移動して(move_regionMoveRegion を参 照してください)、領域が正の座標のみを持ち、出力画像の幅と高さの範 囲に収まるようにする必要があります。入力領域の範囲は、 smallest_rectangle1SmallestRectangle1 で取得できます。

パラメーター Metricmetricmetric は距離計算のために使用される metric を決定します。もし Metricmetricmetric = 'city-block'"city-block" なら ば、距離は水平方向と垂直方向のみ “移動” が許される領域境界の点から の最小パスによって計算されます。これらは 1 で重み付けされます。も し Metricmetricmetric = 'chessboard'"chessboard" ならば、距離は水平、垂 直、対角線方向の “移動” が許される境界の最小パスから計算されます。 これらは 1 で重み付けされます。 もし Metricmetricmetric = 'octagonal'"octagonal" ならば、これらのアプ ローチの組み合わせが使用され、対角線パスに高い重み付けが導かれま す。もし Metricmetricmetric = 'chamfer-3-4'"chamfer-3-4" ならば、水平、垂 直方向の移動は 3 で重み付けられ、対角線方向の移動は 4 で重み付けら れます。距離を正規化するために、求められた距離画像は 3 で割られま す。正規化の段階がいくつかあり、通常は点の相対距離に関連があるの で、Metricmetricmetric = 'chamfer-3-4-unnormalized'"chamfer-3-4-unnormalized" で正規化 を抑制することができます。最後に、もし Metricmetricmetric = 'euclidean'"euclidean" ならば、距離計算はユークリッドで近似されま す。

実行情報🔗

実行情報
  • マルチスレッドタイプ: リエントラント(非排他なオペレーターと並列に動作)

  • マルチスレッドスコープ: グローバル(他のスレッドから呼び出される可能性あり)

  • 並列演算処理には未対応

パラメーター🔗

Regionregionregion (input_object) region(-array) → objectHObjectHRegionHObjectHobject

境界との距離を計算される領域

DistanceImagedistanceImagedistance_image (output_object) image → object (int4)HObject (int4)HImage (int4)HObject (int4)Hobject * (int4)

距離情報を含む画像

Metricmetricmetric (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

距離変換に使用される metric のタイプ

初期値: 'city-block'"city-block"
値のリスト: 'chamfer-3-4', 'chamfer-3-4-unnormalized', 'chessboard', 'city-block', 'euclidean', 'octagonal'"chamfer-3-4", "chamfer-3-4-unnormalized", "chessboard", "city-block", "euclidean", "octagonal"

Foregroundforegroundforeground (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

入力領域の内部('true'"true")もしくは外部( 'false'"false")の画素の距離の計算

初期値: 'true'"true"
値のリスト: 'false', 'true'"false", "true"

Widthwidthwidth (input_control) extent.x → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

出力画像の幅

初期値: 640640
推奨値: 160, 192, 320, 384, 640, 768160, 192, 320, 384, 640, 768
値域: 1 ≤ Width

Heightheightheight (input_control) extent.y → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

出力画像の高さ

初期値: 480480
推奨値: 120, 144, 240, 288, 480, 576120, 144, 240, 288, 480, 576
値域: 1 ≤ Height

例🔗

(HDevelop)


* 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)

複雑性🔗

実行時間は \(O(\textrm{Width}*\textrm{Height})\) です。

結果🔗

distance_transformDistanceTransform は、すべてのパラメーターが正しい場合に 2 (H_MSG_TRUE) を返します。

他のオペレーターとの組み合わせ🔗

組み合わせ

前処理の候補

thresholdThreshold, dyn_thresholdDynThreshold, regiongrowingRegiongrowing

後処理の候補

thresholdThreshold

他の選択候補

closest_point_transformClosestPointTransform

関連項目

skeletonSkeleton

参考文献🔗

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