Skip to content

approx_chainApproxChainApproxChainapprox_chainT_approx_chain🔗

説明🔗

approx_chainApproxChainApproxChainapprox_chainT_approx_chain — 円弧および直線で閉じたチェインコードを近似する。

警告🔗

approx_chainApproxChain は現在では使用されず、下位互換性のためだけに提供 されます。

書式🔗

approx_chain( point.y Row, point.x Column, real MinWidthCoord, real MaxWidthCoord, real ThreshStart, real ThreshEnd, real ThreshStep, real MinWidthSmooth, real MaxWidthSmooth, integer MinWidthCurve, integer MaxWidthCurve, real Weight1, real Weight2, real Weight3, out arc.center.y ArcCenterRow, out arc.center.x ArcCenterCol, out arc.angle.rad ArcAngle, out arc.begin.y ArcBeginRow, out arc.begin.x ArcBeginCol, out line.begin.y LineBeginRow, out line.begin.x LineBeginCol, out line.end.y LineEndRow, out line.end.x LineEndCol, out integer Order )void ApproxChain( const HTuple& Row, const HTuple& Column, const HTuple& MinWidthCoord, const HTuple& MaxWidthCoord, const HTuple& ThreshStart, const HTuple& ThreshEnd, const HTuple& ThreshStep, const HTuple& MinWidthSmooth, const HTuple& MaxWidthSmooth, const HTuple& MinWidthCurve, const HTuple& MaxWidthCurve, const HTuple& Weight1, const HTuple& Weight2, const HTuple& Weight3, HTuple* ArcCenterRow, HTuple* ArcCenterCol, HTuple* ArcAngle, HTuple* ArcBeginRow, HTuple* ArcBeginCol, HTuple* LineBeginRow, HTuple* LineBeginCol, HTuple* LineEndRow, HTuple* LineEndCol, HTuple* Order )static void HOperatorSet.ApproxChain( HTuple row, HTuple column, HTuple minWidthCoord, HTuple maxWidthCoord, HTuple threshStart, HTuple threshEnd, HTuple threshStep, HTuple minWidthSmooth, HTuple maxWidthSmooth, HTuple minWidthCurve, HTuple maxWidthCurve, HTuple weight1, HTuple weight2, HTuple weight3, out HTuple arcCenterRow, out HTuple arcCenterCol, out HTuple arcAngle, out HTuple arcBeginRow, out HTuple arcBeginCol, out HTuple lineBeginRow, out HTuple lineBeginCol, out HTuple lineEndRow, out HTuple lineEndCol, out HTuple order )def approx_chain( row: Sequence[int], column: Sequence[int], min_width_coord: float, max_width_coord: float, thresh_start: float, thresh_end: float, thresh_step: float, min_width_smooth: float, max_width_smooth: float, min_width_curve: int, max_width_curve: int, weight_1: float, weight_2: float, weight_3: float ) -> Tuple[Sequence[int], Sequence[int], Sequence[float], Sequence[int], Sequence[int], Sequence[int], Sequence[int], Sequence[int], Sequence[int], Sequence[int]]

Herror T_approx_chain( const Htuple Row, const Htuple Column, const Htuple MinWidthCoord, const Htuple MaxWidthCoord, const Htuple ThreshStart, const Htuple ThreshEnd, const Htuple ThreshStep, const Htuple MinWidthSmooth, const Htuple MaxWidthSmooth, const Htuple MinWidthCurve, const Htuple MaxWidthCurve, const Htuple Weight1, const Htuple Weight2, const Htuple Weight3, Htuple* ArcCenterRow, Htuple* ArcCenterCol, Htuple* ArcAngle, Htuple* ArcBeginRow, Htuple* ArcBeginCol, Htuple* LineBeginRow, Htuple* LineBeginCol, Htuple* LineEndRow, Htuple* LineEndCol, Htuple* Order )

static void HMisc::ApproxChain( const HTuple& Row, const HTuple& Column, double MinWidthCoord, double MaxWidthCoord, double ThreshStart, double ThreshEnd, double ThreshStep, double MinWidthSmooth, double MaxWidthSmooth, Hlong MinWidthCurve, Hlong MaxWidthCurve, double Weight1, double Weight2, double Weight3, HTuple* ArcCenterRow, HTuple* ArcCenterCol, HTuple* ArcAngle, HTuple* ArcBeginRow, HTuple* ArcBeginCol, HTuple* LineBeginRow, HTuple* LineBeginCol, HTuple* LineEndRow, HTuple* LineEndCol, HTuple* Order )

static void HMisc.ApproxChain( HTuple row, HTuple column, double minWidthCoord, double maxWidthCoord, double threshStart, double threshEnd, double threshStep, double minWidthSmooth, double maxWidthSmooth, int minWidthCurve, int maxWidthCurve, double weight1, double weight2, double weight3, out HTuple arcCenterRow, out HTuple arcCenterCol, out HTuple arcAngle, out HTuple arcBeginRow, out HTuple arcBeginCol, out HTuple lineBeginRow, out HTuple lineBeginCol, out HTuple lineEndRow, out HTuple lineEndCol, out HTuple order )

説明🔗

閉じた曲線のチェインコードを直線と円弧の組み合わせで近似します。 このオペレーターは、ユーザ定義可能な範囲からあるパラメーターに対して 近似を試みます。この範囲制限は、関数のパラメーターリスト (MinWidthCoord … MaxWidthCoord, ThreshStart … ThreshEnd, MinWidthSmooth … MaxWidthSmooth, MinWidthCurve … MaxWidthCurve) にて指定できます。さらにとがったコーナーに対するしきい値の設定範囲に ついて、ステップ幅を指定する必要があります (ThreshStep)。 カバーする範囲を狭くすることによって、計算の実行時間を短くすることが できますが、結果は悪くなる可能性があります。

パラメーター Weight1, Weight2, Weight3 は、それぞれ、近似の精度以上に 重み付けするかどうか、長いセグメントをできるだけ多く得る、もしくは 短いセグメントをできるだけ少なく得るように重み付けするかどうかの 組み合わせを示します。 (Weight1, Weight2, Weight3) が (1,0,0) の場合、非常に正確な近似を生成し、 (0,1,1) に対しては可能な限り 少ない長いセグメントを用いて近似します。

このオペレーターの結果は、円弧と直線に分離して返されます。もしセグメントの 列を得る必要があれば、個々の結果として選られる要素を結果のTuple から 順に読み出すことができます。この列は返るパラメーター順序 (0: 次の要素が 次の直線セグメント、1: 次の要素が次の円弧セグメント) で取り出すことが できます。

注意🔗

ただ一つのセグメントからなるXLDもまたしきい値の最大(ThreshEnd) \(>\) 1.0 を 用いて検査するべきです。なぜならば、少なくとも一つの’‘端点’’ が いかなる場合も決定されるからです。

実行情報🔗

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

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

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

パラメーター🔗

Rowrowrow (input_control) point.y-array → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

チェインコードの開始点の行座標

初期値: 3232

Columncolumncolumn (input_control) point.x-array → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

チェインコードの開始点の列座標

初期値: 3232

MinWidthCoordminWidthCoordmin_width_coord (input_control) real → (real)HTuple (double)HTuple (double)floatHtuple (double)

座標のスムージングに対するガウスオペレーターの 最小幅(\(>\) 0.4)

初期値: 0.50.5
推奨値: 0.5, 0.7, 1.0, 1.2, 1.5, 1.70.5, 0.7, 1.0, 1.2, 1.5, 1.7
値域: 0.4 ≤ MinWidthCoord ≤ 3.0 (lin)
最小増分: 0.01
推奨増分: 0.1

MaxWidthCoordmaxWidthCoordmax_width_coord (input_control) real → (real)HTuple (double)HTuple (double)floatHtuple (double)

座標のスムージングに対するガウスオペレーターの 最大幅(\(>\) 0.4)

初期値: 2.42.4
推奨値: 0.5, 0.7, 1.0, 1.2, 1.5, 1.70.5, 0.7, 1.0, 1.2, 1.5, 1.7
値域: 0.4 ≤ MaxWidthCoord ≤ 3.0 (lin)
最小増分: 0.01
推奨増分: 0.1

ThreshStartthreshStartthresh_start (input_control) real → (real)HTuple (double)HTuple (double)floatHtuple (double)

(最も大きい曲率に対して) コーナーとして受けつけるための曲率の 最小しきい値

初期値: 0.30.3
推奨値: 0.3, 0.4, 0.5, 0.6, 0.7, 0.80.3, 0.4, 0.5, 0.6, 0.7, 0.8
値域: 0.1 ≤ ThreshStart ≤ 0.9 (lin)
最小増分: 0.01
推奨増分: 0.1

ThreshEndthreshEndthresh_end (input_control) real → (real)HTuple (double)HTuple (double)floatHtuple (double)

(最も大きい曲率に対して) コーナーとして受けつけるための曲率の 最大しきい値

初期値: 0.90.9
推奨値: 0.3, 0.4, 0.5, 0.6, 0.7, 0.80.3, 0.4, 0.5, 0.6, 0.7, 0.8
値域: 0.1 ≤ ThreshEnd ≤ 0.9 (lin)
最小増分: 0.01
推奨増分: 0.1

ThreshStepthreshStepthresh_step (input_control) real → (real)HTuple (double)HTuple (double)floatHtuple (double)

しきい値を増加させるためのステップ幅

初期値: 0.20.2
推奨値: 0.3, 0.4, 0.50.3, 0.4, 0.5
値域: 0.1 ≤ ThreshStep ≤ 0.9 (lin)
最小増分: 0.01
推奨増分: 0.1

MinWidthSmoothminWidthSmoothmin_width_smooth (input_control) real → (real)HTuple (double)HTuple (double)floatHtuple (double)

曲率関数のスムージングに対するガウス オペレーターの最小幅(\(>\) 0.4)

初期値: 0.50.5
推奨値: 0.5, 0.7, 1.0, 1.2, 1.5, 1.70.5, 0.7, 1.0, 1.2, 1.5, 1.7
値域: 0.4 ≤ MinWidthSmooth ≤ 3.0 (lin)
最小増分: 0.01
推奨増分: 0.1

MaxWidthSmoothmaxWidthSmoothmax_width_smooth (input_control) real → (real)HTuple (double)HTuple (double)floatHtuple (double)

曲率関数のスムージング に対するガウスオペレーターの最大幅

初期値: 2.42.4
推奨値: 0.5, 0.7, 1.0, 1.2, 1.5, 1.70.5, 0.7, 1.0, 1.2, 1.5, 1.7
値域: 0.4 ≤ MaxWidthSmooth ≤ 3.0 (lin)
最小増分: 0.01
推奨増分: 0.1

MinWidthCurveminWidthCurvemin_width_curve (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

曲率決定のための曲線範囲の最小幅(\(>\) 0.4)

初期値: 22
推奨値: 2, 5, 72, 5, 7
値域: 1 ≤ MinWidthCurve ≤ 12 (lin)
最小増分: 1
推奨増分: 2

MaxWidthCurvemaxWidthCurvemax_width_curve (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

曲率決定 のための曲線範囲の最大幅

初期値: 1212
推奨値: 2, 5, 72, 5, 7
値域: 1 ≤ MaxWidthCurve ≤ 20 (lin)
最小増分: 1
推奨増分: 2

Weight1weight1weight_1 (input_control) real → (real)HTuple (double)HTuple (double)floatHtuple (double)

近似精度に対する重み付け要素

初期値: 1.01.0
推奨値: 0.0, 0.5, 1.00.0, 0.5, 1.0
値域: 0.0 ≤ Weight1 ≤ 1.0 (lin)
最小増分: 0.1
推奨増分: 0.5

Weight2weight2weight_2 (input_control) real → (real)HTuple (double)HTuple (double)floatHtuple (double)

大きなセグメントに対する重み付け要素

初期値: 1.01.0
推奨値: 0.0, 0.5, 1.00.0, 0.5, 1.0
値域: 0.0 ≤ Weight2 ≤ 1.0 (lin)
最小増分: 0.1
推奨増分: 0.5

Weight3weight3weight_3 (input_control) real → (real)HTuple (double)HTuple (double)floatHtuple (double)

小さいセグメントに対する重み付け要素

初期値: 1.01.0
推奨値: 0.0, 0.5, 1.00.0, 0.5, 1.0
値域: 0.0 ≤ Weight3 ≤ 1.0 (lin)
最小増分: 0.1
推奨増分: 0.5

ArcCenterRowarcCenterRowarc_center_row (output_control) arc.center.y-array → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

円弧の中心の行座標

ArcCenterColarcCenterColarc_center_col (output_control) arc.center.x-array → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

円弧の中心の列座標

ArcAnglearcAnglearc_angle (output_control) arc.angle.rad-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

円弧の角度

ArcBeginRowarcBeginRowarc_begin_row (output_control) arc.begin.y-array → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

円弧の開始点の行座標

ArcBeginColarcBeginColarc_begin_col (output_control) arc.begin.x-array → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

円弧の開始点の列座標

LineBeginRowlineBeginRowline_begin_row (output_control) line.begin.y-array → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

直線の開始点の行座標

LineBeginCollineBeginColline_begin_col (output_control) line.begin.x-array → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

直線の開始点の列座標

LineEndRowlineEndRowline_end_row (output_control) line.end.y-array → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

直線の終了点の行座標

LineEndCollineEndColline_end_col (output_control) line.end.x-array → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

直線の終了点の列座標

Orderorderorder (output_control) integer-array → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

直線(値 0)と円弧(値 1)の配列順

例🔗

(C)

/* read edge image  */
read_image(&Image,"fig1_kan")\;
/* construct edge region  */
hysteresis_threshold(Image,&RK1,64,255,40,1)\;
connection(RK1,&Rand)\;
/* fetch chain code  */
T_get_region_contour(Rand,&Rows,&Columns)\;
firstline = get_i(Tline,0)\;
firstcol = get_i(Tcol,0)\;
/* approximation with lines and circular arcs */
set_d(t1,0.4,0)\;
set_d(t2,2.4,0)\;

set_d(t3,0.3,0)\;
set_d(t4,0.9,0)\;

set_d(t5,0.2,0)\;

set_d(t6,0.4,0)\;
set_d(t7,2.4,0)\;

set_i(t8,2,0)\;
set_i(t9,12,0)\;

set_d(t10,1.0,0)\;
set_d(t11,1.0,0)\;
set_d(t12,1.0,0)\;

T_approx_chain(Rows,Columns,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,
                &Bzl,&Bzc,&Br,&Bwl,&Bwc,&Ll0,&Lc0,&Ll1,&Lc1,&order)\;
nob = length_tuple(Bzl)\;
nol = length_tuple(Ll0)\;
/* draw lines and arcs */
set_i(WindowHandleTuple,WindowHandle,0)\;
set_line_width(WindowHandle,4)\;
if (nob>0) T_disp_arc(Bzl,Bzc,Br,Bwl,Bwc)\;
set_line_width(WindowHandle,1)\;
if (nol>0) T_disp_line(WindowHandleTuple,Ll0,Lc0,Ll1,Lc1)\;

結果🔗

パラメーターが正しいならば、オペレーター approx_chainApproxChain は、 値 2 (H_MSG_TRUE) を返します。そうでなければ、例外処理が発生します。

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

組み合わせ

前処理の候補

sobel_ampSobelAmp, edges_imageEdgesImage, get_region_contourGetRegionContour, thresholdThreshold, hysteresis_thresholdHysteresisThreshold

後処理の候補

set_line_widthSetLineWidth, disp_arcDispArc, disp_lineDispLine

他の選択候補

get_region_polygonGetRegionPolygon, approx_chain_simpleApproxChainSimple

関連項目

get_region_chainGetRegionChain, smallest_circleSmallestCircle, disp_circleDispCircle, disp_lineDispLine

モジュール🔗

Foundation